]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.2-201309281103.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.2-201309281103.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 aede319..6bf55a4 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/process_32.c b/arch/sparc/kernel/process_32.c
9446 index fdd819d..5af08c8 100644
9447 --- a/arch/sparc/kernel/process_32.c
9448 +++ b/arch/sparc/kernel/process_32.c
9449 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9450
9451 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9452 r->psr, r->pc, r->npc, r->y, print_tainted());
9453 - printk("PC: <%pS>\n", (void *) r->pc);
9454 + printk("PC: <%pA>\n", (void *) r->pc);
9455 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9456 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9457 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9458 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9459 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9460 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9461 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9462 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9463
9464 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9465 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9466 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9467 rw = (struct reg_window32 *) fp;
9468 pc = rw->ins[7];
9469 printk("[%08lx : ", pc);
9470 - printk("%pS ] ", (void *) pc);
9471 + printk("%pA ] ", (void *) pc);
9472 fp = rw->ins[6];
9473 } while (++count < 16);
9474 printk("\n");
9475 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9476 index baebab2..9cd13b1 100644
9477 --- a/arch/sparc/kernel/process_64.c
9478 +++ b/arch/sparc/kernel/process_64.c
9479 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9480 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9481 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9482 if (regs->tstate & TSTATE_PRIV)
9483 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9484 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9485 }
9486
9487 void show_regs(struct pt_regs *regs)
9488 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9489
9490 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9491 regs->tpc, regs->tnpc, regs->y, print_tainted());
9492 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9493 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9494 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9495 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9496 regs->u_regs[3]);
9497 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9498 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9499 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9500 regs->u_regs[15]);
9501 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9502 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9503 show_regwindow(regs);
9504 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9505 }
9506 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9507 ((tp && tp->task) ? tp->task->pid : -1));
9508
9509 if (gp->tstate & TSTATE_PRIV) {
9510 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9511 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9512 (void *) gp->tpc,
9513 (void *) gp->o7,
9514 (void *) gp->i7,
9515 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9516 index 79cc0d1..ec62734 100644
9517 --- a/arch/sparc/kernel/prom_common.c
9518 +++ b/arch/sparc/kernel/prom_common.c
9519 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9520
9521 unsigned int prom_early_allocated __initdata;
9522
9523 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9524 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9525 .nextprop = prom_common_nextprop,
9526 .getproplen = prom_getproplen,
9527 .getproperty = prom_getproperty,
9528 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9529 index 7ff45e4..a58f271 100644
9530 --- a/arch/sparc/kernel/ptrace_64.c
9531 +++ b/arch/sparc/kernel/ptrace_64.c
9532 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9533 return ret;
9534 }
9535
9536 +#ifdef CONFIG_GRKERNSEC_SETXID
9537 +extern void gr_delayed_cred_worker(void);
9538 +#endif
9539 +
9540 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9541 {
9542 int ret = 0;
9543 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9544 /* do the secure computing check first */
9545 secure_computing_strict(regs->u_regs[UREG_G1]);
9546
9547 +#ifdef CONFIG_GRKERNSEC_SETXID
9548 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9549 + gr_delayed_cred_worker();
9550 +#endif
9551 +
9552 if (test_thread_flag(TIF_SYSCALL_TRACE))
9553 ret = tracehook_report_syscall_entry(regs);
9554
9555 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9556
9557 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9558 {
9559 +#ifdef CONFIG_GRKERNSEC_SETXID
9560 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9561 + gr_delayed_cred_worker();
9562 +#endif
9563 +
9564 audit_syscall_exit(regs);
9565
9566 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9567 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9568 index e142545..fd29654 100644
9569 --- a/arch/sparc/kernel/smp_64.c
9570 +++ b/arch/sparc/kernel/smp_64.c
9571 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9572 extern unsigned long xcall_flush_dcache_page_spitfire;
9573
9574 #ifdef CONFIG_DEBUG_DCFLUSH
9575 -extern atomic_t dcpage_flushes;
9576 -extern atomic_t dcpage_flushes_xcall;
9577 +extern atomic_unchecked_t dcpage_flushes;
9578 +extern atomic_unchecked_t dcpage_flushes_xcall;
9579 #endif
9580
9581 static inline void __local_flush_dcache_page(struct page *page)
9582 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9583 return;
9584
9585 #ifdef CONFIG_DEBUG_DCFLUSH
9586 - atomic_inc(&dcpage_flushes);
9587 + atomic_inc_unchecked(&dcpage_flushes);
9588 #endif
9589
9590 this_cpu = get_cpu();
9591 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9592 xcall_deliver(data0, __pa(pg_addr),
9593 (u64) pg_addr, cpumask_of(cpu));
9594 #ifdef CONFIG_DEBUG_DCFLUSH
9595 - atomic_inc(&dcpage_flushes_xcall);
9596 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9597 #endif
9598 }
9599 }
9600 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9601 preempt_disable();
9602
9603 #ifdef CONFIG_DEBUG_DCFLUSH
9604 - atomic_inc(&dcpage_flushes);
9605 + atomic_inc_unchecked(&dcpage_flushes);
9606 #endif
9607 data0 = 0;
9608 pg_addr = page_address(page);
9609 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9610 xcall_deliver(data0, __pa(pg_addr),
9611 (u64) pg_addr, cpu_online_mask);
9612 #ifdef CONFIG_DEBUG_DCFLUSH
9613 - atomic_inc(&dcpage_flushes_xcall);
9614 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9615 #endif
9616 }
9617 __local_flush_dcache_page(page);
9618 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9619 index 3a8d184..49498a8 100644
9620 --- a/arch/sparc/kernel/sys_sparc_32.c
9621 +++ b/arch/sparc/kernel/sys_sparc_32.c
9622 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9623 if (len > TASK_SIZE - PAGE_SIZE)
9624 return -ENOMEM;
9625 if (!addr)
9626 - addr = TASK_UNMAPPED_BASE;
9627 + addr = current->mm->mmap_base;
9628
9629 info.flags = 0;
9630 info.length = len;
9631 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9632 index 51561b8..8256764 100644
9633 --- a/arch/sparc/kernel/sys_sparc_64.c
9634 +++ b/arch/sparc/kernel/sys_sparc_64.c
9635 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9636 struct vm_area_struct * vma;
9637 unsigned long task_size = TASK_SIZE;
9638 int do_color_align;
9639 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9640 struct vm_unmapped_area_info info;
9641
9642 if (flags & MAP_FIXED) {
9643 /* We do not accept a shared mapping if it would violate
9644 * cache aliasing constraints.
9645 */
9646 - if ((flags & MAP_SHARED) &&
9647 + if ((filp || (flags & MAP_SHARED)) &&
9648 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9649 return -EINVAL;
9650 return addr;
9651 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9652 if (filp || (flags & MAP_SHARED))
9653 do_color_align = 1;
9654
9655 +#ifdef CONFIG_PAX_RANDMMAP
9656 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9657 +#endif
9658 +
9659 if (addr) {
9660 if (do_color_align)
9661 addr = COLOR_ALIGN(addr, pgoff);
9662 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9663 addr = PAGE_ALIGN(addr);
9664
9665 vma = find_vma(mm, addr);
9666 - if (task_size - len >= addr &&
9667 - (!vma || addr + len <= vma->vm_start))
9668 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9669 return addr;
9670 }
9671
9672 info.flags = 0;
9673 info.length = len;
9674 - info.low_limit = TASK_UNMAPPED_BASE;
9675 + info.low_limit = mm->mmap_base;
9676 info.high_limit = min(task_size, VA_EXCLUDE_START);
9677 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9678 info.align_offset = pgoff << PAGE_SHIFT;
9679 + info.threadstack_offset = offset;
9680 addr = vm_unmapped_area(&info);
9681
9682 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9683 VM_BUG_ON(addr != -ENOMEM);
9684 info.low_limit = VA_EXCLUDE_END;
9685 +
9686 +#ifdef CONFIG_PAX_RANDMMAP
9687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9688 + info.low_limit += mm->delta_mmap;
9689 +#endif
9690 +
9691 info.high_limit = task_size;
9692 addr = vm_unmapped_area(&info);
9693 }
9694 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9695 unsigned long task_size = STACK_TOP32;
9696 unsigned long addr = addr0;
9697 int do_color_align;
9698 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9699 struct vm_unmapped_area_info info;
9700
9701 /* This should only ever run for 32-bit processes. */
9702 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9703 /* We do not accept a shared mapping if it would violate
9704 * cache aliasing constraints.
9705 */
9706 - if ((flags & MAP_SHARED) &&
9707 + if ((filp || (flags & MAP_SHARED)) &&
9708 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9709 return -EINVAL;
9710 return addr;
9711 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 if (filp || (flags & MAP_SHARED))
9713 do_color_align = 1;
9714
9715 +#ifdef CONFIG_PAX_RANDMMAP
9716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9717 +#endif
9718 +
9719 /* requesting a specific address */
9720 if (addr) {
9721 if (do_color_align)
9722 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9723 addr = PAGE_ALIGN(addr);
9724
9725 vma = find_vma(mm, addr);
9726 - if (task_size - len >= addr &&
9727 - (!vma || addr + len <= vma->vm_start))
9728 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9729 return addr;
9730 }
9731
9732 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9733 info.high_limit = mm->mmap_base;
9734 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9735 info.align_offset = pgoff << PAGE_SHIFT;
9736 + info.threadstack_offset = offset;
9737 addr = vm_unmapped_area(&info);
9738
9739 /*
9740 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9741 VM_BUG_ON(addr != -ENOMEM);
9742 info.flags = 0;
9743 info.low_limit = TASK_UNMAPPED_BASE;
9744 +
9745 +#ifdef CONFIG_PAX_RANDMMAP
9746 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9747 + info.low_limit += mm->delta_mmap;
9748 +#endif
9749 +
9750 info.high_limit = STACK_TOP32;
9751 addr = vm_unmapped_area(&info);
9752 }
9753 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9754 EXPORT_SYMBOL(get_fb_unmapped_area);
9755
9756 /* Essentially the same as PowerPC. */
9757 -static unsigned long mmap_rnd(void)
9758 +static unsigned long mmap_rnd(struct mm_struct *mm)
9759 {
9760 unsigned long rnd = 0UL;
9761
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9764 +#endif
9765 +
9766 if (current->flags & PF_RANDOMIZE) {
9767 unsigned long val = get_random_int();
9768 if (test_thread_flag(TIF_32BIT))
9769 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9770
9771 void arch_pick_mmap_layout(struct mm_struct *mm)
9772 {
9773 - unsigned long random_factor = mmap_rnd();
9774 + unsigned long random_factor = mmap_rnd(mm);
9775 unsigned long gap;
9776
9777 /*
9778 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9779 gap == RLIM_INFINITY ||
9780 sysctl_legacy_va_layout) {
9781 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9782 +
9783 +#ifdef CONFIG_PAX_RANDMMAP
9784 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9785 + mm->mmap_base += mm->delta_mmap;
9786 +#endif
9787 +
9788 mm->get_unmapped_area = arch_get_unmapped_area;
9789 } else {
9790 /* We know it's 32-bit */
9791 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9792 gap = (task_size / 6 * 5);
9793
9794 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9795 +
9796 +#ifdef CONFIG_PAX_RANDMMAP
9797 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9798 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9799 +#endif
9800 +
9801 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9802 }
9803 }
9804 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9805 index 22a1098..6255eb9 100644
9806 --- a/arch/sparc/kernel/syscalls.S
9807 +++ b/arch/sparc/kernel/syscalls.S
9808 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9809 #endif
9810 .align 32
9811 1: ldx [%g6 + TI_FLAGS], %l5
9812 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9813 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9814 be,pt %icc, rtrap
9815 nop
9816 call syscall_trace_leave
9817 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9818
9819 srl %i5, 0, %o5 ! IEU1
9820 srl %i2, 0, %o2 ! IEU0 Group
9821 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9822 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9823 bne,pn %icc, linux_syscall_trace32 ! CTI
9824 mov %i0, %l5 ! IEU1
9825 call %l7 ! CTI Group brk forced
9826 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9827
9828 mov %i3, %o3 ! IEU1
9829 mov %i4, %o4 ! IEU0 Group
9830 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9831 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9832 bne,pn %icc, linux_syscall_trace ! CTI Group
9833 mov %i0, %l5 ! IEU0
9834 2: call %l7 ! CTI Group brk forced
9835 @@ -223,7 +223,7 @@ ret_sys_call:
9836
9837 cmp %o0, -ERESTART_RESTARTBLOCK
9838 bgeu,pn %xcc, 1f
9839 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9840 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9841 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9842
9843 2:
9844 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9845 index 6629829..036032d 100644
9846 --- a/arch/sparc/kernel/traps_32.c
9847 +++ b/arch/sparc/kernel/traps_32.c
9848 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9849 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9850 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9851
9852 +extern void gr_handle_kernel_exploit(void);
9853 +
9854 void die_if_kernel(char *str, struct pt_regs *regs)
9855 {
9856 static int die_counter;
9857 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9858 count++ < 30 &&
9859 (((unsigned long) rw) >= PAGE_OFFSET) &&
9860 !(((unsigned long) rw) & 0x7)) {
9861 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9862 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9863 (void *) rw->ins[7]);
9864 rw = (struct reg_window32 *)rw->ins[6];
9865 }
9866 }
9867 printk("Instruction DUMP:");
9868 instruction_dump ((unsigned long *) regs->pc);
9869 - if(regs->psr & PSR_PS)
9870 + if(regs->psr & PSR_PS) {
9871 + gr_handle_kernel_exploit();
9872 do_exit(SIGKILL);
9873 + }
9874 do_exit(SIGSEGV);
9875 }
9876
9877 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9878 index b3f833a..f485f80 100644
9879 --- a/arch/sparc/kernel/traps_64.c
9880 +++ b/arch/sparc/kernel/traps_64.c
9881 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9882 i + 1,
9883 p->trapstack[i].tstate, p->trapstack[i].tpc,
9884 p->trapstack[i].tnpc, p->trapstack[i].tt);
9885 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9886 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9887 }
9888 }
9889
9890 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9891
9892 lvl -= 0x100;
9893 if (regs->tstate & TSTATE_PRIV) {
9894 +
9895 +#ifdef CONFIG_PAX_REFCOUNT
9896 + if (lvl == 6)
9897 + pax_report_refcount_overflow(regs);
9898 +#endif
9899 +
9900 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9901 die_if_kernel(buffer, regs);
9902 }
9903 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9904 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9905 {
9906 char buffer[32];
9907 -
9908 +
9909 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9910 0, lvl, SIGTRAP) == NOTIFY_STOP)
9911 return;
9912
9913 +#ifdef CONFIG_PAX_REFCOUNT
9914 + if (lvl == 6)
9915 + pax_report_refcount_overflow(regs);
9916 +#endif
9917 +
9918 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9919
9920 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9921 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9922 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9923 printk("%s" "ERROR(%d): ",
9924 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9925 - printk("TPC<%pS>\n", (void *) regs->tpc);
9926 + printk("TPC<%pA>\n", (void *) regs->tpc);
9927 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9928 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9929 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9930 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9931 smp_processor_id(),
9932 (type & 0x1) ? 'I' : 'D',
9933 regs->tpc);
9934 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9935 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9936 panic("Irrecoverable Cheetah+ parity error.");
9937 }
9938
9939 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9940 smp_processor_id(),
9941 (type & 0x1) ? 'I' : 'D',
9942 regs->tpc);
9943 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9944 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9945 }
9946
9947 struct sun4v_error_entry {
9948 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9949 /*0x38*/u64 reserved_5;
9950 };
9951
9952 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9953 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9954 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9955 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9956
9957 static const char *sun4v_err_type_to_str(u8 type)
9958 {
9959 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9960 }
9961
9962 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9963 - int cpu, const char *pfx, atomic_t *ocnt)
9964 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9965 {
9966 u64 *raw_ptr = (u64 *) ent;
9967 u32 attrs;
9968 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9969
9970 show_regs(regs);
9971
9972 - if ((cnt = atomic_read(ocnt)) != 0) {
9973 - atomic_set(ocnt, 0);
9974 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9975 + atomic_set_unchecked(ocnt, 0);
9976 wmb();
9977 printk("%s: Queue overflowed %d times.\n",
9978 pfx, cnt);
9979 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9980 */
9981 void sun4v_resum_overflow(struct pt_regs *regs)
9982 {
9983 - atomic_inc(&sun4v_resum_oflow_cnt);
9984 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9985 }
9986
9987 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9988 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
9989 /* XXX Actually even this can make not that much sense. Perhaps
9990 * XXX we should just pull the plug and panic directly from here?
9991 */
9992 - atomic_inc(&sun4v_nonresum_oflow_cnt);
9993 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
9994 }
9995
9996 unsigned long sun4v_err_itlb_vaddr;
9997 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9998
9999 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10000 regs->tpc, tl);
10001 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10002 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10003 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10004 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10005 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10006 (void *) regs->u_regs[UREG_I7]);
10007 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10008 "pte[%lx] error[%lx]\n",
10009 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10010
10011 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10012 regs->tpc, tl);
10013 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10014 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10015 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10016 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10017 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10018 (void *) regs->u_regs[UREG_I7]);
10019 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10020 "pte[%lx] error[%lx]\n",
10021 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10022 fp = (unsigned long)sf->fp + STACK_BIAS;
10023 }
10024
10025 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10026 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10027 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10028 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10029 int index = tsk->curr_ret_stack;
10030 if (tsk->ret_stack && index >= graph) {
10031 pc = tsk->ret_stack[index - graph].ret;
10032 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10033 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10034 graph++;
10035 }
10036 }
10037 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10038 return (struct reg_window *) (fp + STACK_BIAS);
10039 }
10040
10041 +extern void gr_handle_kernel_exploit(void);
10042 +
10043 void die_if_kernel(char *str, struct pt_regs *regs)
10044 {
10045 static int die_counter;
10046 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10047 while (rw &&
10048 count++ < 30 &&
10049 kstack_valid(tp, (unsigned long) rw)) {
10050 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10051 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10052 (void *) rw->ins[7]);
10053
10054 rw = kernel_stack_up(rw);
10055 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10056 }
10057 user_instruction_dump ((unsigned int __user *) regs->tpc);
10058 }
10059 - if (regs->tstate & TSTATE_PRIV)
10060 + if (regs->tstate & TSTATE_PRIV) {
10061 + gr_handle_kernel_exploit();
10062 do_exit(SIGKILL);
10063 + }
10064 do_exit(SIGSEGV);
10065 }
10066 EXPORT_SYMBOL(die_if_kernel);
10067 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10068 index 8201c25e..072a2a7 100644
10069 --- a/arch/sparc/kernel/unaligned_64.c
10070 +++ b/arch/sparc/kernel/unaligned_64.c
10071 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10072 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10073
10074 if (__ratelimit(&ratelimit)) {
10075 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10076 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10077 regs->tpc, (void *) regs->tpc);
10078 }
10079 }
10080 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10081 index dbe119b..089c7c1 100644
10082 --- a/arch/sparc/lib/Makefile
10083 +++ b/arch/sparc/lib/Makefile
10084 @@ -2,7 +2,7 @@
10085 #
10086
10087 asflags-y := -ansi -DST_DIV0=0x02
10088 -ccflags-y := -Werror
10089 +#ccflags-y := -Werror
10090
10091 lib-$(CONFIG_SPARC32) += ashrdi3.o
10092 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10093 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10094 index 85c233d..68500e0 100644
10095 --- a/arch/sparc/lib/atomic_64.S
10096 +++ b/arch/sparc/lib/atomic_64.S
10097 @@ -17,7 +17,12 @@
10098 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10099 BACKOFF_SETUP(%o2)
10100 1: lduw [%o1], %g1
10101 - add %g1, %o0, %g7
10102 + addcc %g1, %o0, %g7
10103 +
10104 +#ifdef CONFIG_PAX_REFCOUNT
10105 + tvs %icc, 6
10106 +#endif
10107 +
10108 cas [%o1], %g1, %g7
10109 cmp %g1, %g7
10110 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10111 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10112 2: BACKOFF_SPIN(%o2, %o3, 1b)
10113 ENDPROC(atomic_add)
10114
10115 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10116 + BACKOFF_SETUP(%o2)
10117 +1: lduw [%o1], %g1
10118 + add %g1, %o0, %g7
10119 + cas [%o1], %g1, %g7
10120 + cmp %g1, %g7
10121 + bne,pn %icc, 2f
10122 + nop
10123 + retl
10124 + nop
10125 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10126 +ENDPROC(atomic_add_unchecked)
10127 +
10128 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10129 BACKOFF_SETUP(%o2)
10130 1: lduw [%o1], %g1
10131 - sub %g1, %o0, %g7
10132 + subcc %g1, %o0, %g7
10133 +
10134 +#ifdef CONFIG_PAX_REFCOUNT
10135 + tvs %icc, 6
10136 +#endif
10137 +
10138 cas [%o1], %g1, %g7
10139 cmp %g1, %g7
10140 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10141 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10142 2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 ENDPROC(atomic_sub)
10144
10145 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10146 + BACKOFF_SETUP(%o2)
10147 +1: lduw [%o1], %g1
10148 + sub %g1, %o0, %g7
10149 + cas [%o1], %g1, %g7
10150 + cmp %g1, %g7
10151 + bne,pn %icc, 2f
10152 + nop
10153 + retl
10154 + nop
10155 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10156 +ENDPROC(atomic_sub_unchecked)
10157 +
10158 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10159 BACKOFF_SETUP(%o2)
10160 1: lduw [%o1], %g1
10161 - add %g1, %o0, %g7
10162 + addcc %g1, %o0, %g7
10163 +
10164 +#ifdef CONFIG_PAX_REFCOUNT
10165 + tvs %icc, 6
10166 +#endif
10167 +
10168 cas [%o1], %g1, %g7
10169 cmp %g1, %g7
10170 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10171 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10172 2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 ENDPROC(atomic_add_ret)
10174
10175 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10176 + BACKOFF_SETUP(%o2)
10177 +1: lduw [%o1], %g1
10178 + addcc %g1, %o0, %g7
10179 + cas [%o1], %g1, %g7
10180 + cmp %g1, %g7
10181 + bne,pn %icc, 2f
10182 + add %g7, %o0, %g7
10183 + sra %g7, 0, %o0
10184 + retl
10185 + nop
10186 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10187 +ENDPROC(atomic_add_ret_unchecked)
10188 +
10189 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10190 BACKOFF_SETUP(%o2)
10191 1: lduw [%o1], %g1
10192 - sub %g1, %o0, %g7
10193 + subcc %g1, %o0, %g7
10194 +
10195 +#ifdef CONFIG_PAX_REFCOUNT
10196 + tvs %icc, 6
10197 +#endif
10198 +
10199 cas [%o1], %g1, %g7
10200 cmp %g1, %g7
10201 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10202 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10203 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10204 BACKOFF_SETUP(%o2)
10205 1: ldx [%o1], %g1
10206 - add %g1, %o0, %g7
10207 + addcc %g1, %o0, %g7
10208 +
10209 +#ifdef CONFIG_PAX_REFCOUNT
10210 + tvs %xcc, 6
10211 +#endif
10212 +
10213 casx [%o1], %g1, %g7
10214 cmp %g1, %g7
10215 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10216 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10217 2: BACKOFF_SPIN(%o2, %o3, 1b)
10218 ENDPROC(atomic64_add)
10219
10220 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10221 + BACKOFF_SETUP(%o2)
10222 +1: ldx [%o1], %g1
10223 + addcc %g1, %o0, %g7
10224 + casx [%o1], %g1, %g7
10225 + cmp %g1, %g7
10226 + bne,pn %xcc, 2f
10227 + nop
10228 + retl
10229 + nop
10230 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10231 +ENDPROC(atomic64_add_unchecked)
10232 +
10233 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10234 BACKOFF_SETUP(%o2)
10235 1: ldx [%o1], %g1
10236 - sub %g1, %o0, %g7
10237 + subcc %g1, %o0, %g7
10238 +
10239 +#ifdef CONFIG_PAX_REFCOUNT
10240 + tvs %xcc, 6
10241 +#endif
10242 +
10243 casx [%o1], %g1, %g7
10244 cmp %g1, %g7
10245 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10246 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10247 2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 ENDPROC(atomic64_sub)
10249
10250 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10251 + BACKOFF_SETUP(%o2)
10252 +1: ldx [%o1], %g1
10253 + subcc %g1, %o0, %g7
10254 + casx [%o1], %g1, %g7
10255 + cmp %g1, %g7
10256 + bne,pn %xcc, 2f
10257 + nop
10258 + retl
10259 + nop
10260 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 +ENDPROC(atomic64_sub_unchecked)
10262 +
10263 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10264 BACKOFF_SETUP(%o2)
10265 1: ldx [%o1], %g1
10266 - add %g1, %o0, %g7
10267 + addcc %g1, %o0, %g7
10268 +
10269 +#ifdef CONFIG_PAX_REFCOUNT
10270 + tvs %xcc, 6
10271 +#endif
10272 +
10273 casx [%o1], %g1, %g7
10274 cmp %g1, %g7
10275 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10276 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10277 2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 ENDPROC(atomic64_add_ret)
10279
10280 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10281 + BACKOFF_SETUP(%o2)
10282 +1: ldx [%o1], %g1
10283 + addcc %g1, %o0, %g7
10284 + casx [%o1], %g1, %g7
10285 + cmp %g1, %g7
10286 + bne,pn %xcc, 2f
10287 + add %g7, %o0, %g7
10288 + mov %g7, %o0
10289 + retl
10290 + nop
10291 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10292 +ENDPROC(atomic64_add_ret_unchecked)
10293 +
10294 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10295 BACKOFF_SETUP(%o2)
10296 1: ldx [%o1], %g1
10297 - sub %g1, %o0, %g7
10298 + subcc %g1, %o0, %g7
10299 +
10300 +#ifdef CONFIG_PAX_REFCOUNT
10301 + tvs %xcc, 6
10302 +#endif
10303 +
10304 casx [%o1], %g1, %g7
10305 cmp %g1, %g7
10306 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10307 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10308 index 0c4e35e..745d3e4 100644
10309 --- a/arch/sparc/lib/ksyms.c
10310 +++ b/arch/sparc/lib/ksyms.c
10311 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
10312
10313 /* Atomic counter implementation. */
10314 EXPORT_SYMBOL(atomic_add);
10315 +EXPORT_SYMBOL(atomic_add_unchecked);
10316 EXPORT_SYMBOL(atomic_add_ret);
10317 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10318 EXPORT_SYMBOL(atomic_sub);
10319 +EXPORT_SYMBOL(atomic_sub_unchecked);
10320 EXPORT_SYMBOL(atomic_sub_ret);
10321 EXPORT_SYMBOL(atomic64_add);
10322 +EXPORT_SYMBOL(atomic64_add_unchecked);
10323 EXPORT_SYMBOL(atomic64_add_ret);
10324 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10325 EXPORT_SYMBOL(atomic64_sub);
10326 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10327 EXPORT_SYMBOL(atomic64_sub_ret);
10328 EXPORT_SYMBOL(atomic64_dec_if_positive);
10329
10330 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10331 index 30c3ecc..736f015 100644
10332 --- a/arch/sparc/mm/Makefile
10333 +++ b/arch/sparc/mm/Makefile
10334 @@ -2,7 +2,7 @@
10335 #
10336
10337 asflags-y := -ansi
10338 -ccflags-y := -Werror
10339 +#ccflags-y := -Werror
10340
10341 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10342 obj-y += fault_$(BITS).o
10343 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10344 index e98bfda..ea8d221 100644
10345 --- a/arch/sparc/mm/fault_32.c
10346 +++ b/arch/sparc/mm/fault_32.c
10347 @@ -21,6 +21,9 @@
10348 #include <linux/perf_event.h>
10349 #include <linux/interrupt.h>
10350 #include <linux/kdebug.h>
10351 +#include <linux/slab.h>
10352 +#include <linux/pagemap.h>
10353 +#include <linux/compiler.h>
10354
10355 #include <asm/page.h>
10356 #include <asm/pgtable.h>
10357 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10358 return safe_compute_effective_address(regs, insn);
10359 }
10360
10361 +#ifdef CONFIG_PAX_PAGEEXEC
10362 +#ifdef CONFIG_PAX_DLRESOLVE
10363 +static void pax_emuplt_close(struct vm_area_struct *vma)
10364 +{
10365 + vma->vm_mm->call_dl_resolve = 0UL;
10366 +}
10367 +
10368 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10369 +{
10370 + unsigned int *kaddr;
10371 +
10372 + vmf->page = alloc_page(GFP_HIGHUSER);
10373 + if (!vmf->page)
10374 + return VM_FAULT_OOM;
10375 +
10376 + kaddr = kmap(vmf->page);
10377 + memset(kaddr, 0, PAGE_SIZE);
10378 + kaddr[0] = 0x9DE3BFA8U; /* save */
10379 + flush_dcache_page(vmf->page);
10380 + kunmap(vmf->page);
10381 + return VM_FAULT_MAJOR;
10382 +}
10383 +
10384 +static const struct vm_operations_struct pax_vm_ops = {
10385 + .close = pax_emuplt_close,
10386 + .fault = pax_emuplt_fault
10387 +};
10388 +
10389 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10390 +{
10391 + int ret;
10392 +
10393 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10394 + vma->vm_mm = current->mm;
10395 + vma->vm_start = addr;
10396 + vma->vm_end = addr + PAGE_SIZE;
10397 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10398 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10399 + vma->vm_ops = &pax_vm_ops;
10400 +
10401 + ret = insert_vm_struct(current->mm, vma);
10402 + if (ret)
10403 + return ret;
10404 +
10405 + ++current->mm->total_vm;
10406 + return 0;
10407 +}
10408 +#endif
10409 +
10410 +/*
10411 + * PaX: decide what to do with offenders (regs->pc = fault address)
10412 + *
10413 + * returns 1 when task should be killed
10414 + * 2 when patched PLT trampoline was detected
10415 + * 3 when unpatched PLT trampoline was detected
10416 + */
10417 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10418 +{
10419 +
10420 +#ifdef CONFIG_PAX_EMUPLT
10421 + int err;
10422 +
10423 + do { /* PaX: patched PLT emulation #1 */
10424 + unsigned int sethi1, sethi2, jmpl;
10425 +
10426 + err = get_user(sethi1, (unsigned int *)regs->pc);
10427 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10428 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10429 +
10430 + if (err)
10431 + break;
10432 +
10433 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10434 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10435 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10436 + {
10437 + unsigned int addr;
10438 +
10439 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10440 + addr = regs->u_regs[UREG_G1];
10441 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10442 + regs->pc = addr;
10443 + regs->npc = addr+4;
10444 + return 2;
10445 + }
10446 + } while (0);
10447 +
10448 + do { /* PaX: patched PLT emulation #2 */
10449 + unsigned int ba;
10450 +
10451 + err = get_user(ba, (unsigned int *)regs->pc);
10452 +
10453 + if (err)
10454 + break;
10455 +
10456 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10457 + unsigned int addr;
10458 +
10459 + if ((ba & 0xFFC00000U) == 0x30800000U)
10460 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10461 + else
10462 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10463 + regs->pc = addr;
10464 + regs->npc = addr+4;
10465 + return 2;
10466 + }
10467 + } while (0);
10468 +
10469 + do { /* PaX: patched PLT emulation #3 */
10470 + unsigned int sethi, bajmpl, nop;
10471 +
10472 + err = get_user(sethi, (unsigned int *)regs->pc);
10473 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10474 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10475 +
10476 + if (err)
10477 + break;
10478 +
10479 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10480 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10481 + nop == 0x01000000U)
10482 + {
10483 + unsigned int addr;
10484 +
10485 + addr = (sethi & 0x003FFFFFU) << 10;
10486 + regs->u_regs[UREG_G1] = addr;
10487 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10488 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10489 + else
10490 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10491 + regs->pc = addr;
10492 + regs->npc = addr+4;
10493 + return 2;
10494 + }
10495 + } while (0);
10496 +
10497 + do { /* PaX: unpatched PLT emulation step 1 */
10498 + unsigned int sethi, ba, nop;
10499 +
10500 + err = get_user(sethi, (unsigned int *)regs->pc);
10501 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10502 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10503 +
10504 + if (err)
10505 + break;
10506 +
10507 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10508 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10509 + nop == 0x01000000U)
10510 + {
10511 + unsigned int addr, save, call;
10512 +
10513 + if ((ba & 0xFFC00000U) == 0x30800000U)
10514 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10515 + else
10516 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10517 +
10518 + err = get_user(save, (unsigned int *)addr);
10519 + err |= get_user(call, (unsigned int *)(addr+4));
10520 + err |= get_user(nop, (unsigned int *)(addr+8));
10521 + if (err)
10522 + break;
10523 +
10524 +#ifdef CONFIG_PAX_DLRESOLVE
10525 + if (save == 0x9DE3BFA8U &&
10526 + (call & 0xC0000000U) == 0x40000000U &&
10527 + nop == 0x01000000U)
10528 + {
10529 + struct vm_area_struct *vma;
10530 + unsigned long call_dl_resolve;
10531 +
10532 + down_read(&current->mm->mmap_sem);
10533 + call_dl_resolve = current->mm->call_dl_resolve;
10534 + up_read(&current->mm->mmap_sem);
10535 + if (likely(call_dl_resolve))
10536 + goto emulate;
10537 +
10538 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10539 +
10540 + down_write(&current->mm->mmap_sem);
10541 + if (current->mm->call_dl_resolve) {
10542 + call_dl_resolve = current->mm->call_dl_resolve;
10543 + up_write(&current->mm->mmap_sem);
10544 + if (vma)
10545 + kmem_cache_free(vm_area_cachep, vma);
10546 + goto emulate;
10547 + }
10548 +
10549 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10550 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10551 + up_write(&current->mm->mmap_sem);
10552 + if (vma)
10553 + kmem_cache_free(vm_area_cachep, vma);
10554 + return 1;
10555 + }
10556 +
10557 + if (pax_insert_vma(vma, call_dl_resolve)) {
10558 + up_write(&current->mm->mmap_sem);
10559 + kmem_cache_free(vm_area_cachep, vma);
10560 + return 1;
10561 + }
10562 +
10563 + current->mm->call_dl_resolve = call_dl_resolve;
10564 + up_write(&current->mm->mmap_sem);
10565 +
10566 +emulate:
10567 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10568 + regs->pc = call_dl_resolve;
10569 + regs->npc = addr+4;
10570 + return 3;
10571 + }
10572 +#endif
10573 +
10574 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10575 + if ((save & 0xFFC00000U) == 0x05000000U &&
10576 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10577 + nop == 0x01000000U)
10578 + {
10579 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10580 + regs->u_regs[UREG_G2] = addr + 4;
10581 + addr = (save & 0x003FFFFFU) << 10;
10582 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10583 + regs->pc = addr;
10584 + regs->npc = addr+4;
10585 + return 3;
10586 + }
10587 + }
10588 + } while (0);
10589 +
10590 + do { /* PaX: unpatched PLT emulation step 2 */
10591 + unsigned int save, call, nop;
10592 +
10593 + err = get_user(save, (unsigned int *)(regs->pc-4));
10594 + err |= get_user(call, (unsigned int *)regs->pc);
10595 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10596 + if (err)
10597 + break;
10598 +
10599 + if (save == 0x9DE3BFA8U &&
10600 + (call & 0xC0000000U) == 0x40000000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10604 +
10605 + regs->u_regs[UREG_RETPC] = regs->pc;
10606 + regs->pc = dl_resolve;
10607 + regs->npc = dl_resolve+4;
10608 + return 3;
10609 + }
10610 + } while (0);
10611 +#endif
10612 +
10613 + return 1;
10614 +}
10615 +
10616 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10617 +{
10618 + unsigned long i;
10619 +
10620 + printk(KERN_ERR "PAX: bytes at PC: ");
10621 + for (i = 0; i < 8; i++) {
10622 + unsigned int c;
10623 + if (get_user(c, (unsigned int *)pc+i))
10624 + printk(KERN_CONT "???????? ");
10625 + else
10626 + printk(KERN_CONT "%08x ", c);
10627 + }
10628 + printk("\n");
10629 +}
10630 +#endif
10631 +
10632 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10633 int text_fault)
10634 {
10635 @@ -230,6 +504,24 @@ good_area:
10636 if (!(vma->vm_flags & VM_WRITE))
10637 goto bad_area;
10638 } else {
10639 +
10640 +#ifdef CONFIG_PAX_PAGEEXEC
10641 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10642 + up_read(&mm->mmap_sem);
10643 + switch (pax_handle_fetch_fault(regs)) {
10644 +
10645 +#ifdef CONFIG_PAX_EMUPLT
10646 + case 2:
10647 + case 3:
10648 + return;
10649 +#endif
10650 +
10651 + }
10652 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10653 + do_group_exit(SIGKILL);
10654 + }
10655 +#endif
10656 +
10657 /* Allow reads even for write-only mappings */
10658 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10659 goto bad_area;
10660 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10661 index 5062ff3..e0b75f3 100644
10662 --- a/arch/sparc/mm/fault_64.c
10663 +++ b/arch/sparc/mm/fault_64.c
10664 @@ -21,6 +21,9 @@
10665 #include <linux/kprobes.h>
10666 #include <linux/kdebug.h>
10667 #include <linux/percpu.h>
10668 +#include <linux/slab.h>
10669 +#include <linux/pagemap.h>
10670 +#include <linux/compiler.h>
10671
10672 #include <asm/page.h>
10673 #include <asm/pgtable.h>
10674 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10675 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10676 regs->tpc);
10677 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10678 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10679 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10680 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10681 dump_stack();
10682 unhandled_fault(regs->tpc, current, regs);
10683 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10684 show_regs(regs);
10685 }
10686
10687 +#ifdef CONFIG_PAX_PAGEEXEC
10688 +#ifdef CONFIG_PAX_DLRESOLVE
10689 +static void pax_emuplt_close(struct vm_area_struct *vma)
10690 +{
10691 + vma->vm_mm->call_dl_resolve = 0UL;
10692 +}
10693 +
10694 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10695 +{
10696 + unsigned int *kaddr;
10697 +
10698 + vmf->page = alloc_page(GFP_HIGHUSER);
10699 + if (!vmf->page)
10700 + return VM_FAULT_OOM;
10701 +
10702 + kaddr = kmap(vmf->page);
10703 + memset(kaddr, 0, PAGE_SIZE);
10704 + kaddr[0] = 0x9DE3BFA8U; /* save */
10705 + flush_dcache_page(vmf->page);
10706 + kunmap(vmf->page);
10707 + return VM_FAULT_MAJOR;
10708 +}
10709 +
10710 +static const struct vm_operations_struct pax_vm_ops = {
10711 + .close = pax_emuplt_close,
10712 + .fault = pax_emuplt_fault
10713 +};
10714 +
10715 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10716 +{
10717 + int ret;
10718 +
10719 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10720 + vma->vm_mm = current->mm;
10721 + vma->vm_start = addr;
10722 + vma->vm_end = addr + PAGE_SIZE;
10723 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10724 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10725 + vma->vm_ops = &pax_vm_ops;
10726 +
10727 + ret = insert_vm_struct(current->mm, vma);
10728 + if (ret)
10729 + return ret;
10730 +
10731 + ++current->mm->total_vm;
10732 + return 0;
10733 +}
10734 +#endif
10735 +
10736 +/*
10737 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10738 + *
10739 + * returns 1 when task should be killed
10740 + * 2 when patched PLT trampoline was detected
10741 + * 3 when unpatched PLT trampoline was detected
10742 + */
10743 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10744 +{
10745 +
10746 +#ifdef CONFIG_PAX_EMUPLT
10747 + int err;
10748 +
10749 + do { /* PaX: patched PLT emulation #1 */
10750 + unsigned int sethi1, sethi2, jmpl;
10751 +
10752 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10753 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10754 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10755 +
10756 + if (err)
10757 + break;
10758 +
10759 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10760 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10761 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10762 + {
10763 + unsigned long addr;
10764 +
10765 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10766 + addr = regs->u_regs[UREG_G1];
10767 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10768 +
10769 + if (test_thread_flag(TIF_32BIT))
10770 + addr &= 0xFFFFFFFFUL;
10771 +
10772 + regs->tpc = addr;
10773 + regs->tnpc = addr+4;
10774 + return 2;
10775 + }
10776 + } while (0);
10777 +
10778 + do { /* PaX: patched PLT emulation #2 */
10779 + unsigned int ba;
10780 +
10781 + err = get_user(ba, (unsigned int *)regs->tpc);
10782 +
10783 + if (err)
10784 + break;
10785 +
10786 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10787 + unsigned long addr;
10788 +
10789 + if ((ba & 0xFFC00000U) == 0x30800000U)
10790 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10791 + else
10792 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10793 +
10794 + if (test_thread_flag(TIF_32BIT))
10795 + addr &= 0xFFFFFFFFUL;
10796 +
10797 + regs->tpc = addr;
10798 + regs->tnpc = addr+4;
10799 + return 2;
10800 + }
10801 + } while (0);
10802 +
10803 + do { /* PaX: patched PLT emulation #3 */
10804 + unsigned int sethi, bajmpl, nop;
10805 +
10806 + err = get_user(sethi, (unsigned int *)regs->tpc);
10807 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10808 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10809 +
10810 + if (err)
10811 + break;
10812 +
10813 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10814 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10815 + nop == 0x01000000U)
10816 + {
10817 + unsigned long addr;
10818 +
10819 + addr = (sethi & 0x003FFFFFU) << 10;
10820 + regs->u_regs[UREG_G1] = addr;
10821 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10822 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10823 + else
10824 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10825 +
10826 + if (test_thread_flag(TIF_32BIT))
10827 + addr &= 0xFFFFFFFFUL;
10828 +
10829 + regs->tpc = addr;
10830 + regs->tnpc = addr+4;
10831 + return 2;
10832 + }
10833 + } while (0);
10834 +
10835 + do { /* PaX: patched PLT emulation #4 */
10836 + unsigned int sethi, mov1, call, mov2;
10837 +
10838 + err = get_user(sethi, (unsigned int *)regs->tpc);
10839 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10840 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10841 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10842 +
10843 + if (err)
10844 + break;
10845 +
10846 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10847 + mov1 == 0x8210000FU &&
10848 + (call & 0xC0000000U) == 0x40000000U &&
10849 + mov2 == 0x9E100001U)
10850 + {
10851 + unsigned long addr;
10852 +
10853 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10854 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10855 +
10856 + if (test_thread_flag(TIF_32BIT))
10857 + addr &= 0xFFFFFFFFUL;
10858 +
10859 + regs->tpc = addr;
10860 + regs->tnpc = addr+4;
10861 + return 2;
10862 + }
10863 + } while (0);
10864 +
10865 + do { /* PaX: patched PLT emulation #5 */
10866 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10867 +
10868 + err = get_user(sethi, (unsigned int *)regs->tpc);
10869 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10870 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10871 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10872 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10873 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10874 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10875 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10876 +
10877 + if (err)
10878 + break;
10879 +
10880 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10881 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10882 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10883 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10884 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10885 + sllx == 0x83287020U &&
10886 + jmpl == 0x81C04005U &&
10887 + nop == 0x01000000U)
10888 + {
10889 + unsigned long addr;
10890 +
10891 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10892 + regs->u_regs[UREG_G1] <<= 32;
10893 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10894 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10895 + regs->tpc = addr;
10896 + regs->tnpc = addr+4;
10897 + return 2;
10898 + }
10899 + } while (0);
10900 +
10901 + do { /* PaX: patched PLT emulation #6 */
10902 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10903 +
10904 + err = get_user(sethi, (unsigned int *)regs->tpc);
10905 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10906 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10907 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10908 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10909 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10910 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10911 +
10912 + if (err)
10913 + break;
10914 +
10915 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10916 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10917 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10918 + sllx == 0x83287020U &&
10919 + (or & 0xFFFFE000U) == 0x8A116000U &&
10920 + jmpl == 0x81C04005U &&
10921 + nop == 0x01000000U)
10922 + {
10923 + unsigned long addr;
10924 +
10925 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10926 + regs->u_regs[UREG_G1] <<= 32;
10927 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10928 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10929 + regs->tpc = addr;
10930 + regs->tnpc = addr+4;
10931 + return 2;
10932 + }
10933 + } while (0);
10934 +
10935 + do { /* PaX: unpatched PLT emulation step 1 */
10936 + unsigned int sethi, ba, nop;
10937 +
10938 + err = get_user(sethi, (unsigned int *)regs->tpc);
10939 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10940 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10941 +
10942 + if (err)
10943 + break;
10944 +
10945 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10946 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10947 + nop == 0x01000000U)
10948 + {
10949 + unsigned long addr;
10950 + unsigned int save, call;
10951 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10952 +
10953 + if ((ba & 0xFFC00000U) == 0x30800000U)
10954 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10955 + else
10956 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10957 +
10958 + if (test_thread_flag(TIF_32BIT))
10959 + addr &= 0xFFFFFFFFUL;
10960 +
10961 + err = get_user(save, (unsigned int *)addr);
10962 + err |= get_user(call, (unsigned int *)(addr+4));
10963 + err |= get_user(nop, (unsigned int *)(addr+8));
10964 + if (err)
10965 + break;
10966 +
10967 +#ifdef CONFIG_PAX_DLRESOLVE
10968 + if (save == 0x9DE3BFA8U &&
10969 + (call & 0xC0000000U) == 0x40000000U &&
10970 + nop == 0x01000000U)
10971 + {
10972 + struct vm_area_struct *vma;
10973 + unsigned long call_dl_resolve;
10974 +
10975 + down_read(&current->mm->mmap_sem);
10976 + call_dl_resolve = current->mm->call_dl_resolve;
10977 + up_read(&current->mm->mmap_sem);
10978 + if (likely(call_dl_resolve))
10979 + goto emulate;
10980 +
10981 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10982 +
10983 + down_write(&current->mm->mmap_sem);
10984 + if (current->mm->call_dl_resolve) {
10985 + call_dl_resolve = current->mm->call_dl_resolve;
10986 + up_write(&current->mm->mmap_sem);
10987 + if (vma)
10988 + kmem_cache_free(vm_area_cachep, vma);
10989 + goto emulate;
10990 + }
10991 +
10992 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10993 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10994 + up_write(&current->mm->mmap_sem);
10995 + if (vma)
10996 + kmem_cache_free(vm_area_cachep, vma);
10997 + return 1;
10998 + }
10999 +
11000 + if (pax_insert_vma(vma, call_dl_resolve)) {
11001 + up_write(&current->mm->mmap_sem);
11002 + kmem_cache_free(vm_area_cachep, vma);
11003 + return 1;
11004 + }
11005 +
11006 + current->mm->call_dl_resolve = call_dl_resolve;
11007 + up_write(&current->mm->mmap_sem);
11008 +
11009 +emulate:
11010 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11011 + regs->tpc = call_dl_resolve;
11012 + regs->tnpc = addr+4;
11013 + return 3;
11014 + }
11015 +#endif
11016 +
11017 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11018 + if ((save & 0xFFC00000U) == 0x05000000U &&
11019 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11020 + nop == 0x01000000U)
11021 + {
11022 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11023 + regs->u_regs[UREG_G2] = addr + 4;
11024 + addr = (save & 0x003FFFFFU) << 10;
11025 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11026 +
11027 + if (test_thread_flag(TIF_32BIT))
11028 + addr &= 0xFFFFFFFFUL;
11029 +
11030 + regs->tpc = addr;
11031 + regs->tnpc = addr+4;
11032 + return 3;
11033 + }
11034 +
11035 + /* PaX: 64-bit PLT stub */
11036 + err = get_user(sethi1, (unsigned int *)addr);
11037 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11038 + err |= get_user(or1, (unsigned int *)(addr+8));
11039 + err |= get_user(or2, (unsigned int *)(addr+12));
11040 + err |= get_user(sllx, (unsigned int *)(addr+16));
11041 + err |= get_user(add, (unsigned int *)(addr+20));
11042 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11043 + err |= get_user(nop, (unsigned int *)(addr+28));
11044 + if (err)
11045 + break;
11046 +
11047 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11048 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11049 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11050 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11051 + sllx == 0x89293020U &&
11052 + add == 0x8A010005U &&
11053 + jmpl == 0x89C14000U &&
11054 + nop == 0x01000000U)
11055 + {
11056 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11057 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11058 + regs->u_regs[UREG_G4] <<= 32;
11059 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11060 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11061 + regs->u_regs[UREG_G4] = addr + 24;
11062 + addr = regs->u_regs[UREG_G5];
11063 + regs->tpc = addr;
11064 + regs->tnpc = addr+4;
11065 + return 3;
11066 + }
11067 + }
11068 + } while (0);
11069 +
11070 +#ifdef CONFIG_PAX_DLRESOLVE
11071 + do { /* PaX: unpatched PLT emulation step 2 */
11072 + unsigned int save, call, nop;
11073 +
11074 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11075 + err |= get_user(call, (unsigned int *)regs->tpc);
11076 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11077 + if (err)
11078 + break;
11079 +
11080 + if (save == 0x9DE3BFA8U &&
11081 + (call & 0xC0000000U) == 0x40000000U &&
11082 + nop == 0x01000000U)
11083 + {
11084 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11085 +
11086 + if (test_thread_flag(TIF_32BIT))
11087 + dl_resolve &= 0xFFFFFFFFUL;
11088 +
11089 + regs->u_regs[UREG_RETPC] = regs->tpc;
11090 + regs->tpc = dl_resolve;
11091 + regs->tnpc = dl_resolve+4;
11092 + return 3;
11093 + }
11094 + } while (0);
11095 +#endif
11096 +
11097 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11098 + unsigned int sethi, ba, nop;
11099 +
11100 + err = get_user(sethi, (unsigned int *)regs->tpc);
11101 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11102 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11103 +
11104 + if (err)
11105 + break;
11106 +
11107 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11108 + (ba & 0xFFF00000U) == 0x30600000U &&
11109 + nop == 0x01000000U)
11110 + {
11111 + unsigned long addr;
11112 +
11113 + addr = (sethi & 0x003FFFFFU) << 10;
11114 + regs->u_regs[UREG_G1] = addr;
11115 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11116 +
11117 + if (test_thread_flag(TIF_32BIT))
11118 + addr &= 0xFFFFFFFFUL;
11119 +
11120 + regs->tpc = addr;
11121 + regs->tnpc = addr+4;
11122 + return 2;
11123 + }
11124 + } while (0);
11125 +
11126 +#endif
11127 +
11128 + return 1;
11129 +}
11130 +
11131 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11132 +{
11133 + unsigned long i;
11134 +
11135 + printk(KERN_ERR "PAX: bytes at PC: ");
11136 + for (i = 0; i < 8; i++) {
11137 + unsigned int c;
11138 + if (get_user(c, (unsigned int *)pc+i))
11139 + printk(KERN_CONT "???????? ");
11140 + else
11141 + printk(KERN_CONT "%08x ", c);
11142 + }
11143 + printk("\n");
11144 +}
11145 +#endif
11146 +
11147 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11148 {
11149 struct mm_struct *mm = current->mm;
11150 @@ -341,6 +804,29 @@ retry:
11151 if (!vma)
11152 goto bad_area;
11153
11154 +#ifdef CONFIG_PAX_PAGEEXEC
11155 + /* PaX: detect ITLB misses on non-exec pages */
11156 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11157 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11158 + {
11159 + if (address != regs->tpc)
11160 + goto good_area;
11161 +
11162 + up_read(&mm->mmap_sem);
11163 + switch (pax_handle_fetch_fault(regs)) {
11164 +
11165 +#ifdef CONFIG_PAX_EMUPLT
11166 + case 2:
11167 + case 3:
11168 + return;
11169 +#endif
11170 +
11171 + }
11172 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11173 + do_group_exit(SIGKILL);
11174 + }
11175 +#endif
11176 +
11177 /* Pure DTLB misses do not tell us whether the fault causing
11178 * load/store/atomic was a write or not, it only says that there
11179 * was no match. So in such a case we (carefully) read the
11180 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11181 index d2b5944..d878f3c 100644
11182 --- a/arch/sparc/mm/hugetlbpage.c
11183 +++ b/arch/sparc/mm/hugetlbpage.c
11184 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11185 unsigned long addr,
11186 unsigned long len,
11187 unsigned long pgoff,
11188 - unsigned long flags)
11189 + unsigned long flags,
11190 + unsigned long offset)
11191 {
11192 unsigned long task_size = TASK_SIZE;
11193 struct vm_unmapped_area_info info;
11194 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11195
11196 info.flags = 0;
11197 info.length = len;
11198 - info.low_limit = TASK_UNMAPPED_BASE;
11199 + info.low_limit = mm->mmap_base;
11200 info.high_limit = min(task_size, VA_EXCLUDE_START);
11201 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11202 info.align_offset = 0;
11203 + info.threadstack_offset = offset;
11204 addr = vm_unmapped_area(&info);
11205
11206 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11207 VM_BUG_ON(addr != -ENOMEM);
11208 info.low_limit = VA_EXCLUDE_END;
11209 +
11210 +#ifdef CONFIG_PAX_RANDMMAP
11211 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11212 + info.low_limit += mm->delta_mmap;
11213 +#endif
11214 +
11215 info.high_limit = task_size;
11216 addr = vm_unmapped_area(&info);
11217 }
11218 @@ -58,7 +66,8 @@ static unsigned long
11219 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11220 const unsigned long len,
11221 const unsigned long pgoff,
11222 - const unsigned long flags)
11223 + const unsigned long flags,
11224 + const unsigned long offset)
11225 {
11226 struct mm_struct *mm = current->mm;
11227 unsigned long addr = addr0;
11228 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11229 info.high_limit = mm->mmap_base;
11230 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11231 info.align_offset = 0;
11232 + info.threadstack_offset = offset;
11233 addr = vm_unmapped_area(&info);
11234
11235 /*
11236 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 VM_BUG_ON(addr != -ENOMEM);
11238 info.flags = 0;
11239 info.low_limit = TASK_UNMAPPED_BASE;
11240 +
11241 +#ifdef CONFIG_PAX_RANDMMAP
11242 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11243 + info.low_limit += mm->delta_mmap;
11244 +#endif
11245 +
11246 info.high_limit = STACK_TOP32;
11247 addr = vm_unmapped_area(&info);
11248 }
11249 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11250 struct mm_struct *mm = current->mm;
11251 struct vm_area_struct *vma;
11252 unsigned long task_size = TASK_SIZE;
11253 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11254
11255 if (test_thread_flag(TIF_32BIT))
11256 task_size = STACK_TOP32;
11257 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11258 return addr;
11259 }
11260
11261 +#ifdef CONFIG_PAX_RANDMMAP
11262 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11263 +#endif
11264 +
11265 if (addr) {
11266 addr = ALIGN(addr, HPAGE_SIZE);
11267 vma = find_vma(mm, addr);
11268 - if (task_size - len >= addr &&
11269 - (!vma || addr + len <= vma->vm_start))
11270 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11271 return addr;
11272 }
11273 if (mm->get_unmapped_area == arch_get_unmapped_area)
11274 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11275 - pgoff, flags);
11276 + pgoff, flags, offset);
11277 else
11278 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11279 - pgoff, flags);
11280 + pgoff, flags, offset);
11281 }
11282
11283 pte_t *huge_pte_alloc(struct mm_struct *mm,
11284 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11285 index ed82eda..0d80e77 100644
11286 --- a/arch/sparc/mm/init_64.c
11287 +++ b/arch/sparc/mm/init_64.c
11288 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11289 int num_kernel_image_mappings;
11290
11291 #ifdef CONFIG_DEBUG_DCFLUSH
11292 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11293 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11294 #ifdef CONFIG_SMP
11295 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11296 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11297 #endif
11298 #endif
11299
11300 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11301 {
11302 BUG_ON(tlb_type == hypervisor);
11303 #ifdef CONFIG_DEBUG_DCFLUSH
11304 - atomic_inc(&dcpage_flushes);
11305 + atomic_inc_unchecked(&dcpage_flushes);
11306 #endif
11307
11308 #ifdef DCACHE_ALIASING_POSSIBLE
11309 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11310
11311 #ifdef CONFIG_DEBUG_DCFLUSH
11312 seq_printf(m, "DCPageFlushes\t: %d\n",
11313 - atomic_read(&dcpage_flushes));
11314 + atomic_read_unchecked(&dcpage_flushes));
11315 #ifdef CONFIG_SMP
11316 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11317 - atomic_read(&dcpage_flushes_xcall));
11318 + atomic_read_unchecked(&dcpage_flushes_xcall));
11319 #endif /* CONFIG_SMP */
11320 #endif /* CONFIG_DEBUG_DCFLUSH */
11321 }
11322 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11323 index f4500c6..889656c 100644
11324 --- a/arch/tile/include/asm/atomic_64.h
11325 +++ b/arch/tile/include/asm/atomic_64.h
11326 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11327
11328 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11329
11330 +#define atomic64_read_unchecked(v) atomic64_read(v)
11331 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11332 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11333 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11334 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11335 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11336 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11337 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11338 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11339 +
11340 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11341 #define smp_mb__before_atomic_dec() smp_mb()
11342 #define smp_mb__after_atomic_dec() smp_mb()
11343 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11344 index a9a5299..0fce79e 100644
11345 --- a/arch/tile/include/asm/cache.h
11346 +++ b/arch/tile/include/asm/cache.h
11347 @@ -15,11 +15,12 @@
11348 #ifndef _ASM_TILE_CACHE_H
11349 #define _ASM_TILE_CACHE_H
11350
11351 +#include <linux/const.h>
11352 #include <arch/chip.h>
11353
11354 /* bytes per L1 data cache line */
11355 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11356 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11357 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11358
11359 /* bytes per L2 cache line */
11360 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11361 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11362 index e4d44bd..99927a3 100644
11363 --- a/arch/tile/include/asm/uaccess.h
11364 +++ b/arch/tile/include/asm/uaccess.h
11365 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11366 const void __user *from,
11367 unsigned long n)
11368 {
11369 - int sz = __compiletime_object_size(to);
11370 + size_t sz = __compiletime_object_size(to);
11371
11372 - if (likely(sz == -1 || sz >= n))
11373 + if (likely(sz == (size_t)-1 || sz >= n))
11374 n = _copy_from_user(to, from, n);
11375 else
11376 copy_from_user_overflow();
11377 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11378 index 650ccff..45fe2d6 100644
11379 --- a/arch/tile/mm/hugetlbpage.c
11380 +++ b/arch/tile/mm/hugetlbpage.c
11381 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11382 info.high_limit = TASK_SIZE;
11383 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11384 info.align_offset = 0;
11385 + info.threadstack_offset = 0;
11386 return vm_unmapped_area(&info);
11387 }
11388
11389 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11390 info.high_limit = current->mm->mmap_base;
11391 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11392 info.align_offset = 0;
11393 + info.threadstack_offset = 0;
11394 addr = vm_unmapped_area(&info);
11395
11396 /*
11397 diff --git a/arch/um/Makefile b/arch/um/Makefile
11398 index 133f7de..1d6f2f1 100644
11399 --- a/arch/um/Makefile
11400 +++ b/arch/um/Makefile
11401 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11402 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11403 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11404
11405 +ifdef CONSTIFY_PLUGIN
11406 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11407 +endif
11408 +
11409 #This will adjust *FLAGS accordingly to the platform.
11410 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11411
11412 diff --git a/arch/um/defconfig b/arch/um/defconfig
11413 index 08107a7..ab22afe 100644
11414 --- a/arch/um/defconfig
11415 +++ b/arch/um/defconfig
11416 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11417 CONFIG_X86_L1_CACHE_SHIFT=5
11418 CONFIG_X86_XADD=y
11419 CONFIG_X86_PPRO_FENCE=y
11420 -CONFIG_X86_WP_WORKS_OK=y
11421 CONFIG_X86_INVLPG=y
11422 CONFIG_X86_BSWAP=y
11423 CONFIG_X86_POPAD_OK=y
11424 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11425 index 19e1bdd..3665b77 100644
11426 --- a/arch/um/include/asm/cache.h
11427 +++ b/arch/um/include/asm/cache.h
11428 @@ -1,6 +1,7 @@
11429 #ifndef __UM_CACHE_H
11430 #define __UM_CACHE_H
11431
11432 +#include <linux/const.h>
11433
11434 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11435 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11436 @@ -12,6 +13,6 @@
11437 # define L1_CACHE_SHIFT 5
11438 #endif
11439
11440 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11441 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11442
11443 #endif
11444 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11445 index 2e0a6b1..a64d0f5 100644
11446 --- a/arch/um/include/asm/kmap_types.h
11447 +++ b/arch/um/include/asm/kmap_types.h
11448 @@ -8,6 +8,6 @@
11449
11450 /* No more #include "asm/arch/kmap_types.h" ! */
11451
11452 -#define KM_TYPE_NR 14
11453 +#define KM_TYPE_NR 15
11454
11455 #endif
11456 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11457 index 5ff53d9..5850cdf 100644
11458 --- a/arch/um/include/asm/page.h
11459 +++ b/arch/um/include/asm/page.h
11460 @@ -14,6 +14,9 @@
11461 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11462 #define PAGE_MASK (~(PAGE_SIZE-1))
11463
11464 +#define ktla_ktva(addr) (addr)
11465 +#define ktva_ktla(addr) (addr)
11466 +
11467 #ifndef __ASSEMBLY__
11468
11469 struct page;
11470 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11471 index 0032f92..cd151e0 100644
11472 --- a/arch/um/include/asm/pgtable-3level.h
11473 +++ b/arch/um/include/asm/pgtable-3level.h
11474 @@ -58,6 +58,7 @@
11475 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11476 #define pud_populate(mm, pud, pmd) \
11477 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11478 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11479
11480 #ifdef CONFIG_64BIT
11481 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11482 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11483 index bbcef52..6a2a483 100644
11484 --- a/arch/um/kernel/process.c
11485 +++ b/arch/um/kernel/process.c
11486 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11487 return 2;
11488 }
11489
11490 -/*
11491 - * Only x86 and x86_64 have an arch_align_stack().
11492 - * All other arches have "#define arch_align_stack(x) (x)"
11493 - * in their asm/system.h
11494 - * As this is included in UML from asm-um/system-generic.h,
11495 - * we can use it to behave as the subarch does.
11496 - */
11497 -#ifndef arch_align_stack
11498 -unsigned long arch_align_stack(unsigned long sp)
11499 -{
11500 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11501 - sp -= get_random_int() % 8192;
11502 - return sp & ~0xf;
11503 -}
11504 -#endif
11505 -
11506 unsigned long get_wchan(struct task_struct *p)
11507 {
11508 unsigned long stack_page, sp, ip;
11509 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11510 index ad8f795..2c7eec6 100644
11511 --- a/arch/unicore32/include/asm/cache.h
11512 +++ b/arch/unicore32/include/asm/cache.h
11513 @@ -12,8 +12,10 @@
11514 #ifndef __UNICORE_CACHE_H__
11515 #define __UNICORE_CACHE_H__
11516
11517 -#define L1_CACHE_SHIFT (5)
11518 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11519 +#include <linux/const.h>
11520 +
11521 +#define L1_CACHE_SHIFT 5
11522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11523
11524 /*
11525 * Memory returned by kmalloc() may be used for DMA, so we must make
11526 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11527 index b32ebf9..5704f98 100644
11528 --- a/arch/x86/Kconfig
11529 +++ b/arch/x86/Kconfig
11530 @@ -248,7 +248,7 @@ config X86_HT
11531
11532 config X86_32_LAZY_GS
11533 def_bool y
11534 - depends on X86_32 && !CC_STACKPROTECTOR
11535 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11536
11537 config ARCH_HWEIGHT_CFLAGS
11538 string
11539 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11540
11541 config X86_MSR
11542 tristate "/dev/cpu/*/msr - Model-specific register support"
11543 + depends on !GRKERNSEC_KMEM
11544 ---help---
11545 This device gives privileged processes access to the x86
11546 Model-Specific Registers (MSRs). It is a character device with
11547 @@ -1111,7 +1112,7 @@ choice
11548
11549 config NOHIGHMEM
11550 bool "off"
11551 - depends on !X86_NUMAQ
11552 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11553 ---help---
11554 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11555 However, the address space of 32-bit x86 processors is only 4
11556 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11557
11558 config HIGHMEM4G
11559 bool "4GB"
11560 - depends on !X86_NUMAQ
11561 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11562 ---help---
11563 Select this if you have a 32-bit processor and between 1 and 4
11564 gigabytes of physical RAM.
11565 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11566 hex
11567 default 0xB0000000 if VMSPLIT_3G_OPT
11568 default 0x80000000 if VMSPLIT_2G
11569 - default 0x78000000 if VMSPLIT_2G_OPT
11570 + default 0x70000000 if VMSPLIT_2G_OPT
11571 default 0x40000000 if VMSPLIT_1G
11572 default 0xC0000000
11573 depends on X86_32
11574 @@ -1599,6 +1600,7 @@ config SECCOMP
11575
11576 config CC_STACKPROTECTOR
11577 bool "Enable -fstack-protector buffer overflow detection"
11578 + depends on X86_64 || !PAX_MEMORY_UDEREF
11579 ---help---
11580 This option turns on the -fstack-protector GCC feature. This
11581 feature puts, at the beginning of functions, a canary value on
11582 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11583 config PHYSICAL_ALIGN
11584 hex "Alignment value to which kernel should be aligned" if X86_32
11585 default "0x1000000"
11586 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11587 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11588 range 0x2000 0x1000000
11589 ---help---
11590 This value puts the alignment restrictions on physical address
11591 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11592 If unsure, say N.
11593
11594 config COMPAT_VDSO
11595 - def_bool y
11596 + def_bool n
11597 prompt "Compat VDSO support"
11598 depends on X86_32 || IA32_EMULATION
11599 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11600 ---help---
11601 Map the 32-bit VDSO to the predictable old-style address too.
11602
11603 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11604 index c026cca..14657ae 100644
11605 --- a/arch/x86/Kconfig.cpu
11606 +++ b/arch/x86/Kconfig.cpu
11607 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11608
11609 config X86_F00F_BUG
11610 def_bool y
11611 - depends on M586MMX || M586TSC || M586 || M486
11612 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11613
11614 config X86_INVD_BUG
11615 def_bool y
11616 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11617
11618 config X86_ALIGNMENT_16
11619 def_bool y
11620 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11621 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11622
11623 config X86_INTEL_USERCOPY
11624 def_bool y
11625 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11626 # generates cmov.
11627 config X86_CMOV
11628 def_bool y
11629 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11630 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11631
11632 config X86_MINIMUM_CPU_FAMILY
11633 int
11634 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11635 index 78d91af..8ceb94b 100644
11636 --- a/arch/x86/Kconfig.debug
11637 +++ b/arch/x86/Kconfig.debug
11638 @@ -74,7 +74,7 @@ config X86_PTDUMP
11639 config DEBUG_RODATA
11640 bool "Write protect kernel read-only data structures"
11641 default y
11642 - depends on DEBUG_KERNEL
11643 + depends on DEBUG_KERNEL && BROKEN
11644 ---help---
11645 Mark the kernel read-only data as write-protected in the pagetables,
11646 in order to catch accidental (and incorrect) writes to such const
11647 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11648
11649 config DEBUG_SET_MODULE_RONX
11650 bool "Set loadable kernel module data as NX and text as RO"
11651 - depends on MODULES
11652 + depends on MODULES && BROKEN
11653 ---help---
11654 This option helps catch unintended modifications to loadable
11655 kernel module's text and read-only data. It also prevents execution
11656 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11657 index 07639c6..6f2c901 100644
11658 --- a/arch/x86/Makefile
11659 +++ b/arch/x86/Makefile
11660 @@ -54,6 +54,7 @@ else
11661 UTS_MACHINE := x86_64
11662 CHECKFLAGS += -D__x86_64__ -m64
11663
11664 + biarch := $(call cc-option,-m64)
11665 KBUILD_AFLAGS += -m64
11666 KBUILD_CFLAGS += -m64
11667
11668 @@ -241,3 +242,12 @@ define archhelp
11669 echo ' FDINITRD=file initrd for the booted kernel'
11670 echo ' kvmconfig - Enable additional options for guest kernel support'
11671 endef
11672 +
11673 +define OLD_LD
11674 +
11675 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11676 +*** Please upgrade your binutils to 2.18 or newer
11677 +endef
11678 +
11679 +archprepare:
11680 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11681 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11682 index 379814b..add62ce 100644
11683 --- a/arch/x86/boot/Makefile
11684 +++ b/arch/x86/boot/Makefile
11685 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11686 $(call cc-option, -fno-stack-protector) \
11687 $(call cc-option, -mpreferred-stack-boundary=2)
11688 KBUILD_CFLAGS += $(call cc-option, -m32)
11689 +ifdef CONSTIFY_PLUGIN
11690 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11691 +endif
11692 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11693 GCOV_PROFILE := n
11694
11695 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11696 index 878e4b9..20537ab 100644
11697 --- a/arch/x86/boot/bitops.h
11698 +++ b/arch/x86/boot/bitops.h
11699 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11700 u8 v;
11701 const u32 *p = (const u32 *)addr;
11702
11703 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11704 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11705 return v;
11706 }
11707
11708 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11709
11710 static inline void set_bit(int nr, void *addr)
11711 {
11712 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11713 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11714 }
11715
11716 #endif /* BOOT_BITOPS_H */
11717 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11718 index 5b75319..331a4ca 100644
11719 --- a/arch/x86/boot/boot.h
11720 +++ b/arch/x86/boot/boot.h
11721 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11722 static inline u16 ds(void)
11723 {
11724 u16 seg;
11725 - asm("movw %%ds,%0" : "=rm" (seg));
11726 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11727 return seg;
11728 }
11729
11730 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11731 static inline int memcmp(const void *s1, const void *s2, size_t len)
11732 {
11733 u8 diff;
11734 - asm("repe; cmpsb; setnz %0"
11735 + asm volatile("repe; cmpsb; setnz %0"
11736 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11737 return diff;
11738 }
11739 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11740 index dcd90df..c830d7d 100644
11741 --- a/arch/x86/boot/compressed/Makefile
11742 +++ b/arch/x86/boot/compressed/Makefile
11743 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11744 KBUILD_CFLAGS += $(cflags-y)
11745 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11746 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11747 +ifdef CONSTIFY_PLUGIN
11748 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11749 +endif
11750
11751 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11752 GCOV_PROFILE := n
11753 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11754 index b7388a4..03844ec 100644
11755 --- a/arch/x86/boot/compressed/eboot.c
11756 +++ b/arch/x86/boot/compressed/eboot.c
11757 @@ -150,7 +150,6 @@ again:
11758 *addr = max_addr;
11759 }
11760
11761 -free_pool:
11762 efi_call_phys1(sys_table->boottime->free_pool, map);
11763
11764 fail:
11765 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11766 if (i == map_size / desc_size)
11767 status = EFI_NOT_FOUND;
11768
11769 -free_pool:
11770 efi_call_phys1(sys_table->boottime->free_pool, map);
11771 fail:
11772 return status;
11773 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11774 index a53440e..c3dbf1e 100644
11775 --- a/arch/x86/boot/compressed/efi_stub_32.S
11776 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11777 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11778 * parameter 2, ..., param n. To make things easy, we save the return
11779 * address of efi_call_phys in a global variable.
11780 */
11781 - popl %ecx
11782 - movl %ecx, saved_return_addr(%edx)
11783 - /* get the function pointer into ECX*/
11784 - popl %ecx
11785 - movl %ecx, efi_rt_function_ptr(%edx)
11786 + popl saved_return_addr(%edx)
11787 + popl efi_rt_function_ptr(%edx)
11788
11789 /*
11790 * 3. Call the physical function.
11791 */
11792 - call *%ecx
11793 + call *efi_rt_function_ptr(%edx)
11794
11795 /*
11796 * 4. Balance the stack. And because EAX contain the return value,
11797 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11798 1: popl %edx
11799 subl $1b, %edx
11800
11801 - movl efi_rt_function_ptr(%edx), %ecx
11802 - pushl %ecx
11803 + pushl efi_rt_function_ptr(%edx)
11804
11805 /*
11806 * 10. Push the saved return address onto the stack and return.
11807 */
11808 - movl saved_return_addr(%edx), %ecx
11809 - pushl %ecx
11810 - ret
11811 + jmpl *saved_return_addr(%edx)
11812 ENDPROC(efi_call_phys)
11813 .previous
11814
11815 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11816 index 1e3184f..0d11e2e 100644
11817 --- a/arch/x86/boot/compressed/head_32.S
11818 +++ b/arch/x86/boot/compressed/head_32.S
11819 @@ -118,7 +118,7 @@ preferred_addr:
11820 notl %eax
11821 andl %eax, %ebx
11822 #else
11823 - movl $LOAD_PHYSICAL_ADDR, %ebx
11824 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11825 #endif
11826
11827 /* Target address to relocate to for decompression */
11828 @@ -204,7 +204,7 @@ relocated:
11829 * and where it was actually loaded.
11830 */
11831 movl %ebp, %ebx
11832 - subl $LOAD_PHYSICAL_ADDR, %ebx
11833 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11834 jz 2f /* Nothing to be done if loaded at compiled addr. */
11835 /*
11836 * Process relocations.
11837 @@ -212,8 +212,7 @@ relocated:
11838
11839 1: subl $4, %edi
11840 movl (%edi), %ecx
11841 - testl %ecx, %ecx
11842 - jz 2f
11843 + jecxz 2f
11844 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11845 jmp 1b
11846 2:
11847 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11848 index 06e71c2..88a98264 100644
11849 --- a/arch/x86/boot/compressed/head_64.S
11850 +++ b/arch/x86/boot/compressed/head_64.S
11851 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11852 notl %eax
11853 andl %eax, %ebx
11854 #else
11855 - movl $LOAD_PHYSICAL_ADDR, %ebx
11856 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11857 #endif
11858
11859 /* Target address to relocate to for decompression */
11860 @@ -270,7 +270,7 @@ preferred_addr:
11861 notq %rax
11862 andq %rax, %rbp
11863 #else
11864 - movq $LOAD_PHYSICAL_ADDR, %rbp
11865 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11866 #endif
11867
11868 /* Target address to relocate to for decompression */
11869 @@ -361,8 +361,8 @@ gdt:
11870 .long gdt
11871 .word 0
11872 .quad 0x0000000000000000 /* NULL descriptor */
11873 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11874 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11875 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11876 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11877 .quad 0x0080890000000000 /* TS descriptor */
11878 .quad 0x0000000000000000 /* TS continued */
11879 gdt_end:
11880 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11881 index 0319c88..7c1931f 100644
11882 --- a/arch/x86/boot/compressed/misc.c
11883 +++ b/arch/x86/boot/compressed/misc.c
11884 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11885 case PT_LOAD:
11886 #ifdef CONFIG_RELOCATABLE
11887 dest = output;
11888 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11889 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11890 #else
11891 dest = (void *)(phdr->p_paddr);
11892 #endif
11893 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11894 error("Destination address too large");
11895 #endif
11896 #ifndef CONFIG_RELOCATABLE
11897 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11898 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11899 error("Wrong destination address");
11900 #endif
11901
11902 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11903 index 4d3ff03..e4972ff 100644
11904 --- a/arch/x86/boot/cpucheck.c
11905 +++ b/arch/x86/boot/cpucheck.c
11906 @@ -74,7 +74,7 @@ static int has_fpu(void)
11907 u16 fcw = -1, fsw = -1;
11908 u32 cr0;
11909
11910 - asm("movl %%cr0,%0" : "=r" (cr0));
11911 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11912 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11913 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11914 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11915 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11916 {
11917 u32 f0, f1;
11918
11919 - asm("pushfl ; "
11920 + asm volatile("pushfl ; "
11921 "pushfl ; "
11922 "popl %0 ; "
11923 "movl %0,%1 ; "
11924 @@ -115,7 +115,7 @@ static void get_flags(void)
11925 set_bit(X86_FEATURE_FPU, cpu.flags);
11926
11927 if (has_eflag(X86_EFLAGS_ID)) {
11928 - asm("cpuid"
11929 + asm volatile("cpuid"
11930 : "=a" (max_intel_level),
11931 "=b" (cpu_vendor[0]),
11932 "=d" (cpu_vendor[1]),
11933 @@ -124,7 +124,7 @@ static void get_flags(void)
11934
11935 if (max_intel_level >= 0x00000001 &&
11936 max_intel_level <= 0x0000ffff) {
11937 - asm("cpuid"
11938 + asm volatile("cpuid"
11939 : "=a" (tfms),
11940 "=c" (cpu.flags[4]),
11941 "=d" (cpu.flags[0])
11942 @@ -136,7 +136,7 @@ static void get_flags(void)
11943 cpu.model += ((tfms >> 16) & 0xf) << 4;
11944 }
11945
11946 - asm("cpuid"
11947 + asm volatile("cpuid"
11948 : "=a" (max_amd_level)
11949 : "a" (0x80000000)
11950 : "ebx", "ecx", "edx");
11951 @@ -144,7 +144,7 @@ static void get_flags(void)
11952 if (max_amd_level >= 0x80000001 &&
11953 max_amd_level <= 0x8000ffff) {
11954 u32 eax = 0x80000001;
11955 - asm("cpuid"
11956 + asm volatile("cpuid"
11957 : "+a" (eax),
11958 "=c" (cpu.flags[6]),
11959 "=d" (cpu.flags[1])
11960 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11961 u32 ecx = MSR_K7_HWCR;
11962 u32 eax, edx;
11963
11964 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11965 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11966 eax &= ~(1 << 15);
11967 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11968 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11969
11970 get_flags(); /* Make sure it really did something */
11971 err = check_flags();
11972 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11973 u32 ecx = MSR_VIA_FCR;
11974 u32 eax, edx;
11975
11976 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11977 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11978 eax |= (1<<1)|(1<<7);
11979 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11980 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11981
11982 set_bit(X86_FEATURE_CX8, cpu.flags);
11983 err = check_flags();
11984 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 eax, edx;
11986 u32 level = 1;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11990 - asm("cpuid"
11991 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11993 + asm volatile("cpuid"
11994 : "+a" (level), "=d" (cpu.flags[0])
11995 : : "ecx", "ebx");
11996 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11997 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11998
11999 err = check_flags();
12000 }
12001 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12002 index 9ec06a1..2c25e79 100644
12003 --- a/arch/x86/boot/header.S
12004 +++ b/arch/x86/boot/header.S
12005 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12006 # single linked list of
12007 # struct setup_data
12008
12009 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12010 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12011
12012 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12014 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12015 +#else
12016 #define VO_INIT_SIZE (VO__end - VO__text)
12017 +#endif
12018 #if ZO_INIT_SIZE > VO_INIT_SIZE
12019 #define INIT_SIZE ZO_INIT_SIZE
12020 #else
12021 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12022 index db75d07..8e6d0af 100644
12023 --- a/arch/x86/boot/memory.c
12024 +++ b/arch/x86/boot/memory.c
12025 @@ -19,7 +19,7 @@
12026
12027 static int detect_memory_e820(void)
12028 {
12029 - int count = 0;
12030 + unsigned int count = 0;
12031 struct biosregs ireg, oreg;
12032 struct e820entry *desc = boot_params.e820_map;
12033 static struct e820entry buf; /* static so it is zeroed */
12034 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12035 index 11e8c6e..fdbb1ed 100644
12036 --- a/arch/x86/boot/video-vesa.c
12037 +++ b/arch/x86/boot/video-vesa.c
12038 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12039
12040 boot_params.screen_info.vesapm_seg = oreg.es;
12041 boot_params.screen_info.vesapm_off = oreg.di;
12042 + boot_params.screen_info.vesapm_size = oreg.cx;
12043 }
12044
12045 /*
12046 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12047 index 43eda28..5ab5fdb 100644
12048 --- a/arch/x86/boot/video.c
12049 +++ b/arch/x86/boot/video.c
12050 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12051 static unsigned int get_entry(void)
12052 {
12053 char entry_buf[4];
12054 - int i, len = 0;
12055 + unsigned int i, len = 0;
12056 int key;
12057 unsigned int v;
12058
12059 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12060 index 9105655..5e37f27 100644
12061 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12062 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12063 @@ -8,6 +8,8 @@
12064 * including this sentence is retained in full.
12065 */
12066
12067 +#include <asm/alternative-asm.h>
12068 +
12069 .extern crypto_ft_tab
12070 .extern crypto_it_tab
12071 .extern crypto_fl_tab
12072 @@ -70,6 +72,8 @@
12073 je B192; \
12074 leaq 32(r9),r9;
12075
12076 +#define ret pax_force_retaddr 0, 1; ret
12077 +
12078 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12079 movq r1,r2; \
12080 movq r3,r4; \
12081 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12082 index 477e9d7..3ab339f 100644
12083 --- a/arch/x86/crypto/aesni-intel_asm.S
12084 +++ b/arch/x86/crypto/aesni-intel_asm.S
12085 @@ -31,6 +31,7 @@
12086
12087 #include <linux/linkage.h>
12088 #include <asm/inst.h>
12089 +#include <asm/alternative-asm.h>
12090
12091 #ifdef __x86_64__
12092 .data
12093 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12094 pop %r14
12095 pop %r13
12096 pop %r12
12097 + pax_force_retaddr 0, 1
12098 ret
12099 ENDPROC(aesni_gcm_dec)
12100
12101 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12102 pop %r14
12103 pop %r13
12104 pop %r12
12105 + pax_force_retaddr 0, 1
12106 ret
12107 ENDPROC(aesni_gcm_enc)
12108
12109 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12110 pxor %xmm1, %xmm0
12111 movaps %xmm0, (TKEYP)
12112 add $0x10, TKEYP
12113 + pax_force_retaddr_bts
12114 ret
12115 ENDPROC(_key_expansion_128)
12116 ENDPROC(_key_expansion_256a)
12117 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12118 shufps $0b01001110, %xmm2, %xmm1
12119 movaps %xmm1, 0x10(TKEYP)
12120 add $0x20, TKEYP
12121 + pax_force_retaddr_bts
12122 ret
12123 ENDPROC(_key_expansion_192a)
12124
12125 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12126
12127 movaps %xmm0, (TKEYP)
12128 add $0x10, TKEYP
12129 + pax_force_retaddr_bts
12130 ret
12131 ENDPROC(_key_expansion_192b)
12132
12133 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12134 pxor %xmm1, %xmm2
12135 movaps %xmm2, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_256b)
12140
12141 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12142 #ifndef __x86_64__
12143 popl KEYP
12144 #endif
12145 + pax_force_retaddr 0, 1
12146 ret
12147 ENDPROC(aesni_set_key)
12148
12149 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12150 popl KLEN
12151 popl KEYP
12152 #endif
12153 + pax_force_retaddr 0, 1
12154 ret
12155 ENDPROC(aesni_enc)
12156
12157 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12158 AESENC KEY STATE
12159 movaps 0x70(TKEYP), KEY
12160 AESENCLAST KEY STATE
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_aesni_enc1)
12164
12165 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12166 AESENCLAST KEY STATE2
12167 AESENCLAST KEY STATE3
12168 AESENCLAST KEY STATE4
12169 + pax_force_retaddr_bts
12170 ret
12171 ENDPROC(_aesni_enc4)
12172
12173 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_dec)
12180
12181 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12182 AESDEC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESDECLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_dec1)
12188
12189 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12190 AESDECLAST KEY STATE2
12191 AESDECLAST KEY STATE3
12192 AESDECLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_dec4)
12196
12197 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12198 popl KEYP
12199 popl LEN
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_ecb_enc)
12204
12205 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12206 popl KEYP
12207 popl LEN
12208 #endif
12209 + pax_force_retaddr 0, 1
12210 ret
12211 ENDPROC(aesni_ecb_dec)
12212
12213 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12214 popl LEN
12215 popl IVP
12216 #endif
12217 + pax_force_retaddr 0, 1
12218 ret
12219 ENDPROC(aesni_cbc_enc)
12220
12221 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12222 popl LEN
12223 popl IVP
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_cbc_dec)
12228
12229 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12230 mov $1, TCTR_LOW
12231 MOVQ_R64_XMM TCTR_LOW INC
12232 MOVQ_R64_XMM CTR TCTR_LOW
12233 + pax_force_retaddr_bts
12234 ret
12235 ENDPROC(_aesni_inc_init)
12236
12237 @@ -2579,6 +2598,7 @@ _aesni_inc:
12238 .Linc_low:
12239 movaps CTR, IV
12240 PSHUFB_XMM BSWAP_MASK IV
12241 + pax_force_retaddr_bts
12242 ret
12243 ENDPROC(_aesni_inc)
12244
12245 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12246 .Lctr_enc_ret:
12247 movups IV, (IVP)
12248 .Lctr_enc_just_ret:
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_ctr_enc)
12252
12253 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12254 pxor INC, STATE4
12255 movdqu STATE4, 0x70(OUTP)
12256
12257 + pax_force_retaddr 0, 1
12258 ret
12259 ENDPROC(aesni_xts_crypt8)
12260
12261 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12262 index 246c670..4d1ed00 100644
12263 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12264 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12265 @@ -21,6 +21,7 @@
12266 */
12267
12268 #include <linux/linkage.h>
12269 +#include <asm/alternative-asm.h>
12270
12271 .file "blowfish-x86_64-asm.S"
12272 .text
12273 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12274 jnz .L__enc_xor;
12275
12276 write_block();
12277 + pax_force_retaddr 0, 1
12278 ret;
12279 .L__enc_xor:
12280 xor_block();
12281 + pax_force_retaddr 0, 1
12282 ret;
12283 ENDPROC(__blowfish_enc_blk)
12284
12285 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12286
12287 movq %r11, %rbp;
12288
12289 + pax_force_retaddr 0, 1
12290 ret;
12291 ENDPROC(blowfish_dec_blk)
12292
12293 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12294
12295 popq %rbx;
12296 popq %rbp;
12297 + pax_force_retaddr 0, 1
12298 ret;
12299
12300 .L__enc_xor4:
12301 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12302
12303 popq %rbx;
12304 popq %rbp;
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk_4way)
12308
12309 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12310 popq %rbx;
12311 popq %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk_4way)
12316 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12317 index ce71f92..2dd5b1e 100644
12318 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12319 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12320 @@ -16,6 +16,7 @@
12321 */
12322
12323 #include <linux/linkage.h>
12324 +#include <asm/alternative-asm.h>
12325
12326 #define CAMELLIA_TABLE_BYTE_LEN 272
12327
12328 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12329 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12330 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12331 %rcx, (%r9));
12332 + pax_force_retaddr_bts
12333 ret;
12334 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12335
12336 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12337 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12338 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12339 %rax, (%r9));
12340 + pax_force_retaddr_bts
12341 ret;
12342 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12343
12344 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12345 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12346 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12347
12348 + pax_force_retaddr_bts
12349 ret;
12350
12351 .align 8
12352 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12353 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12354 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12355
12356 + pax_force_retaddr_bts
12357 ret;
12358
12359 .align 8
12360 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12361 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12362 %xmm8, %rsi);
12363
12364 + pax_force_retaddr 0, 1
12365 ret;
12366 ENDPROC(camellia_ecb_enc_16way)
12367
12368 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12369 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12370 %xmm8, %rsi);
12371
12372 + pax_force_retaddr 0, 1
12373 ret;
12374 ENDPROC(camellia_ecb_dec_16way)
12375
12376 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12377 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12378 %xmm8, %rsi);
12379
12380 + pax_force_retaddr 0, 1
12381 ret;
12382 ENDPROC(camellia_cbc_dec_16way)
12383
12384 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ctr_16way)
12391
12392 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_xts_crypt_16way)
12399
12400 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12401 index 0e0b886..8fc756a 100644
12402 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12403 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12404 @@ -11,6 +11,7 @@
12405 */
12406
12407 #include <linux/linkage.h>
12408 +#include <asm/alternative-asm.h>
12409
12410 #define CAMELLIA_TABLE_BYTE_LEN 272
12411
12412 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12413 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12414 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12415 %rcx, (%r9));
12416 + pax_force_retaddr_bts
12417 ret;
12418 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12419
12420 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12421 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12422 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12423 %rax, (%r9));
12424 + pax_force_retaddr_bts
12425 ret;
12426 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12427
12428 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12429 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12430 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12431
12432 + pax_force_retaddr_bts
12433 ret;
12434
12435 .align 8
12436 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12437 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12438 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12439
12440 + pax_force_retaddr_bts
12441 ret;
12442
12443 .align 8
12444 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12445
12446 vzeroupper;
12447
12448 + pax_force_retaddr 0, 1
12449 ret;
12450 ENDPROC(camellia_ecb_enc_32way)
12451
12452 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12453
12454 vzeroupper;
12455
12456 + pax_force_retaddr 0, 1
12457 ret;
12458 ENDPROC(camellia_ecb_dec_32way)
12459
12460 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12461
12462 vzeroupper;
12463
12464 + pax_force_retaddr 0, 1
12465 ret;
12466 ENDPROC(camellia_cbc_dec_32way)
12467
12468 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ctr_32way)
12475
12476 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_xts_crypt_32way)
12483
12484 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12485 index 310319c..ce174a4 100644
12486 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12487 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12488 @@ -21,6 +21,7 @@
12489 */
12490
12491 #include <linux/linkage.h>
12492 +#include <asm/alternative-asm.h>
12493
12494 .file "camellia-x86_64-asm_64.S"
12495 .text
12496 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12497 enc_outunpack(mov, RT1);
12498
12499 movq RRBP, %rbp;
12500 + pax_force_retaddr 0, 1
12501 ret;
12502
12503 .L__enc_xor:
12504 enc_outunpack(xor, RT1);
12505
12506 movq RRBP, %rbp;
12507 + pax_force_retaddr 0, 1
12508 ret;
12509 ENDPROC(__camellia_enc_blk)
12510
12511 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12512 dec_outunpack();
12513
12514 movq RRBP, %rbp;
12515 + pax_force_retaddr 0, 1
12516 ret;
12517 ENDPROC(camellia_dec_blk)
12518
12519 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12520
12521 movq RRBP, %rbp;
12522 popq %rbx;
12523 + pax_force_retaddr 0, 1
12524 ret;
12525
12526 .L__enc2_xor:
12527 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12528
12529 movq RRBP, %rbp;
12530 popq %rbx;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk_2way)
12534
12535 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12536
12537 movq RRBP, %rbp;
12538 movq RXOR, %rbx;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk_2way)
12542 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12543 index c35fd5d..c1ee236 100644
12544 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12545 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12546 @@ -24,6 +24,7 @@
12547 */
12548
12549 #include <linux/linkage.h>
12550 +#include <asm/alternative-asm.h>
12551
12552 .file "cast5-avx-x86_64-asm_64.S"
12553
12554 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12555 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12556 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12557
12558 + pax_force_retaddr 0, 1
12559 ret;
12560 ENDPROC(__cast5_enc_blk16)
12561
12562 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12563 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12564 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12565
12566 + pax_force_retaddr 0, 1
12567 ret;
12568
12569 .L__skip_dec:
12570 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12571 vmovdqu RR4, (6*4*4)(%r11);
12572 vmovdqu RL4, (7*4*4)(%r11);
12573
12574 + pax_force_retaddr
12575 ret;
12576 ENDPROC(cast5_ecb_enc_16way)
12577
12578 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12579 vmovdqu RR4, (6*4*4)(%r11);
12580 vmovdqu RL4, (7*4*4)(%r11);
12581
12582 + pax_force_retaddr
12583 ret;
12584 ENDPROC(cast5_ecb_dec_16way)
12585
12586 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12587
12588 popq %r12;
12589
12590 + pax_force_retaddr
12591 ret;
12592 ENDPROC(cast5_cbc_dec_16way)
12593
12594 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12595
12596 popq %r12;
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ctr_16way)
12601 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12602 index e3531f8..18ded3a 100644
12603 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12604 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12605 @@ -24,6 +24,7 @@
12606 */
12607
12608 #include <linux/linkage.h>
12609 +#include <asm/alternative-asm.h>
12610 #include "glue_helper-asm-avx.S"
12611
12612 .file "cast6-avx-x86_64-asm_64.S"
12613 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12614 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12615 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12616
12617 + pax_force_retaddr 0, 1
12618 ret;
12619 ENDPROC(__cast6_enc_blk8)
12620
12621 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12622 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12623 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12624
12625 + pax_force_retaddr 0, 1
12626 ret;
12627 ENDPROC(__cast6_dec_blk8)
12628
12629 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12630
12631 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12632
12633 + pax_force_retaddr
12634 ret;
12635 ENDPROC(cast6_ecb_enc_8way)
12636
12637 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12638
12639 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12640
12641 + pax_force_retaddr
12642 ret;
12643 ENDPROC(cast6_ecb_dec_8way)
12644
12645 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12646
12647 popq %r12;
12648
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(cast6_cbc_dec_8way)
12652
12653 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12654
12655 popq %r12;
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ctr_8way)
12660
12661 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12662 /* dst <= regs xor IVs(in dst) */
12663 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_xts_enc_8way)
12668
12669 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12670 /* dst <= regs xor IVs(in dst) */
12671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_xts_dec_8way)
12676 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12677 index dbc4339..3d868c5 100644
12678 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12679 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12680 @@ -45,6 +45,7 @@
12681
12682 #include <asm/inst.h>
12683 #include <linux/linkage.h>
12684 +#include <asm/alternative-asm.h>
12685
12686 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12687
12688 @@ -312,6 +313,7 @@ do_return:
12689 popq %rsi
12690 popq %rdi
12691 popq %rbx
12692 + pax_force_retaddr 0, 1
12693 ret
12694
12695 ################################################################
12696 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12697 index 586f41a..d02851e 100644
12698 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12699 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12700 @@ -18,6 +18,7 @@
12701
12702 #include <linux/linkage.h>
12703 #include <asm/inst.h>
12704 +#include <asm/alternative-asm.h>
12705
12706 .data
12707
12708 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12709 psrlq $1, T2
12710 pxor T2, T1
12711 pxor T1, DATA
12712 + pax_force_retaddr
12713 ret
12714 ENDPROC(__clmul_gf128mul_ble)
12715
12716 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12717 call __clmul_gf128mul_ble
12718 PSHUFB_XMM BSWAP DATA
12719 movups DATA, (%rdi)
12720 + pax_force_retaddr
12721 ret
12722 ENDPROC(clmul_ghash_mul)
12723
12724 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12725 PSHUFB_XMM BSWAP DATA
12726 movups DATA, (%rdi)
12727 .Lupdate_just_ret:
12728 + pax_force_retaddr
12729 ret
12730 ENDPROC(clmul_ghash_update)
12731
12732 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12733 pand .Lpoly, %xmm1
12734 pxor %xmm1, %xmm0
12735 movups %xmm0, (%rdi)
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(clmul_ghash_setkey)
12739 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12740 index 9279e0b..9270820 100644
12741 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12742 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12743 @@ -1,4 +1,5 @@
12744 #include <linux/linkage.h>
12745 +#include <asm/alternative-asm.h>
12746
12747 # enter salsa20_encrypt_bytes
12748 ENTRY(salsa20_encrypt_bytes)
12749 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12750 add %r11,%rsp
12751 mov %rdi,%rax
12752 mov %rsi,%rdx
12753 + pax_force_retaddr 0, 1
12754 ret
12755 # bytesatleast65:
12756 ._bytesatleast65:
12757 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12758 add %r11,%rsp
12759 mov %rdi,%rax
12760 mov %rsi,%rdx
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(salsa20_keysetup)
12764
12765 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12766 add %r11,%rsp
12767 mov %rdi,%rax
12768 mov %rsi,%rdx
12769 + pax_force_retaddr
12770 ret
12771 ENDPROC(salsa20_ivsetup)
12772 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12773 index 2f202f4..d9164d6 100644
12774 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12775 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12776 @@ -24,6 +24,7 @@
12777 */
12778
12779 #include <linux/linkage.h>
12780 +#include <asm/alternative-asm.h>
12781 #include "glue_helper-asm-avx.S"
12782
12783 .file "serpent-avx-x86_64-asm_64.S"
12784 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12785 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12786 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12787
12788 + pax_force_retaddr
12789 ret;
12790 ENDPROC(__serpent_enc_blk8_avx)
12791
12792 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12793 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12794 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12795
12796 + pax_force_retaddr
12797 ret;
12798 ENDPROC(__serpent_dec_blk8_avx)
12799
12800 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12801
12802 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12803
12804 + pax_force_retaddr
12805 ret;
12806 ENDPROC(serpent_ecb_enc_8way_avx)
12807
12808 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12809
12810 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(serpent_ecb_dec_8way_avx)
12815
12816 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12817
12818 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(serpent_cbc_dec_8way_avx)
12823
12824 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12825
12826 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ctr_8way_avx)
12831
12832 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12833 /* dst <= regs xor IVs(in dst) */
12834 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_xts_enc_8way_avx)
12839
12840 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12841 /* dst <= regs xor IVs(in dst) */
12842 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_xts_dec_8way_avx)
12847 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12848 index b222085..abd483c 100644
12849 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12850 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12851 @@ -15,6 +15,7 @@
12852 */
12853
12854 #include <linux/linkage.h>
12855 +#include <asm/alternative-asm.h>
12856 #include "glue_helper-asm-avx2.S"
12857
12858 .file "serpent-avx2-asm_64.S"
12859 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12860 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12861 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12862
12863 + pax_force_retaddr
12864 ret;
12865 ENDPROC(__serpent_enc_blk16)
12866
12867 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12868 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12869 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12870
12871 + pax_force_retaddr
12872 ret;
12873 ENDPROC(__serpent_dec_blk16)
12874
12875 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12876
12877 vzeroupper;
12878
12879 + pax_force_retaddr
12880 ret;
12881 ENDPROC(serpent_ecb_enc_16way)
12882
12883 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12884
12885 vzeroupper;
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(serpent_ecb_dec_16way)
12890
12891 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12892
12893 vzeroupper;
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(serpent_cbc_dec_16way)
12898
12899 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ctr_16way)
12906
12907 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_xts_enc_16way)
12914
12915 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_xts_dec_16way)
12922 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12923 index acc066c..1559cc4 100644
12924 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12925 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12926 @@ -25,6 +25,7 @@
12927 */
12928
12929 #include <linux/linkage.h>
12930 +#include <asm/alternative-asm.h>
12931
12932 .file "serpent-sse2-x86_64-asm_64.S"
12933 .text
12934 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12935 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12936 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12937
12938 + pax_force_retaddr
12939 ret;
12940
12941 .L__enc_xor8:
12942 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12943 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12944
12945 + pax_force_retaddr
12946 ret;
12947 ENDPROC(__serpent_enc_blk_8way)
12948
12949 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12950 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12951 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12952
12953 + pax_force_retaddr
12954 ret;
12955 ENDPROC(serpent_dec_blk_8way)
12956 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12957 index a410950..3356d42 100644
12958 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12959 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12960 @@ -29,6 +29,7 @@
12961 */
12962
12963 #include <linux/linkage.h>
12964 +#include <asm/alternative-asm.h>
12965
12966 #define CTX %rdi // arg1
12967 #define BUF %rsi // arg2
12968 @@ -104,6 +105,7 @@
12969 pop %r12
12970 pop %rbp
12971 pop %rbx
12972 + pax_force_retaddr 0, 1
12973 ret
12974
12975 ENDPROC(\name)
12976 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12977 index 642f156..4ab07b9 100644
12978 --- a/arch/x86/crypto/sha256-avx-asm.S
12979 +++ b/arch/x86/crypto/sha256-avx-asm.S
12980 @@ -49,6 +49,7 @@
12981
12982 #ifdef CONFIG_AS_AVX
12983 #include <linux/linkage.h>
12984 +#include <asm/alternative-asm.h>
12985
12986 ## assume buffers not aligned
12987 #define VMOVDQ vmovdqu
12988 @@ -460,6 +461,7 @@ done_hash:
12989 popq %r13
12990 popq %rbp
12991 popq %rbx
12992 + pax_force_retaddr 0, 1
12993 ret
12994 ENDPROC(sha256_transform_avx)
12995
12996 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12997 index 9e86944..2e7f95a 100644
12998 --- a/arch/x86/crypto/sha256-avx2-asm.S
12999 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13000 @@ -50,6 +50,7 @@
13001
13002 #ifdef CONFIG_AS_AVX2
13003 #include <linux/linkage.h>
13004 +#include <asm/alternative-asm.h>
13005
13006 ## assume buffers not aligned
13007 #define VMOVDQ vmovdqu
13008 @@ -720,6 +721,7 @@ done_hash:
13009 popq %r12
13010 popq %rbp
13011 popq %rbx
13012 + pax_force_retaddr 0, 1
13013 ret
13014 ENDPROC(sha256_transform_rorx)
13015
13016 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13017 index f833b74..c36ed14 100644
13018 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13019 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13020 @@ -47,6 +47,7 @@
13021 ########################################################################
13022
13023 #include <linux/linkage.h>
13024 +#include <asm/alternative-asm.h>
13025
13026 ## assume buffers not aligned
13027 #define MOVDQ movdqu
13028 @@ -471,6 +472,7 @@ done_hash:
13029 popq %rbp
13030 popq %rbx
13031
13032 + pax_force_retaddr 0, 1
13033 ret
13034 ENDPROC(sha256_transform_ssse3)
13035
13036 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13037 index 974dde9..4533d34 100644
13038 --- a/arch/x86/crypto/sha512-avx-asm.S
13039 +++ b/arch/x86/crypto/sha512-avx-asm.S
13040 @@ -49,6 +49,7 @@
13041
13042 #ifdef CONFIG_AS_AVX
13043 #include <linux/linkage.h>
13044 +#include <asm/alternative-asm.h>
13045
13046 .text
13047
13048 @@ -364,6 +365,7 @@ updateblock:
13049 mov frame_RSPSAVE(%rsp), %rsp
13050
13051 nowork:
13052 + pax_force_retaddr 0, 1
13053 ret
13054 ENDPROC(sha512_transform_avx)
13055
13056 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13057 index 568b961..061ef1d 100644
13058 --- a/arch/x86/crypto/sha512-avx2-asm.S
13059 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13060 @@ -51,6 +51,7 @@
13061
13062 #ifdef CONFIG_AS_AVX2
13063 #include <linux/linkage.h>
13064 +#include <asm/alternative-asm.h>
13065
13066 .text
13067
13068 @@ -678,6 +679,7 @@ done_hash:
13069
13070 # Restore Stack Pointer
13071 mov frame_RSPSAVE(%rsp), %rsp
13072 + pax_force_retaddr 0, 1
13073 ret
13074 ENDPROC(sha512_transform_rorx)
13075
13076 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13077 index fb56855..e23914f 100644
13078 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13079 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13080 @@ -48,6 +48,7 @@
13081 ########################################################################
13082
13083 #include <linux/linkage.h>
13084 +#include <asm/alternative-asm.h>
13085
13086 .text
13087
13088 @@ -363,6 +364,7 @@ updateblock:
13089 mov frame_RSPSAVE(%rsp), %rsp
13090
13091 nowork:
13092 + pax_force_retaddr 0, 1
13093 ret
13094 ENDPROC(sha512_transform_ssse3)
13095
13096 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13097 index 0505813..63b1d00 100644
13098 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13099 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13100 @@ -24,6 +24,7 @@
13101 */
13102
13103 #include <linux/linkage.h>
13104 +#include <asm/alternative-asm.h>
13105 #include "glue_helper-asm-avx.S"
13106
13107 .file "twofish-avx-x86_64-asm_64.S"
13108 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13109 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13110 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13111
13112 + pax_force_retaddr 0, 1
13113 ret;
13114 ENDPROC(__twofish_enc_blk8)
13115
13116 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13117 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13118 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13119
13120 + pax_force_retaddr 0, 1
13121 ret;
13122 ENDPROC(__twofish_dec_blk8)
13123
13124 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13125
13126 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13127
13128 + pax_force_retaddr 0, 1
13129 ret;
13130 ENDPROC(twofish_ecb_enc_8way)
13131
13132 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13133
13134 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(twofish_ecb_dec_8way)
13139
13140 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13141
13142 popq %r12;
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(twofish_cbc_dec_8way)
13147
13148 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13149
13150 popq %r12;
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ctr_8way)
13155
13156 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13157 /* dst <= regs xor IVs(in dst) */
13158 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_xts_enc_8way)
13163
13164 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13165 /* dst <= regs xor IVs(in dst) */
13166 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_xts_dec_8way)
13171 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13172 index 1c3b7ce..b365c5e 100644
13173 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13174 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13175 @@ -21,6 +21,7 @@
13176 */
13177
13178 #include <linux/linkage.h>
13179 +#include <asm/alternative-asm.h>
13180
13181 .file "twofish-x86_64-asm-3way.S"
13182 .text
13183 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13184 popq %r13;
13185 popq %r14;
13186 popq %r15;
13187 + pax_force_retaddr 0, 1
13188 ret;
13189
13190 .L__enc_xor3:
13191 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13192 popq %r13;
13193 popq %r14;
13194 popq %r15;
13195 + pax_force_retaddr 0, 1
13196 ret;
13197 ENDPROC(__twofish_enc_blk_3way)
13198
13199 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13200 popq %r13;
13201 popq %r14;
13202 popq %r15;
13203 + pax_force_retaddr 0, 1
13204 ret;
13205 ENDPROC(twofish_dec_blk_3way)
13206 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13207 index a039d21..29e7615 100644
13208 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13209 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13210 @@ -22,6 +22,7 @@
13211
13212 #include <linux/linkage.h>
13213 #include <asm/asm-offsets.h>
13214 +#include <asm/alternative-asm.h>
13215
13216 #define a_offset 0
13217 #define b_offset 4
13218 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13219
13220 popq R1
13221 movq $1,%rax
13222 + pax_force_retaddr 0, 1
13223 ret
13224 ENDPROC(twofish_enc_blk)
13225
13226 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13227
13228 popq R1
13229 movq $1,%rax
13230 + pax_force_retaddr 0, 1
13231 ret
13232 ENDPROC(twofish_dec_blk)
13233 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13234 index bae3aba..c1788c1 100644
13235 --- a/arch/x86/ia32/ia32_aout.c
13236 +++ b/arch/x86/ia32/ia32_aout.c
13237 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13238 unsigned long dump_start, dump_size;
13239 struct user32 dump;
13240
13241 + memset(&dump, 0, sizeof(dump));
13242 +
13243 fs = get_fs();
13244 set_fs(KERNEL_DS);
13245 has_dumped = 1;
13246 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13247 index 665a730..8e7a67a 100644
13248 --- a/arch/x86/ia32/ia32_signal.c
13249 +++ b/arch/x86/ia32/ia32_signal.c
13250 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13251 sp -= frame_size;
13252 /* Align the stack pointer according to the i386 ABI,
13253 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13254 - sp = ((sp + 4) & -16ul) - 4;
13255 + sp = ((sp - 12) & -16ul) - 4;
13256 return (void __user *) sp;
13257 }
13258
13259 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13260 * These are actually not used anymore, but left because some
13261 * gdb versions depend on them as a marker.
13262 */
13263 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13264 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13265 } put_user_catch(err);
13266
13267 if (err)
13268 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13269 0xb8,
13270 __NR_ia32_rt_sigreturn,
13271 0x80cd,
13272 - 0,
13273 + 0
13274 };
13275
13276 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13277 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13278
13279 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13280 restorer = ksig->ka.sa.sa_restorer;
13281 + else if (current->mm->context.vdso)
13282 + /* Return stub is in 32bit vsyscall page */
13283 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13284 else
13285 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13286 - rt_sigreturn);
13287 + restorer = &frame->retcode;
13288 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13289
13290 /*
13291 * Not actually used anymore, but left because some gdb
13292 * versions need it.
13293 */
13294 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13295 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13296 } put_user_catch(err);
13297
13298 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13299 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13300 index 474dc1b..9297c58 100644
13301 --- a/arch/x86/ia32/ia32entry.S
13302 +++ b/arch/x86/ia32/ia32entry.S
13303 @@ -15,8 +15,10 @@
13304 #include <asm/irqflags.h>
13305 #include <asm/asm.h>
13306 #include <asm/smap.h>
13307 +#include <asm/pgtable.h>
13308 #include <linux/linkage.h>
13309 #include <linux/err.h>
13310 +#include <asm/alternative-asm.h>
13311
13312 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13313 #include <linux/elf-em.h>
13314 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13315 ENDPROC(native_irq_enable_sysexit)
13316 #endif
13317
13318 + .macro pax_enter_kernel_user
13319 + pax_set_fptr_mask
13320 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13321 + call pax_enter_kernel_user
13322 +#endif
13323 + .endm
13324 +
13325 + .macro pax_exit_kernel_user
13326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13327 + call pax_exit_kernel_user
13328 +#endif
13329 +#ifdef CONFIG_PAX_RANDKSTACK
13330 + pushq %rax
13331 + pushq %r11
13332 + call pax_randomize_kstack
13333 + popq %r11
13334 + popq %rax
13335 +#endif
13336 + .endm
13337 +
13338 + .macro pax_erase_kstack
13339 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13340 + call pax_erase_kstack
13341 +#endif
13342 + .endm
13343 +
13344 /*
13345 * 32bit SYSENTER instruction entry.
13346 *
13347 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13348 CFI_REGISTER rsp,rbp
13349 SWAPGS_UNSAFE_STACK
13350 movq PER_CPU_VAR(kernel_stack), %rsp
13351 - addq $(KERNEL_STACK_OFFSET),%rsp
13352 - /*
13353 - * No need to follow this irqs on/off section: the syscall
13354 - * disabled irqs, here we enable it straight after entry:
13355 - */
13356 - ENABLE_INTERRUPTS(CLBR_NONE)
13357 movl %ebp,%ebp /* zero extension */
13358 pushq_cfi $__USER32_DS
13359 /*CFI_REL_OFFSET ss,0*/
13360 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13361 CFI_REL_OFFSET rsp,0
13362 pushfq_cfi
13363 /*CFI_REL_OFFSET rflags,0*/
13364 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13365 - CFI_REGISTER rip,r10
13366 + orl $X86_EFLAGS_IF,(%rsp)
13367 + GET_THREAD_INFO(%r11)
13368 + movl TI_sysenter_return(%r11), %r11d
13369 + CFI_REGISTER rip,r11
13370 pushq_cfi $__USER32_CS
13371 /*CFI_REL_OFFSET cs,0*/
13372 movl %eax, %eax
13373 - pushq_cfi %r10
13374 + pushq_cfi %r11
13375 CFI_REL_OFFSET rip,0
13376 pushq_cfi %rax
13377 cld
13378 SAVE_ARGS 0,1,0
13379 + pax_enter_kernel_user
13380 +
13381 +#ifdef CONFIG_PAX_RANDKSTACK
13382 + pax_erase_kstack
13383 +#endif
13384 +
13385 + /*
13386 + * No need to follow this irqs on/off section: the syscall
13387 + * disabled irqs, here we enable it straight after entry:
13388 + */
13389 + ENABLE_INTERRUPTS(CLBR_NONE)
13390 /* no need to do an access_ok check here because rbp has been
13391 32bit zero extended */
13392 +
13393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13394 + addq pax_user_shadow_base,%rbp
13395 + ASM_PAX_OPEN_USERLAND
13396 +#endif
13397 +
13398 ASM_STAC
13399 1: movl (%rbp),%ebp
13400 _ASM_EXTABLE(1b,ia32_badarg)
13401 ASM_CLAC
13402 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13403 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13404 +
13405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13406 + ASM_PAX_CLOSE_USERLAND
13407 +#endif
13408 +
13409 + GET_THREAD_INFO(%r11)
13410 + orl $TS_COMPAT,TI_status(%r11)
13411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13412 CFI_REMEMBER_STATE
13413 jnz sysenter_tracesys
13414 cmpq $(IA32_NR_syscalls-1),%rax
13415 @@ -162,12 +209,15 @@ sysenter_do_call:
13416 sysenter_dispatch:
13417 call *ia32_sys_call_table(,%rax,8)
13418 movq %rax,RAX-ARGOFFSET(%rsp)
13419 + GET_THREAD_INFO(%r11)
13420 DISABLE_INTERRUPTS(CLBR_NONE)
13421 TRACE_IRQS_OFF
13422 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13423 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13424 jnz sysexit_audit
13425 sysexit_from_sys_call:
13426 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 + pax_exit_kernel_user
13428 + pax_erase_kstack
13429 + andl $~TS_COMPAT,TI_status(%r11)
13430 /* clear IF, that popfq doesn't enable interrupts early */
13431 andl $~0x200,EFLAGS-R11(%rsp)
13432 movl RIP-R11(%rsp),%edx /* User %eip */
13433 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13434 movl %eax,%esi /* 2nd arg: syscall number */
13435 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13436 call __audit_syscall_entry
13437 +
13438 + pax_erase_kstack
13439 +
13440 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13441 cmpq $(IA32_NR_syscalls-1),%rax
13442 ja ia32_badsys
13443 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13444 .endm
13445
13446 .macro auditsys_exit exit
13447 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13449 jnz ia32_ret_from_sys_call
13450 TRACE_IRQS_ON
13451 ENABLE_INTERRUPTS(CLBR_NONE)
13452 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13453 1: setbe %al /* 1 if error, 0 if not */
13454 movzbl %al,%edi /* zero-extend that into %edi */
13455 call __audit_syscall_exit
13456 + GET_THREAD_INFO(%r11)
13457 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13458 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13459 DISABLE_INTERRUPTS(CLBR_NONE)
13460 TRACE_IRQS_OFF
13461 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13462 + testl %edi,TI_flags(%r11)
13463 jz \exit
13464 CLEAR_RREGS -ARGOFFSET
13465 jmp int_with_check
13466 @@ -237,7 +291,7 @@ sysexit_audit:
13467
13468 sysenter_tracesys:
13469 #ifdef CONFIG_AUDITSYSCALL
13470 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13471 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13472 jz sysenter_auditsys
13473 #endif
13474 SAVE_REST
13475 @@ -249,6 +303,9 @@ sysenter_tracesys:
13476 RESTORE_REST
13477 cmpq $(IA32_NR_syscalls-1),%rax
13478 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13479 +
13480 + pax_erase_kstack
13481 +
13482 jmp sysenter_do_call
13483 CFI_ENDPROC
13484 ENDPROC(ia32_sysenter_target)
13485 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13486 ENTRY(ia32_cstar_target)
13487 CFI_STARTPROC32 simple
13488 CFI_SIGNAL_FRAME
13489 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13490 + CFI_DEF_CFA rsp,0
13491 CFI_REGISTER rip,rcx
13492 /*CFI_REGISTER rflags,r11*/
13493 SWAPGS_UNSAFE_STACK
13494 movl %esp,%r8d
13495 CFI_REGISTER rsp,r8
13496 movq PER_CPU_VAR(kernel_stack),%rsp
13497 + SAVE_ARGS 8*6,0,0
13498 + pax_enter_kernel_user
13499 +
13500 +#ifdef CONFIG_PAX_RANDKSTACK
13501 + pax_erase_kstack
13502 +#endif
13503 +
13504 /*
13505 * No need to follow this irqs on/off section: the syscall
13506 * disabled irqs and here we enable it straight after entry:
13507 */
13508 ENABLE_INTERRUPTS(CLBR_NONE)
13509 - SAVE_ARGS 8,0,0
13510 movl %eax,%eax /* zero extension */
13511 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13512 movq %rcx,RIP-ARGOFFSET(%rsp)
13513 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13514 /* no need to do an access_ok check here because r8 has been
13515 32bit zero extended */
13516 /* hardware stack frame is complete now */
13517 +
13518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13519 + ASM_PAX_OPEN_USERLAND
13520 + movq pax_user_shadow_base,%r8
13521 + addq RSP-ARGOFFSET(%rsp),%r8
13522 +#endif
13523 +
13524 ASM_STAC
13525 1: movl (%r8),%r9d
13526 _ASM_EXTABLE(1b,ia32_badarg)
13527 ASM_CLAC
13528 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13529 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13530 +
13531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13532 + ASM_PAX_CLOSE_USERLAND
13533 +#endif
13534 +
13535 + GET_THREAD_INFO(%r11)
13536 + orl $TS_COMPAT,TI_status(%r11)
13537 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13538 CFI_REMEMBER_STATE
13539 jnz cstar_tracesys
13540 cmpq $IA32_NR_syscalls-1,%rax
13541 @@ -319,12 +395,15 @@ cstar_do_call:
13542 cstar_dispatch:
13543 call *ia32_sys_call_table(,%rax,8)
13544 movq %rax,RAX-ARGOFFSET(%rsp)
13545 + GET_THREAD_INFO(%r11)
13546 DISABLE_INTERRUPTS(CLBR_NONE)
13547 TRACE_IRQS_OFF
13548 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13549 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13550 jnz sysretl_audit
13551 sysretl_from_sys_call:
13552 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 + pax_exit_kernel_user
13554 + pax_erase_kstack
13555 + andl $~TS_COMPAT,TI_status(%r11)
13556 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13557 movl RIP-ARGOFFSET(%rsp),%ecx
13558 CFI_REGISTER rip,rcx
13559 @@ -352,7 +431,7 @@ sysretl_audit:
13560
13561 cstar_tracesys:
13562 #ifdef CONFIG_AUDITSYSCALL
13563 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13565 jz cstar_auditsys
13566 #endif
13567 xchgl %r9d,%ebp
13568 @@ -366,11 +445,19 @@ cstar_tracesys:
13569 xchgl %ebp,%r9d
13570 cmpq $(IA32_NR_syscalls-1),%rax
13571 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13572 +
13573 + pax_erase_kstack
13574 +
13575 jmp cstar_do_call
13576 END(ia32_cstar_target)
13577
13578 ia32_badarg:
13579 ASM_CLAC
13580 +
13581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13582 + ASM_PAX_CLOSE_USERLAND
13583 +#endif
13584 +
13585 movq $-EFAULT,%rax
13586 jmp ia32_sysret
13587 CFI_ENDPROC
13588 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13589 CFI_REL_OFFSET rip,RIP-RIP
13590 PARAVIRT_ADJUST_EXCEPTION_FRAME
13591 SWAPGS
13592 - /*
13593 - * No need to follow this irqs on/off section: the syscall
13594 - * disabled irqs and here we enable it straight after entry:
13595 - */
13596 - ENABLE_INTERRUPTS(CLBR_NONE)
13597 movl %eax,%eax
13598 pushq_cfi %rax
13599 cld
13600 /* note the registers are not zero extended to the sf.
13601 this could be a problem. */
13602 SAVE_ARGS 0,1,0
13603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13605 + pax_enter_kernel_user
13606 +
13607 +#ifdef CONFIG_PAX_RANDKSTACK
13608 + pax_erase_kstack
13609 +#endif
13610 +
13611 + /*
13612 + * No need to follow this irqs on/off section: the syscall
13613 + * disabled irqs and here we enable it straight after entry:
13614 + */
13615 + ENABLE_INTERRUPTS(CLBR_NONE)
13616 + GET_THREAD_INFO(%r11)
13617 + orl $TS_COMPAT,TI_status(%r11)
13618 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13619 jnz ia32_tracesys
13620 cmpq $(IA32_NR_syscalls-1),%rax
13621 ja ia32_badsys
13622 @@ -442,6 +536,9 @@ ia32_tracesys:
13623 RESTORE_REST
13624 cmpq $(IA32_NR_syscalls-1),%rax
13625 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13626 +
13627 + pax_erase_kstack
13628 +
13629 jmp ia32_do_call
13630 END(ia32_syscall)
13631
13632 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13633 index 8e0ceec..af13504 100644
13634 --- a/arch/x86/ia32/sys_ia32.c
13635 +++ b/arch/x86/ia32/sys_ia32.c
13636 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13637 */
13638 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13639 {
13640 - typeof(ubuf->st_uid) uid = 0;
13641 - typeof(ubuf->st_gid) gid = 0;
13642 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13643 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13644 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13645 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13646 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13647 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13648 index 372231c..a5aa1a1 100644
13649 --- a/arch/x86/include/asm/alternative-asm.h
13650 +++ b/arch/x86/include/asm/alternative-asm.h
13651 @@ -18,6 +18,45 @@
13652 .endm
13653 #endif
13654
13655 +#ifdef KERNEXEC_PLUGIN
13656 + .macro pax_force_retaddr_bts rip=0
13657 + btsq $63,\rip(%rsp)
13658 + .endm
13659 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13660 + .macro pax_force_retaddr rip=0, reload=0
13661 + btsq $63,\rip(%rsp)
13662 + .endm
13663 + .macro pax_force_fptr ptr
13664 + btsq $63,\ptr
13665 + .endm
13666 + .macro pax_set_fptr_mask
13667 + .endm
13668 +#endif
13669 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13670 + .macro pax_force_retaddr rip=0, reload=0
13671 + .if \reload
13672 + pax_set_fptr_mask
13673 + .endif
13674 + orq %r10,\rip(%rsp)
13675 + .endm
13676 + .macro pax_force_fptr ptr
13677 + orq %r10,\ptr
13678 + .endm
13679 + .macro pax_set_fptr_mask
13680 + movabs $0x8000000000000000,%r10
13681 + .endm
13682 +#endif
13683 +#else
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + .endm
13686 + .macro pax_force_fptr ptr
13687 + .endm
13688 + .macro pax_force_retaddr_bts rip=0
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +
13694 .macro altinstruction_entry orig alt feature orig_len alt_len
13695 .long \orig - .
13696 .long \alt - .
13697 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13698 index 58ed6d9..f1cbe58 100644
13699 --- a/arch/x86/include/asm/alternative.h
13700 +++ b/arch/x86/include/asm/alternative.h
13701 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13702 ".pushsection .discard,\"aw\",@progbits\n" \
13703 DISCARD_ENTRY(1) \
13704 ".popsection\n" \
13705 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13706 + ".pushsection .altinstr_replacement, \"a\"\n" \
13707 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13708 ".popsection"
13709
13710 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13711 DISCARD_ENTRY(1) \
13712 DISCARD_ENTRY(2) \
13713 ".popsection\n" \
13714 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13715 + ".pushsection .altinstr_replacement, \"a\"\n" \
13716 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13717 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13718 ".popsection"
13719 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13720 index f8119b5..7209d5b 100644
13721 --- a/arch/x86/include/asm/apic.h
13722 +++ b/arch/x86/include/asm/apic.h
13723 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13724
13725 #ifdef CONFIG_X86_LOCAL_APIC
13726
13727 -extern unsigned int apic_verbosity;
13728 +extern int apic_verbosity;
13729 extern int local_apic_timer_c2_ok;
13730
13731 extern int disable_apic;
13732 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13733 index 20370c6..a2eb9b0 100644
13734 --- a/arch/x86/include/asm/apm.h
13735 +++ b/arch/x86/include/asm/apm.h
13736 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13737 __asm__ __volatile__(APM_DO_ZERO_SEGS
13738 "pushl %%edi\n\t"
13739 "pushl %%ebp\n\t"
13740 - "lcall *%%cs:apm_bios_entry\n\t"
13741 + "lcall *%%ss:apm_bios_entry\n\t"
13742 "setc %%al\n\t"
13743 "popl %%ebp\n\t"
13744 "popl %%edi\n\t"
13745 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13746 __asm__ __volatile__(APM_DO_ZERO_SEGS
13747 "pushl %%edi\n\t"
13748 "pushl %%ebp\n\t"
13749 - "lcall *%%cs:apm_bios_entry\n\t"
13750 + "lcall *%%ss:apm_bios_entry\n\t"
13751 "setc %%bl\n\t"
13752 "popl %%ebp\n\t"
13753 "popl %%edi\n\t"
13754 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13755 index 722aa3b..3a0bb27 100644
13756 --- a/arch/x86/include/asm/atomic.h
13757 +++ b/arch/x86/include/asm/atomic.h
13758 @@ -22,7 +22,18 @@
13759 */
13760 static inline int atomic_read(const atomic_t *v)
13761 {
13762 - return (*(volatile int *)&(v)->counter);
13763 + return (*(volatile const int *)&(v)->counter);
13764 +}
13765 +
13766 +/**
13767 + * atomic_read_unchecked - read atomic variable
13768 + * @v: pointer of type atomic_unchecked_t
13769 + *
13770 + * Atomically reads the value of @v.
13771 + */
13772 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13773 +{
13774 + return (*(volatile const int *)&(v)->counter);
13775 }
13776
13777 /**
13778 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13779 }
13780
13781 /**
13782 + * atomic_set_unchecked - set atomic variable
13783 + * @v: pointer of type atomic_unchecked_t
13784 + * @i: required value
13785 + *
13786 + * Atomically sets the value of @v to @i.
13787 + */
13788 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13789 +{
13790 + v->counter = i;
13791 +}
13792 +
13793 +/**
13794 * atomic_add - add integer to atomic variable
13795 * @i: integer value to add
13796 * @v: pointer of type atomic_t
13797 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13798 */
13799 static inline void atomic_add(int i, atomic_t *v)
13800 {
13801 - asm volatile(LOCK_PREFIX "addl %1,%0"
13802 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13803 +
13804 +#ifdef CONFIG_PAX_REFCOUNT
13805 + "jno 0f\n"
13806 + LOCK_PREFIX "subl %1,%0\n"
13807 + "int $4\n0:\n"
13808 + _ASM_EXTABLE(0b, 0b)
13809 +#endif
13810 +
13811 + : "+m" (v->counter)
13812 + : "ir" (i));
13813 +}
13814 +
13815 +/**
13816 + * atomic_add_unchecked - add integer to atomic variable
13817 + * @i: integer value to add
13818 + * @v: pointer of type atomic_unchecked_t
13819 + *
13820 + * Atomically adds @i to @v.
13821 + */
13822 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13823 +{
13824 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13825 : "+m" (v->counter)
13826 : "ir" (i));
13827 }
13828 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13829 */
13830 static inline void atomic_sub(int i, atomic_t *v)
13831 {
13832 - asm volatile(LOCK_PREFIX "subl %1,%0"
13833 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13834 +
13835 +#ifdef CONFIG_PAX_REFCOUNT
13836 + "jno 0f\n"
13837 + LOCK_PREFIX "addl %1,%0\n"
13838 + "int $4\n0:\n"
13839 + _ASM_EXTABLE(0b, 0b)
13840 +#endif
13841 +
13842 + : "+m" (v->counter)
13843 + : "ir" (i));
13844 +}
13845 +
13846 +/**
13847 + * atomic_sub_unchecked - subtract integer from atomic variable
13848 + * @i: integer value to subtract
13849 + * @v: pointer of type atomic_unchecked_t
13850 + *
13851 + * Atomically subtracts @i from @v.
13852 + */
13853 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13854 +{
13855 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13856 : "+m" (v->counter)
13857 : "ir" (i));
13858 }
13859 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13860 {
13861 unsigned char c;
13862
13863 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13864 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13865 +
13866 +#ifdef CONFIG_PAX_REFCOUNT
13867 + "jno 0f\n"
13868 + LOCK_PREFIX "addl %2,%0\n"
13869 + "int $4\n0:\n"
13870 + _ASM_EXTABLE(0b, 0b)
13871 +#endif
13872 +
13873 + "sete %1\n"
13874 : "+m" (v->counter), "=qm" (c)
13875 : "ir" (i) : "memory");
13876 return c;
13877 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13878 */
13879 static inline void atomic_inc(atomic_t *v)
13880 {
13881 - asm volatile(LOCK_PREFIX "incl %0"
13882 + asm volatile(LOCK_PREFIX "incl %0\n"
13883 +
13884 +#ifdef CONFIG_PAX_REFCOUNT
13885 + "jno 0f\n"
13886 + LOCK_PREFIX "decl %0\n"
13887 + "int $4\n0:\n"
13888 + _ASM_EXTABLE(0b, 0b)
13889 +#endif
13890 +
13891 + : "+m" (v->counter));
13892 +}
13893 +
13894 +/**
13895 + * atomic_inc_unchecked - increment atomic variable
13896 + * @v: pointer of type atomic_unchecked_t
13897 + *
13898 + * Atomically increments @v by 1.
13899 + */
13900 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13901 +{
13902 + asm volatile(LOCK_PREFIX "incl %0\n"
13903 : "+m" (v->counter));
13904 }
13905
13906 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13907 */
13908 static inline void atomic_dec(atomic_t *v)
13909 {
13910 - asm volatile(LOCK_PREFIX "decl %0"
13911 + asm volatile(LOCK_PREFIX "decl %0\n"
13912 +
13913 +#ifdef CONFIG_PAX_REFCOUNT
13914 + "jno 0f\n"
13915 + LOCK_PREFIX "incl %0\n"
13916 + "int $4\n0:\n"
13917 + _ASM_EXTABLE(0b, 0b)
13918 +#endif
13919 +
13920 + : "+m" (v->counter));
13921 +}
13922 +
13923 +/**
13924 + * atomic_dec_unchecked - decrement atomic variable
13925 + * @v: pointer of type atomic_unchecked_t
13926 + *
13927 + * Atomically decrements @v by 1.
13928 + */
13929 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13930 +{
13931 + asm volatile(LOCK_PREFIX "decl %0\n"
13932 : "+m" (v->counter));
13933 }
13934
13935 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13936 {
13937 unsigned char c;
13938
13939 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13940 + asm volatile(LOCK_PREFIX "decl %0\n"
13941 +
13942 +#ifdef CONFIG_PAX_REFCOUNT
13943 + "jno 0f\n"
13944 + LOCK_PREFIX "incl %0\n"
13945 + "int $4\n0:\n"
13946 + _ASM_EXTABLE(0b, 0b)
13947 +#endif
13948 +
13949 + "sete %1\n"
13950 : "+m" (v->counter), "=qm" (c)
13951 : : "memory");
13952 return c != 0;
13953 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13954 {
13955 unsigned char c;
13956
13957 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13958 + asm volatile(LOCK_PREFIX "incl %0\n"
13959 +
13960 +#ifdef CONFIG_PAX_REFCOUNT
13961 + "jno 0f\n"
13962 + LOCK_PREFIX "decl %0\n"
13963 + "int $4\n0:\n"
13964 + _ASM_EXTABLE(0b, 0b)
13965 +#endif
13966 +
13967 + "sete %1\n"
13968 + : "+m" (v->counter), "=qm" (c)
13969 + : : "memory");
13970 + return c != 0;
13971 +}
13972 +
13973 +/**
13974 + * atomic_inc_and_test_unchecked - increment and test
13975 + * @v: pointer of type atomic_unchecked_t
13976 + *
13977 + * Atomically increments @v by 1
13978 + * and returns true if the result is zero, or false for all
13979 + * other cases.
13980 + */
13981 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13982 +{
13983 + unsigned char c;
13984 +
13985 + asm volatile(LOCK_PREFIX "incl %0\n"
13986 + "sete %1\n"
13987 : "+m" (v->counter), "=qm" (c)
13988 : : "memory");
13989 return c != 0;
13990 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13991 {
13992 unsigned char c;
13993
13994 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13995 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13996 +
13997 +#ifdef CONFIG_PAX_REFCOUNT
13998 + "jno 0f\n"
13999 + LOCK_PREFIX "subl %2,%0\n"
14000 + "int $4\n0:\n"
14001 + _ASM_EXTABLE(0b, 0b)
14002 +#endif
14003 +
14004 + "sets %1\n"
14005 : "+m" (v->counter), "=qm" (c)
14006 : "ir" (i) : "memory");
14007 return c;
14008 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14009 */
14010 static inline int atomic_add_return(int i, atomic_t *v)
14011 {
14012 + return i + xadd_check_overflow(&v->counter, i);
14013 +}
14014 +
14015 +/**
14016 + * atomic_add_return_unchecked - add integer and return
14017 + * @i: integer value to add
14018 + * @v: pointer of type atomic_unchecked_t
14019 + *
14020 + * Atomically adds @i to @v and returns @i + @v
14021 + */
14022 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14023 +{
14024 return i + xadd(&v->counter, i);
14025 }
14026
14027 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14028 }
14029
14030 #define atomic_inc_return(v) (atomic_add_return(1, v))
14031 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14032 +{
14033 + return atomic_add_return_unchecked(1, v);
14034 +}
14035 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14036
14037 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14038 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14039 return cmpxchg(&v->counter, old, new);
14040 }
14041
14042 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14043 +{
14044 + return cmpxchg(&v->counter, old, new);
14045 +}
14046 +
14047 static inline int atomic_xchg(atomic_t *v, int new)
14048 {
14049 return xchg(&v->counter, new);
14050 }
14051
14052 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14053 +{
14054 + return xchg(&v->counter, new);
14055 +}
14056 +
14057 /**
14058 * __atomic_add_unless - add unless the number is already a given value
14059 * @v: pointer of type atomic_t
14060 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14061 */
14062 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14063 {
14064 - int c, old;
14065 + int c, old, new;
14066 c = atomic_read(v);
14067 for (;;) {
14068 - if (unlikely(c == (u)))
14069 + if (unlikely(c == u))
14070 break;
14071 - old = atomic_cmpxchg((v), c, c + (a));
14072 +
14073 + asm volatile("addl %2,%0\n"
14074 +
14075 +#ifdef CONFIG_PAX_REFCOUNT
14076 + "jno 0f\n"
14077 + "subl %2,%0\n"
14078 + "int $4\n0:\n"
14079 + _ASM_EXTABLE(0b, 0b)
14080 +#endif
14081 +
14082 + : "=r" (new)
14083 + : "0" (c), "ir" (a));
14084 +
14085 + old = atomic_cmpxchg(v, c, new);
14086 if (likely(old == c))
14087 break;
14088 c = old;
14089 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14090 }
14091
14092 /**
14093 + * atomic_inc_not_zero_hint - increment if not null
14094 + * @v: pointer of type atomic_t
14095 + * @hint: probable value of the atomic before the increment
14096 + *
14097 + * This version of atomic_inc_not_zero() gives a hint of probable
14098 + * value of the atomic. This helps processor to not read the memory
14099 + * before doing the atomic read/modify/write cycle, lowering
14100 + * number of bus transactions on some arches.
14101 + *
14102 + * Returns: 0 if increment was not done, 1 otherwise.
14103 + */
14104 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14105 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14106 +{
14107 + int val, c = hint, new;
14108 +
14109 + /* sanity test, should be removed by compiler if hint is a constant */
14110 + if (!hint)
14111 + return __atomic_add_unless(v, 1, 0);
14112 +
14113 + do {
14114 + asm volatile("incl %0\n"
14115 +
14116 +#ifdef CONFIG_PAX_REFCOUNT
14117 + "jno 0f\n"
14118 + "decl %0\n"
14119 + "int $4\n0:\n"
14120 + _ASM_EXTABLE(0b, 0b)
14121 +#endif
14122 +
14123 + : "=r" (new)
14124 + : "0" (c));
14125 +
14126 + val = atomic_cmpxchg(v, c, new);
14127 + if (val == c)
14128 + return 1;
14129 + c = val;
14130 + } while (c);
14131 +
14132 + return 0;
14133 +}
14134 +
14135 +/**
14136 * atomic_inc_short - increment of a short integer
14137 * @v: pointer to type int
14138 *
14139 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14140 #endif
14141
14142 /* These are x86-specific, used by some header files */
14143 -#define atomic_clear_mask(mask, addr) \
14144 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14145 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14146 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14147 +{
14148 + asm volatile(LOCK_PREFIX "andl %1,%0"
14149 + : "+m" (v->counter)
14150 + : "r" (~(mask))
14151 + : "memory");
14152 +}
14153
14154 -#define atomic_set_mask(mask, addr) \
14155 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14156 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14157 - : "memory")
14158 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14159 +{
14160 + asm volatile(LOCK_PREFIX "andl %1,%0"
14161 + : "+m" (v->counter)
14162 + : "r" (~(mask))
14163 + : "memory");
14164 +}
14165 +
14166 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14167 +{
14168 + asm volatile(LOCK_PREFIX "orl %1,%0"
14169 + : "+m" (v->counter)
14170 + : "r" (mask)
14171 + : "memory");
14172 +}
14173 +
14174 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14175 +{
14176 + asm volatile(LOCK_PREFIX "orl %1,%0"
14177 + : "+m" (v->counter)
14178 + : "r" (mask)
14179 + : "memory");
14180 +}
14181
14182 /* Atomic operations are already serializing on x86 */
14183 #define smp_mb__before_atomic_dec() barrier()
14184 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14185 index b154de7..aadebd8 100644
14186 --- a/arch/x86/include/asm/atomic64_32.h
14187 +++ b/arch/x86/include/asm/atomic64_32.h
14188 @@ -12,6 +12,14 @@ typedef struct {
14189 u64 __aligned(8) counter;
14190 } atomic64_t;
14191
14192 +#ifdef CONFIG_PAX_REFCOUNT
14193 +typedef struct {
14194 + u64 __aligned(8) counter;
14195 +} atomic64_unchecked_t;
14196 +#else
14197 +typedef atomic64_t atomic64_unchecked_t;
14198 +#endif
14199 +
14200 #define ATOMIC64_INIT(val) { (val) }
14201
14202 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14203 @@ -37,21 +45,31 @@ typedef struct {
14204 ATOMIC64_DECL_ONE(sym##_386)
14205
14206 ATOMIC64_DECL_ONE(add_386);
14207 +ATOMIC64_DECL_ONE(add_unchecked_386);
14208 ATOMIC64_DECL_ONE(sub_386);
14209 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14210 ATOMIC64_DECL_ONE(inc_386);
14211 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14212 ATOMIC64_DECL_ONE(dec_386);
14213 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14214 #endif
14215
14216 #define alternative_atomic64(f, out, in...) \
14217 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14218
14219 ATOMIC64_DECL(read);
14220 +ATOMIC64_DECL(read_unchecked);
14221 ATOMIC64_DECL(set);
14222 +ATOMIC64_DECL(set_unchecked);
14223 ATOMIC64_DECL(xchg);
14224 ATOMIC64_DECL(add_return);
14225 +ATOMIC64_DECL(add_return_unchecked);
14226 ATOMIC64_DECL(sub_return);
14227 +ATOMIC64_DECL(sub_return_unchecked);
14228 ATOMIC64_DECL(inc_return);
14229 +ATOMIC64_DECL(inc_return_unchecked);
14230 ATOMIC64_DECL(dec_return);
14231 +ATOMIC64_DECL(dec_return_unchecked);
14232 ATOMIC64_DECL(dec_if_positive);
14233 ATOMIC64_DECL(inc_not_zero);
14234 ATOMIC64_DECL(add_unless);
14235 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14236 }
14237
14238 /**
14239 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14240 + * @p: pointer to type atomic64_unchecked_t
14241 + * @o: expected value
14242 + * @n: new value
14243 + *
14244 + * Atomically sets @v to @n if it was equal to @o and returns
14245 + * the old value.
14246 + */
14247 +
14248 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14249 +{
14250 + return cmpxchg64(&v->counter, o, n);
14251 +}
14252 +
14253 +/**
14254 * atomic64_xchg - xchg atomic64 variable
14255 * @v: pointer to type atomic64_t
14256 * @n: value to assign
14257 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14258 }
14259
14260 /**
14261 + * atomic64_set_unchecked - set atomic64 variable
14262 + * @v: pointer to type atomic64_unchecked_t
14263 + * @n: value to assign
14264 + *
14265 + * Atomically sets the value of @v to @n.
14266 + */
14267 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14268 +{
14269 + unsigned high = (unsigned)(i >> 32);
14270 + unsigned low = (unsigned)i;
14271 + alternative_atomic64(set, /* no output */,
14272 + "S" (v), "b" (low), "c" (high)
14273 + : "eax", "edx", "memory");
14274 +}
14275 +
14276 +/**
14277 * atomic64_read - read atomic64 variable
14278 * @v: pointer to type atomic64_t
14279 *
14280 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14281 }
14282
14283 /**
14284 + * atomic64_read_unchecked - read atomic64 variable
14285 + * @v: pointer to type atomic64_unchecked_t
14286 + *
14287 + * Atomically reads the value of @v and returns it.
14288 + */
14289 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14290 +{
14291 + long long r;
14292 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14293 + return r;
14294 + }
14295 +
14296 +/**
14297 * atomic64_add_return - add and return
14298 * @i: integer value to add
14299 * @v: pointer to type atomic64_t
14300 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14301 return i;
14302 }
14303
14304 +/**
14305 + * atomic64_add_return_unchecked - add and return
14306 + * @i: integer value to add
14307 + * @v: pointer to type atomic64_unchecked_t
14308 + *
14309 + * Atomically adds @i to @v and returns @i + *@v
14310 + */
14311 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14312 +{
14313 + alternative_atomic64(add_return_unchecked,
14314 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14315 + ASM_NO_INPUT_CLOBBER("memory"));
14316 + return i;
14317 +}
14318 +
14319 /*
14320 * Other variants with different arithmetic operators:
14321 */
14322 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14323 return a;
14324 }
14325
14326 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14327 +{
14328 + long long a;
14329 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14330 + "S" (v) : "memory", "ecx");
14331 + return a;
14332 +}
14333 +
14334 static inline long long atomic64_dec_return(atomic64_t *v)
14335 {
14336 long long a;
14337 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14338 }
14339
14340 /**
14341 + * atomic64_add_unchecked - add integer to atomic64 variable
14342 + * @i: integer value to add
14343 + * @v: pointer to type atomic64_unchecked_t
14344 + *
14345 + * Atomically adds @i to @v.
14346 + */
14347 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14348 +{
14349 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14350 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14351 + ASM_NO_INPUT_CLOBBER("memory"));
14352 + return i;
14353 +}
14354 +
14355 +/**
14356 * atomic64_sub - subtract the atomic64 variable
14357 * @i: integer value to subtract
14358 * @v: pointer to type atomic64_t
14359 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14360 index 0e1cbfc..5623683 100644
14361 --- a/arch/x86/include/asm/atomic64_64.h
14362 +++ b/arch/x86/include/asm/atomic64_64.h
14363 @@ -18,7 +18,19 @@
14364 */
14365 static inline long atomic64_read(const atomic64_t *v)
14366 {
14367 - return (*(volatile long *)&(v)->counter);
14368 + return (*(volatile const long *)&(v)->counter);
14369 +}
14370 +
14371 +/**
14372 + * atomic64_read_unchecked - read atomic64 variable
14373 + * @v: pointer of type atomic64_unchecked_t
14374 + *
14375 + * Atomically reads the value of @v.
14376 + * Doesn't imply a read memory barrier.
14377 + */
14378 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14379 +{
14380 + return (*(volatile const long *)&(v)->counter);
14381 }
14382
14383 /**
14384 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14385 }
14386
14387 /**
14388 + * atomic64_set_unchecked - set atomic64 variable
14389 + * @v: pointer to type atomic64_unchecked_t
14390 + * @i: required value
14391 + *
14392 + * Atomically sets the value of @v to @i.
14393 + */
14394 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14395 +{
14396 + v->counter = i;
14397 +}
14398 +
14399 +/**
14400 * atomic64_add - add integer to atomic64 variable
14401 * @i: integer value to add
14402 * @v: pointer to type atomic64_t
14403 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14404 */
14405 static inline void atomic64_add(long i, atomic64_t *v)
14406 {
14407 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14408 +
14409 +#ifdef CONFIG_PAX_REFCOUNT
14410 + "jno 0f\n"
14411 + LOCK_PREFIX "subq %1,%0\n"
14412 + "int $4\n0:\n"
14413 + _ASM_EXTABLE(0b, 0b)
14414 +#endif
14415 +
14416 + : "=m" (v->counter)
14417 + : "er" (i), "m" (v->counter));
14418 +}
14419 +
14420 +/**
14421 + * atomic64_add_unchecked - add integer to atomic64 variable
14422 + * @i: integer value to add
14423 + * @v: pointer to type atomic64_unchecked_t
14424 + *
14425 + * Atomically adds @i to @v.
14426 + */
14427 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14428 +{
14429 asm volatile(LOCK_PREFIX "addq %1,%0"
14430 : "=m" (v->counter)
14431 : "er" (i), "m" (v->counter));
14432 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14433 */
14434 static inline void atomic64_sub(long i, atomic64_t *v)
14435 {
14436 - asm volatile(LOCK_PREFIX "subq %1,%0"
14437 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14438 +
14439 +#ifdef CONFIG_PAX_REFCOUNT
14440 + "jno 0f\n"
14441 + LOCK_PREFIX "addq %1,%0\n"
14442 + "int $4\n0:\n"
14443 + _ASM_EXTABLE(0b, 0b)
14444 +#endif
14445 +
14446 + : "=m" (v->counter)
14447 + : "er" (i), "m" (v->counter));
14448 +}
14449 +
14450 +/**
14451 + * atomic64_sub_unchecked - subtract the atomic64 variable
14452 + * @i: integer value to subtract
14453 + * @v: pointer to type atomic64_unchecked_t
14454 + *
14455 + * Atomically subtracts @i from @v.
14456 + */
14457 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14458 +{
14459 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14460 : "=m" (v->counter)
14461 : "er" (i), "m" (v->counter));
14462 }
14463 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14464 {
14465 unsigned char c;
14466
14467 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14468 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14469 +
14470 +#ifdef CONFIG_PAX_REFCOUNT
14471 + "jno 0f\n"
14472 + LOCK_PREFIX "addq %2,%0\n"
14473 + "int $4\n0:\n"
14474 + _ASM_EXTABLE(0b, 0b)
14475 +#endif
14476 +
14477 + "sete %1\n"
14478 : "=m" (v->counter), "=qm" (c)
14479 : "er" (i), "m" (v->counter) : "memory");
14480 return c;
14481 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14482 */
14483 static inline void atomic64_inc(atomic64_t *v)
14484 {
14485 + asm volatile(LOCK_PREFIX "incq %0\n"
14486 +
14487 +#ifdef CONFIG_PAX_REFCOUNT
14488 + "jno 0f\n"
14489 + LOCK_PREFIX "decq %0\n"
14490 + "int $4\n0:\n"
14491 + _ASM_EXTABLE(0b, 0b)
14492 +#endif
14493 +
14494 + : "=m" (v->counter)
14495 + : "m" (v->counter));
14496 +}
14497 +
14498 +/**
14499 + * atomic64_inc_unchecked - increment atomic64 variable
14500 + * @v: pointer to type atomic64_unchecked_t
14501 + *
14502 + * Atomically increments @v by 1.
14503 + */
14504 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14505 +{
14506 asm volatile(LOCK_PREFIX "incq %0"
14507 : "=m" (v->counter)
14508 : "m" (v->counter));
14509 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14510 */
14511 static inline void atomic64_dec(atomic64_t *v)
14512 {
14513 - asm volatile(LOCK_PREFIX "decq %0"
14514 + asm volatile(LOCK_PREFIX "decq %0\n"
14515 +
14516 +#ifdef CONFIG_PAX_REFCOUNT
14517 + "jno 0f\n"
14518 + LOCK_PREFIX "incq %0\n"
14519 + "int $4\n0:\n"
14520 + _ASM_EXTABLE(0b, 0b)
14521 +#endif
14522 +
14523 + : "=m" (v->counter)
14524 + : "m" (v->counter));
14525 +}
14526 +
14527 +/**
14528 + * atomic64_dec_unchecked - decrement atomic64 variable
14529 + * @v: pointer to type atomic64_t
14530 + *
14531 + * Atomically decrements @v by 1.
14532 + */
14533 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14534 +{
14535 + asm volatile(LOCK_PREFIX "decq %0\n"
14536 : "=m" (v->counter)
14537 : "m" (v->counter));
14538 }
14539 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14540 {
14541 unsigned char c;
14542
14543 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14544 + asm volatile(LOCK_PREFIX "decq %0\n"
14545 +
14546 +#ifdef CONFIG_PAX_REFCOUNT
14547 + "jno 0f\n"
14548 + LOCK_PREFIX "incq %0\n"
14549 + "int $4\n0:\n"
14550 + _ASM_EXTABLE(0b, 0b)
14551 +#endif
14552 +
14553 + "sete %1\n"
14554 : "=m" (v->counter), "=qm" (c)
14555 : "m" (v->counter) : "memory");
14556 return c != 0;
14557 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14558 {
14559 unsigned char c;
14560
14561 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14562 + asm volatile(LOCK_PREFIX "incq %0\n"
14563 +
14564 +#ifdef CONFIG_PAX_REFCOUNT
14565 + "jno 0f\n"
14566 + LOCK_PREFIX "decq %0\n"
14567 + "int $4\n0:\n"
14568 + _ASM_EXTABLE(0b, 0b)
14569 +#endif
14570 +
14571 + "sete %1\n"
14572 : "=m" (v->counter), "=qm" (c)
14573 : "m" (v->counter) : "memory");
14574 return c != 0;
14575 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14576 {
14577 unsigned char c;
14578
14579 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14580 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14581 +
14582 +#ifdef CONFIG_PAX_REFCOUNT
14583 + "jno 0f\n"
14584 + LOCK_PREFIX "subq %2,%0\n"
14585 + "int $4\n0:\n"
14586 + _ASM_EXTABLE(0b, 0b)
14587 +#endif
14588 +
14589 + "sets %1\n"
14590 : "=m" (v->counter), "=qm" (c)
14591 : "er" (i), "m" (v->counter) : "memory");
14592 return c;
14593 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14594 */
14595 static inline long atomic64_add_return(long i, atomic64_t *v)
14596 {
14597 + return i + xadd_check_overflow(&v->counter, i);
14598 +}
14599 +
14600 +/**
14601 + * atomic64_add_return_unchecked - add and return
14602 + * @i: integer value to add
14603 + * @v: pointer to type atomic64_unchecked_t
14604 + *
14605 + * Atomically adds @i to @v and returns @i + @v
14606 + */
14607 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14608 +{
14609 return i + xadd(&v->counter, i);
14610 }
14611
14612 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14613 }
14614
14615 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14616 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14617 +{
14618 + return atomic64_add_return_unchecked(1, v);
14619 +}
14620 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14621
14622 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14623 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14624 return cmpxchg(&v->counter, old, new);
14625 }
14626
14627 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14628 +{
14629 + return cmpxchg(&v->counter, old, new);
14630 +}
14631 +
14632 static inline long atomic64_xchg(atomic64_t *v, long new)
14633 {
14634 return xchg(&v->counter, new);
14635 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14636 */
14637 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14638 {
14639 - long c, old;
14640 + long c, old, new;
14641 c = atomic64_read(v);
14642 for (;;) {
14643 - if (unlikely(c == (u)))
14644 + if (unlikely(c == u))
14645 break;
14646 - old = atomic64_cmpxchg((v), c, c + (a));
14647 +
14648 + asm volatile("add %2,%0\n"
14649 +
14650 +#ifdef CONFIG_PAX_REFCOUNT
14651 + "jno 0f\n"
14652 + "sub %2,%0\n"
14653 + "int $4\n0:\n"
14654 + _ASM_EXTABLE(0b, 0b)
14655 +#endif
14656 +
14657 + : "=r" (new)
14658 + : "0" (c), "ir" (a));
14659 +
14660 + old = atomic64_cmpxchg(v, c, new);
14661 if (likely(old == c))
14662 break;
14663 c = old;
14664 }
14665 - return c != (u);
14666 + return c != u;
14667 }
14668
14669 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14670 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14671 index 6dfd019..28e188d 100644
14672 --- a/arch/x86/include/asm/bitops.h
14673 +++ b/arch/x86/include/asm/bitops.h
14674 @@ -40,7 +40,7 @@
14675 * a mask operation on a byte.
14676 */
14677 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14678 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14679 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14680 #define CONST_MASK(nr) (1 << ((nr) & 7))
14681
14682 /**
14683 @@ -486,7 +486,7 @@ static inline int fls(int x)
14684 * at position 64.
14685 */
14686 #ifdef CONFIG_X86_64
14687 -static __always_inline int fls64(__u64 x)
14688 +static __always_inline long fls64(__u64 x)
14689 {
14690 int bitpos = -1;
14691 /*
14692 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14693 index 4fa687a..60f2d39 100644
14694 --- a/arch/x86/include/asm/boot.h
14695 +++ b/arch/x86/include/asm/boot.h
14696 @@ -6,10 +6,15 @@
14697 #include <uapi/asm/boot.h>
14698
14699 /* Physical address where kernel should be loaded. */
14700 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14701 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14702 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14703 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14704
14705 +#ifndef __ASSEMBLY__
14706 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14707 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14708 +#endif
14709 +
14710 /* Minimum kernel alignment, as a power of two */
14711 #ifdef CONFIG_X86_64
14712 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14713 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14714 index 48f99f1..d78ebf9 100644
14715 --- a/arch/x86/include/asm/cache.h
14716 +++ b/arch/x86/include/asm/cache.h
14717 @@ -5,12 +5,13 @@
14718
14719 /* L1 cache line size */
14720 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14721 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14723
14724 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14725 +#define __read_only __attribute__((__section__(".data..read_only")))
14726
14727 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14728 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14729 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14730
14731 #ifdef CONFIG_X86_VSMP
14732 #ifdef CONFIG_SMP
14733 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14734 index 9863ee3..4a1f8e1 100644
14735 --- a/arch/x86/include/asm/cacheflush.h
14736 +++ b/arch/x86/include/asm/cacheflush.h
14737 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14738 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14739
14740 if (pg_flags == _PGMT_DEFAULT)
14741 - return -1;
14742 + return ~0UL;
14743 else if (pg_flags == _PGMT_WC)
14744 return _PAGE_CACHE_WC;
14745 else if (pg_flags == _PGMT_UC_MINUS)
14746 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14747 index f50de69..2b0a458 100644
14748 --- a/arch/x86/include/asm/checksum_32.h
14749 +++ b/arch/x86/include/asm/checksum_32.h
14750 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14751 int len, __wsum sum,
14752 int *src_err_ptr, int *dst_err_ptr);
14753
14754 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14755 + int len, __wsum sum,
14756 + int *src_err_ptr, int *dst_err_ptr);
14757 +
14758 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14759 + int len, __wsum sum,
14760 + int *src_err_ptr, int *dst_err_ptr);
14761 +
14762 /*
14763 * Note: when you get a NULL pointer exception here this means someone
14764 * passed in an incorrect kernel address to one of these functions.
14765 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14766
14767 might_sleep();
14768 stac();
14769 - ret = csum_partial_copy_generic((__force void *)src, dst,
14770 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14771 len, sum, err_ptr, NULL);
14772 clac();
14773
14774 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14775 might_sleep();
14776 if (access_ok(VERIFY_WRITE, dst, len)) {
14777 stac();
14778 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14779 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14780 len, sum, NULL, err_ptr);
14781 clac();
14782 return ret;
14783 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14784 index d47786a..ce1b05d 100644
14785 --- a/arch/x86/include/asm/cmpxchg.h
14786 +++ b/arch/x86/include/asm/cmpxchg.h
14787 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14788 __compiletime_error("Bad argument size for cmpxchg");
14789 extern void __xadd_wrong_size(void)
14790 __compiletime_error("Bad argument size for xadd");
14791 +extern void __xadd_check_overflow_wrong_size(void)
14792 + __compiletime_error("Bad argument size for xadd_check_overflow");
14793 extern void __add_wrong_size(void)
14794 __compiletime_error("Bad argument size for add");
14795 +extern void __add_check_overflow_wrong_size(void)
14796 + __compiletime_error("Bad argument size for add_check_overflow");
14797
14798 /*
14799 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14800 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14801 __ret; \
14802 })
14803
14804 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14805 + ({ \
14806 + __typeof__ (*(ptr)) __ret = (arg); \
14807 + switch (sizeof(*(ptr))) { \
14808 + case __X86_CASE_L: \
14809 + asm volatile (lock #op "l %0, %1\n" \
14810 + "jno 0f\n" \
14811 + "mov %0,%1\n" \
14812 + "int $4\n0:\n" \
14813 + _ASM_EXTABLE(0b, 0b) \
14814 + : "+r" (__ret), "+m" (*(ptr)) \
14815 + : : "memory", "cc"); \
14816 + break; \
14817 + case __X86_CASE_Q: \
14818 + asm volatile (lock #op "q %q0, %1\n" \
14819 + "jno 0f\n" \
14820 + "mov %0,%1\n" \
14821 + "int $4\n0:\n" \
14822 + _ASM_EXTABLE(0b, 0b) \
14823 + : "+r" (__ret), "+m" (*(ptr)) \
14824 + : : "memory", "cc"); \
14825 + break; \
14826 + default: \
14827 + __ ## op ## _check_overflow_wrong_size(); \
14828 + } \
14829 + __ret; \
14830 + })
14831 +
14832 /*
14833 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14834 * Since this is generally used to protect other memory information, we
14835 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14836 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14837 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14838
14839 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14840 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14841 +
14842 #define __add(ptr, inc, lock) \
14843 ({ \
14844 __typeof__ (*(ptr)) __ret = (inc); \
14845 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14846 index 59c6c40..5e0b22c 100644
14847 --- a/arch/x86/include/asm/compat.h
14848 +++ b/arch/x86/include/asm/compat.h
14849 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14850 typedef u32 compat_uint_t;
14851 typedef u32 compat_ulong_t;
14852 typedef u64 __attribute__((aligned(4))) compat_u64;
14853 -typedef u32 compat_uptr_t;
14854 +typedef u32 __user compat_uptr_t;
14855
14856 struct compat_timespec {
14857 compat_time_t tv_sec;
14858 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14859 index 47538a6..44902d1 100644
14860 --- a/arch/x86/include/asm/cpufeature.h
14861 +++ b/arch/x86/include/asm/cpufeature.h
14862 @@ -203,7 +203,7 @@
14863 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14864 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14865 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14866 -
14867 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14868
14869 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14870 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14871 @@ -211,7 +211,7 @@
14872 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14873 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14874 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14875 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14876 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14877 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14878 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14879 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14880 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14881 #undef cpu_has_centaur_mcr
14882 #define cpu_has_centaur_mcr 0
14883
14884 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14885 #endif /* CONFIG_X86_64 */
14886
14887 #if __GNUC__ >= 4
14888 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14889
14890 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14891 t_warn:
14892 - warn_pre_alternatives();
14893 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14894 + warn_pre_alternatives();
14895 return false;
14896 #endif
14897 #else /* GCC_VERSION >= 40500 */
14898 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14899 ".section .discard,\"aw\",@progbits\n"
14900 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14901 ".previous\n"
14902 - ".section .altinstr_replacement,\"ax\"\n"
14903 + ".section .altinstr_replacement,\"a\"\n"
14904 "3: movb $1,%0\n"
14905 "4:\n"
14906 ".previous\n"
14907 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14908 " .byte 2b - 1b\n" /* src len */
14909 " .byte 4f - 3f\n" /* repl len */
14910 ".previous\n"
14911 - ".section .altinstr_replacement,\"ax\"\n"
14912 + ".section .altinstr_replacement,\"a\"\n"
14913 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14914 "4:\n"
14915 ".previous\n"
14916 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14917 ".section .discard,\"aw\",@progbits\n"
14918 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14919 ".previous\n"
14920 - ".section .altinstr_replacement,\"ax\"\n"
14921 + ".section .altinstr_replacement,\"a\"\n"
14922 "3: movb $0,%0\n"
14923 "4:\n"
14924 ".previous\n"
14925 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14926 ".section .discard,\"aw\",@progbits\n"
14927 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14928 ".previous\n"
14929 - ".section .altinstr_replacement,\"ax\"\n"
14930 + ".section .altinstr_replacement,\"a\"\n"
14931 "5: movb $1,%0\n"
14932 "6:\n"
14933 ".previous\n"
14934 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14935 index b90e5df..b462c91 100644
14936 --- a/arch/x86/include/asm/desc.h
14937 +++ b/arch/x86/include/asm/desc.h
14938 @@ -4,6 +4,7 @@
14939 #include <asm/desc_defs.h>
14940 #include <asm/ldt.h>
14941 #include <asm/mmu.h>
14942 +#include <asm/pgtable.h>
14943
14944 #include <linux/smp.h>
14945 #include <linux/percpu.h>
14946 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14947
14948 desc->type = (info->read_exec_only ^ 1) << 1;
14949 desc->type |= info->contents << 2;
14950 + desc->type |= info->seg_not_present ^ 1;
14951
14952 desc->s = 1;
14953 desc->dpl = 0x3;
14954 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14955 }
14956
14957 extern struct desc_ptr idt_descr;
14958 -extern gate_desc idt_table[];
14959 -extern struct desc_ptr debug_idt_descr;
14960 -extern gate_desc debug_idt_table[];
14961 -
14962 -struct gdt_page {
14963 - struct desc_struct gdt[GDT_ENTRIES];
14964 -} __attribute__((aligned(PAGE_SIZE)));
14965 -
14966 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14967 +extern gate_desc idt_table[IDT_ENTRIES];
14968 +extern const struct desc_ptr debug_idt_descr;
14969 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14970
14971 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14972 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14973 {
14974 - return per_cpu(gdt_page, cpu).gdt;
14975 + return cpu_gdt_table[cpu];
14976 }
14977
14978 #ifdef CONFIG_X86_64
14979 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14980 unsigned long base, unsigned dpl, unsigned flags,
14981 unsigned short seg)
14982 {
14983 - gate->a = (seg << 16) | (base & 0xffff);
14984 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14985 + gate->gate.offset_low = base;
14986 + gate->gate.seg = seg;
14987 + gate->gate.reserved = 0;
14988 + gate->gate.type = type;
14989 + gate->gate.s = 0;
14990 + gate->gate.dpl = dpl;
14991 + gate->gate.p = 1;
14992 + gate->gate.offset_high = base >> 16;
14993 }
14994
14995 #endif
14996 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14997
14998 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14999 {
15000 + pax_open_kernel();
15001 memcpy(&idt[entry], gate, sizeof(*gate));
15002 + pax_close_kernel();
15003 }
15004
15005 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15006 {
15007 + pax_open_kernel();
15008 memcpy(&ldt[entry], desc, 8);
15009 + pax_close_kernel();
15010 }
15011
15012 static inline void
15013 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15014 default: size = sizeof(*gdt); break;
15015 }
15016
15017 + pax_open_kernel();
15018 memcpy(&gdt[entry], desc, size);
15019 + pax_close_kernel();
15020 }
15021
15022 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15023 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15024
15025 static inline void native_load_tr_desc(void)
15026 {
15027 + pax_open_kernel();
15028 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15029 + pax_close_kernel();
15030 }
15031
15032 static inline void native_load_gdt(const struct desc_ptr *dtr)
15033 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15034 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15035 unsigned int i;
15036
15037 + pax_open_kernel();
15038 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15039 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15040 + pax_close_kernel();
15041 }
15042
15043 #define _LDT_empty(info) \
15044 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15045 preempt_enable();
15046 }
15047
15048 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15049 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15050 {
15051 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15052 }
15053 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15054 }
15055
15056 #ifdef CONFIG_X86_64
15057 -static inline void set_nmi_gate(int gate, void *addr)
15058 +static inline void set_nmi_gate(int gate, const void *addr)
15059 {
15060 gate_desc s;
15061
15062 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15063 #endif
15064
15065 #ifdef CONFIG_TRACING
15066 -extern struct desc_ptr trace_idt_descr;
15067 -extern gate_desc trace_idt_table[];
15068 +extern const struct desc_ptr trace_idt_descr;
15069 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15070 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15071 {
15072 write_idt_entry(trace_idt_table, entry, gate);
15073 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15074 }
15075 #endif
15076
15077 -static inline void _set_gate(int gate, unsigned type, void *addr,
15078 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15079 unsigned dpl, unsigned ist, unsigned seg)
15080 {
15081 gate_desc s;
15082 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15083 * Pentium F0 0F bugfix can have resulted in the mapped
15084 * IDT being write-protected.
15085 */
15086 -static inline void set_intr_gate(unsigned int n, void *addr)
15087 +static inline void set_intr_gate(unsigned int n, const void *addr)
15088 {
15089 BUG_ON((unsigned)n > 0xFF);
15090 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15091 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15092 /*
15093 * This routine sets up an interrupt gate at directory privilege level 3.
15094 */
15095 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15096 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15097 {
15098 BUG_ON((unsigned)n > 0xFF);
15099 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15100 }
15101
15102 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15103 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15104 {
15105 BUG_ON((unsigned)n > 0xFF);
15106 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15107 }
15108
15109 -static inline void set_trap_gate(unsigned int n, void *addr)
15110 +static inline void set_trap_gate(unsigned int n, const void *addr)
15111 {
15112 BUG_ON((unsigned)n > 0xFF);
15113 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15114 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15115 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15116 {
15117 BUG_ON((unsigned)n > 0xFF);
15118 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15119 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15120 }
15121
15122 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15123 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15124 {
15125 BUG_ON((unsigned)n > 0xFF);
15126 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15127 }
15128
15129 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15130 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15134 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15135 else
15136 load_idt((const struct desc_ptr *)&idt_descr);
15137 }
15138 +
15139 +#ifdef CONFIG_X86_32
15140 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15141 +{
15142 + struct desc_struct d;
15143 +
15144 + if (likely(limit))
15145 + limit = (limit - 1UL) >> PAGE_SHIFT;
15146 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15147 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15148 +}
15149 +#endif
15150 +
15151 #endif /* _ASM_X86_DESC_H */
15152 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15153 index 278441f..b95a174 100644
15154 --- a/arch/x86/include/asm/desc_defs.h
15155 +++ b/arch/x86/include/asm/desc_defs.h
15156 @@ -31,6 +31,12 @@ struct desc_struct {
15157 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15158 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15159 };
15160 + struct {
15161 + u16 offset_low;
15162 + u16 seg;
15163 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15164 + unsigned offset_high: 16;
15165 + } gate;
15166 };
15167 } __attribute__((packed));
15168
15169 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15170 index ced283a..ffe04cc 100644
15171 --- a/arch/x86/include/asm/div64.h
15172 +++ b/arch/x86/include/asm/div64.h
15173 @@ -39,7 +39,7 @@
15174 __mod; \
15175 })
15176
15177 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15178 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15179 {
15180 union {
15181 u64 v64;
15182 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15183 index 9c999c1..3860cb8 100644
15184 --- a/arch/x86/include/asm/elf.h
15185 +++ b/arch/x86/include/asm/elf.h
15186 @@ -243,7 +243,25 @@ extern int force_personality32;
15187 the loader. We need to make sure that it is out of the way of the program
15188 that it will "exec", and that there is sufficient room for the brk. */
15189
15190 +#ifdef CONFIG_PAX_SEGMEXEC
15191 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15192 +#else
15193 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15194 +#endif
15195 +
15196 +#ifdef CONFIG_PAX_ASLR
15197 +#ifdef CONFIG_X86_32
15198 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15199 +
15200 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15201 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15202 +#else
15203 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15204 +
15205 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15206 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15207 +#endif
15208 +#endif
15209
15210 /* This yields a mask that user programs can use to figure out what
15211 instruction set this CPU supports. This could be done in user space,
15212 @@ -296,16 +314,12 @@ do { \
15213
15214 #define ARCH_DLINFO \
15215 do { \
15216 - if (vdso_enabled) \
15217 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15218 - (unsigned long)current->mm->context.vdso); \
15219 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15220 } while (0)
15221
15222 #define ARCH_DLINFO_X32 \
15223 do { \
15224 - if (vdso_enabled) \
15225 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15226 - (unsigned long)current->mm->context.vdso); \
15227 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15228 } while (0)
15229
15230 #define AT_SYSINFO 32
15231 @@ -320,7 +334,7 @@ else \
15232
15233 #endif /* !CONFIG_X86_32 */
15234
15235 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15236 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15237
15238 #define VDSO_ENTRY \
15239 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15240 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15241 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15242 #define compat_arch_setup_additional_pages syscall32_setup_pages
15243
15244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15245 -#define arch_randomize_brk arch_randomize_brk
15246 -
15247 /*
15248 * True on X86_32 or when emulating IA32 on X86_64
15249 */
15250 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15251 index 77a99ac..39ff7f5 100644
15252 --- a/arch/x86/include/asm/emergency-restart.h
15253 +++ b/arch/x86/include/asm/emergency-restart.h
15254 @@ -1,6 +1,6 @@
15255 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15256 #define _ASM_X86_EMERGENCY_RESTART_H
15257
15258 -extern void machine_emergency_restart(void);
15259 +extern void machine_emergency_restart(void) __noreturn;
15260
15261 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15262 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15263 index 4d0bda7..221da4d 100644
15264 --- a/arch/x86/include/asm/fpu-internal.h
15265 +++ b/arch/x86/include/asm/fpu-internal.h
15266 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15267 #define user_insn(insn, output, input...) \
15268 ({ \
15269 int err; \
15270 + pax_open_userland(); \
15271 asm volatile(ASM_STAC "\n" \
15272 - "1:" #insn "\n\t" \
15273 + "1:" \
15274 + __copyuser_seg \
15275 + #insn "\n\t" \
15276 "2: " ASM_CLAC "\n" \
15277 ".section .fixup,\"ax\"\n" \
15278 "3: movl $-1,%[err]\n" \
15279 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15280 _ASM_EXTABLE(1b, 3b) \
15281 : [err] "=r" (err), output \
15282 : "0"(0), input); \
15283 + pax_close_userland(); \
15284 err; \
15285 })
15286
15287 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15288 "emms\n\t" /* clear stack tags */
15289 "fildl %P[addr]", /* set F?P to defined value */
15290 X86_FEATURE_FXSAVE_LEAK,
15291 - [addr] "m" (tsk->thread.fpu.has_fpu));
15292 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15293
15294 return fpu_restore_checking(&tsk->thread.fpu);
15295 }
15296 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15297 index be27ba1..04a8801 100644
15298 --- a/arch/x86/include/asm/futex.h
15299 +++ b/arch/x86/include/asm/futex.h
15300 @@ -12,6 +12,7 @@
15301 #include <asm/smap.h>
15302
15303 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15304 + typecheck(u32 __user *, uaddr); \
15305 asm volatile("\t" ASM_STAC "\n" \
15306 "1:\t" insn "\n" \
15307 "2:\t" ASM_CLAC "\n" \
15308 @@ -20,15 +21,16 @@
15309 "\tjmp\t2b\n" \
15310 "\t.previous\n" \
15311 _ASM_EXTABLE(1b, 3b) \
15312 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15313 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15314 : "i" (-EFAULT), "0" (oparg), "1" (0))
15315
15316 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15317 + typecheck(u32 __user *, uaddr); \
15318 asm volatile("\t" ASM_STAC "\n" \
15319 "1:\tmovl %2, %0\n" \
15320 "\tmovl\t%0, %3\n" \
15321 "\t" insn "\n" \
15322 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15323 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15324 "\tjnz\t1b\n" \
15325 "3:\t" ASM_CLAC "\n" \
15326 "\t.section .fixup,\"ax\"\n" \
15327 @@ -38,7 +40,7 @@
15328 _ASM_EXTABLE(1b, 4b) \
15329 _ASM_EXTABLE(2b, 4b) \
15330 : "=&a" (oldval), "=&r" (ret), \
15331 - "+m" (*uaddr), "=&r" (tem) \
15332 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15333 : "r" (oparg), "i" (-EFAULT), "1" (0))
15334
15335 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15336 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15337
15338 pagefault_disable();
15339
15340 + pax_open_userland();
15341 switch (op) {
15342 case FUTEX_OP_SET:
15343 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15344 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15345 break;
15346 case FUTEX_OP_ADD:
15347 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15348 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15349 uaddr, oparg);
15350 break;
15351 case FUTEX_OP_OR:
15352 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15353 default:
15354 ret = -ENOSYS;
15355 }
15356 + pax_close_userland();
15357
15358 pagefault_enable();
15359
15360 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15361 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15362 return -EFAULT;
15363
15364 + pax_open_userland();
15365 asm volatile("\t" ASM_STAC "\n"
15366 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15367 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15368 "2:\t" ASM_CLAC "\n"
15369 "\t.section .fixup, \"ax\"\n"
15370 "3:\tmov %3, %0\n"
15371 "\tjmp 2b\n"
15372 "\t.previous\n"
15373 _ASM_EXTABLE(1b, 3b)
15374 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15375 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15376 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15377 : "memory"
15378 );
15379 + pax_close_userland();
15380
15381 *uval = oldval;
15382 return ret;
15383 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15384 index e4ac559..c1c0c87 100644
15385 --- a/arch/x86/include/asm/hw_irq.h
15386 +++ b/arch/x86/include/asm/hw_irq.h
15387 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15388 extern void enable_IO_APIC(void);
15389
15390 /* Statistics */
15391 -extern atomic_t irq_err_count;
15392 -extern atomic_t irq_mis_count;
15393 +extern atomic_unchecked_t irq_err_count;
15394 +extern atomic_unchecked_t irq_mis_count;
15395
15396 /* EISA */
15397 extern void eisa_set_level_irq(unsigned int irq);
15398 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15399 index a203659..9889f1c 100644
15400 --- a/arch/x86/include/asm/i8259.h
15401 +++ b/arch/x86/include/asm/i8259.h
15402 @@ -62,7 +62,7 @@ struct legacy_pic {
15403 void (*init)(int auto_eoi);
15404 int (*irq_pending)(unsigned int irq);
15405 void (*make_irq)(unsigned int irq);
15406 -};
15407 +} __do_const;
15408
15409 extern struct legacy_pic *legacy_pic;
15410 extern struct legacy_pic null_legacy_pic;
15411 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15412 index 34f69cb..6d95446 100644
15413 --- a/arch/x86/include/asm/io.h
15414 +++ b/arch/x86/include/asm/io.h
15415 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15416 "m" (*(volatile type __force *)addr) barrier); }
15417
15418 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15419 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15420 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15421 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15422 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15423
15424 build_mmio_read(__readb, "b", unsigned char, "=q", )
15425 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15426 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15427 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15428 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15429
15430 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15431 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15432 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15433 return ioremap_nocache(offset, size);
15434 }
15435
15436 -extern void iounmap(volatile void __iomem *addr);
15437 +extern void iounmap(const volatile void __iomem *addr);
15438
15439 extern void set_iounmap_nonlazy(void);
15440
15441 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15442
15443 #include <linux/vmalloc.h>
15444
15445 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15446 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15447 +{
15448 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15449 +}
15450 +
15451 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15452 +{
15453 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15454 +}
15455 +
15456 /*
15457 * Convert a virtual cached pointer to an uncached pointer
15458 */
15459 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15460 index bba3cf8..06bc8da 100644
15461 --- a/arch/x86/include/asm/irqflags.h
15462 +++ b/arch/x86/include/asm/irqflags.h
15463 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15464 sti; \
15465 sysexit
15466
15467 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15468 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15469 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15470 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15471 +
15472 #else
15473 #define INTERRUPT_RETURN iret
15474 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15475 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15476 index 5a6d287..f815789 100644
15477 --- a/arch/x86/include/asm/kprobes.h
15478 +++ b/arch/x86/include/asm/kprobes.h
15479 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15480 #define RELATIVEJUMP_SIZE 5
15481 #define RELATIVECALL_OPCODE 0xe8
15482 #define RELATIVE_ADDR_SIZE 4
15483 -#define MAX_STACK_SIZE 64
15484 -#define MIN_STACK_SIZE(ADDR) \
15485 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15486 - THREAD_SIZE - (unsigned long)(ADDR))) \
15487 - ? (MAX_STACK_SIZE) \
15488 - : (((unsigned long)current_thread_info()) + \
15489 - THREAD_SIZE - (unsigned long)(ADDR)))
15490 +#define MAX_STACK_SIZE 64UL
15491 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15492
15493 #define flush_insn_slot(p) do { } while (0)
15494
15495 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15496 index 2d89e39..baee879 100644
15497 --- a/arch/x86/include/asm/local.h
15498 +++ b/arch/x86/include/asm/local.h
15499 @@ -10,33 +10,97 @@ typedef struct {
15500 atomic_long_t a;
15501 } local_t;
15502
15503 +typedef struct {
15504 + atomic_long_unchecked_t a;
15505 +} local_unchecked_t;
15506 +
15507 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15508
15509 #define local_read(l) atomic_long_read(&(l)->a)
15510 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15511 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15512 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15513
15514 static inline void local_inc(local_t *l)
15515 {
15516 - asm volatile(_ASM_INC "%0"
15517 + asm volatile(_ASM_INC "%0\n"
15518 +
15519 +#ifdef CONFIG_PAX_REFCOUNT
15520 + "jno 0f\n"
15521 + _ASM_DEC "%0\n"
15522 + "int $4\n0:\n"
15523 + _ASM_EXTABLE(0b, 0b)
15524 +#endif
15525 +
15526 + : "+m" (l->a.counter));
15527 +}
15528 +
15529 +static inline void local_inc_unchecked(local_unchecked_t *l)
15530 +{
15531 + asm volatile(_ASM_INC "%0\n"
15532 : "+m" (l->a.counter));
15533 }
15534
15535 static inline void local_dec(local_t *l)
15536 {
15537 - asm volatile(_ASM_DEC "%0"
15538 + asm volatile(_ASM_DEC "%0\n"
15539 +
15540 +#ifdef CONFIG_PAX_REFCOUNT
15541 + "jno 0f\n"
15542 + _ASM_INC "%0\n"
15543 + "int $4\n0:\n"
15544 + _ASM_EXTABLE(0b, 0b)
15545 +#endif
15546 +
15547 + : "+m" (l->a.counter));
15548 +}
15549 +
15550 +static inline void local_dec_unchecked(local_unchecked_t *l)
15551 +{
15552 + asm volatile(_ASM_DEC "%0\n"
15553 : "+m" (l->a.counter));
15554 }
15555
15556 static inline void local_add(long i, local_t *l)
15557 {
15558 - asm volatile(_ASM_ADD "%1,%0"
15559 + asm volatile(_ASM_ADD "%1,%0\n"
15560 +
15561 +#ifdef CONFIG_PAX_REFCOUNT
15562 + "jno 0f\n"
15563 + _ASM_SUB "%1,%0\n"
15564 + "int $4\n0:\n"
15565 + _ASM_EXTABLE(0b, 0b)
15566 +#endif
15567 +
15568 + : "+m" (l->a.counter)
15569 + : "ir" (i));
15570 +}
15571 +
15572 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_ADD "%1,%0\n"
15575 : "+m" (l->a.counter)
15576 : "ir" (i));
15577 }
15578
15579 static inline void local_sub(long i, local_t *l)
15580 {
15581 - asm volatile(_ASM_SUB "%1,%0"
15582 + asm volatile(_ASM_SUB "%1,%0\n"
15583 +
15584 +#ifdef CONFIG_PAX_REFCOUNT
15585 + "jno 0f\n"
15586 + _ASM_ADD "%1,%0\n"
15587 + "int $4\n0:\n"
15588 + _ASM_EXTABLE(0b, 0b)
15589 +#endif
15590 +
15591 + : "+m" (l->a.counter)
15592 + : "ir" (i));
15593 +}
15594 +
15595 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15596 +{
15597 + asm volatile(_ASM_SUB "%1,%0\n"
15598 : "+m" (l->a.counter)
15599 : "ir" (i));
15600 }
15601 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15602 {
15603 unsigned char c;
15604
15605 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15606 + asm volatile(_ASM_SUB "%2,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%2,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + "sete %1\n"
15616 : "+m" (l->a.counter), "=qm" (c)
15617 : "ir" (i) : "memory");
15618 return c;
15619 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15620 {
15621 unsigned char c;
15622
15623 - asm volatile(_ASM_DEC "%0; sete %1"
15624 + asm volatile(_ASM_DEC "%0\n"
15625 +
15626 +#ifdef CONFIG_PAX_REFCOUNT
15627 + "jno 0f\n"
15628 + _ASM_INC "%0\n"
15629 + "int $4\n0:\n"
15630 + _ASM_EXTABLE(0b, 0b)
15631 +#endif
15632 +
15633 + "sete %1\n"
15634 : "+m" (l->a.counter), "=qm" (c)
15635 : : "memory");
15636 return c != 0;
15637 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15638 {
15639 unsigned char c;
15640
15641 - asm volatile(_ASM_INC "%0; sete %1"
15642 + asm volatile(_ASM_INC "%0\n"
15643 +
15644 +#ifdef CONFIG_PAX_REFCOUNT
15645 + "jno 0f\n"
15646 + _ASM_DEC "%0\n"
15647 + "int $4\n0:\n"
15648 + _ASM_EXTABLE(0b, 0b)
15649 +#endif
15650 +
15651 + "sete %1\n"
15652 : "+m" (l->a.counter), "=qm" (c)
15653 : : "memory");
15654 return c != 0;
15655 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15656 {
15657 unsigned char c;
15658
15659 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15660 + asm volatile(_ASM_ADD "%2,%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + _ASM_SUB "%2,%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 + "sets %1\n"
15670 : "+m" (l->a.counter), "=qm" (c)
15671 : "ir" (i) : "memory");
15672 return c;
15673 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15674 static inline long local_add_return(long i, local_t *l)
15675 {
15676 long __i = i;
15677 + asm volatile(_ASM_XADD "%0, %1\n"
15678 +
15679 +#ifdef CONFIG_PAX_REFCOUNT
15680 + "jno 0f\n"
15681 + _ASM_MOV "%0,%1\n"
15682 + "int $4\n0:\n"
15683 + _ASM_EXTABLE(0b, 0b)
15684 +#endif
15685 +
15686 + : "+r" (i), "+m" (l->a.counter)
15687 + : : "memory");
15688 + return i + __i;
15689 +}
15690 +
15691 +/**
15692 + * local_add_return_unchecked - add and return
15693 + * @i: integer value to add
15694 + * @l: pointer to type local_unchecked_t
15695 + *
15696 + * Atomically adds @i to @l and returns @i + @l
15697 + */
15698 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15699 +{
15700 + long __i = i;
15701 asm volatile(_ASM_XADD "%0, %1;"
15702 : "+r" (i), "+m" (l->a.counter)
15703 : : "memory");
15704 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15705
15706 #define local_cmpxchg(l, o, n) \
15707 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15708 +#define local_cmpxchg_unchecked(l, o, n) \
15709 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15710 /* Always has a lock prefix */
15711 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15712
15713 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15714 new file mode 100644
15715 index 0000000..2bfd3ba
15716 --- /dev/null
15717 +++ b/arch/x86/include/asm/mman.h
15718 @@ -0,0 +1,15 @@
15719 +#ifndef _X86_MMAN_H
15720 +#define _X86_MMAN_H
15721 +
15722 +#include <uapi/asm/mman.h>
15723 +
15724 +#ifdef __KERNEL__
15725 +#ifndef __ASSEMBLY__
15726 +#ifdef CONFIG_X86_32
15727 +#define arch_mmap_check i386_mmap_check
15728 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15729 +#endif
15730 +#endif
15731 +#endif
15732 +
15733 +#endif /* X86_MMAN_H */
15734 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15735 index 5f55e69..e20bfb1 100644
15736 --- a/arch/x86/include/asm/mmu.h
15737 +++ b/arch/x86/include/asm/mmu.h
15738 @@ -9,7 +9,7 @@
15739 * we put the segment information here.
15740 */
15741 typedef struct {
15742 - void *ldt;
15743 + struct desc_struct *ldt;
15744 int size;
15745
15746 #ifdef CONFIG_X86_64
15747 @@ -18,7 +18,19 @@ typedef struct {
15748 #endif
15749
15750 struct mutex lock;
15751 - void *vdso;
15752 + unsigned long vdso;
15753 +
15754 +#ifdef CONFIG_X86_32
15755 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15756 + unsigned long user_cs_base;
15757 + unsigned long user_cs_limit;
15758 +
15759 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15760 + cpumask_t cpu_user_cs_mask;
15761 +#endif
15762 +
15763 +#endif
15764 +#endif
15765 } mm_context_t;
15766
15767 #ifdef CONFIG_SMP
15768 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15769 index be12c53..2124e35 100644
15770 --- a/arch/x86/include/asm/mmu_context.h
15771 +++ b/arch/x86/include/asm/mmu_context.h
15772 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15773
15774 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15775 {
15776 +
15777 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15778 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15779 + unsigned int i;
15780 + pgd_t *pgd;
15781 +
15782 + pax_open_kernel();
15783 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15784 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15785 + set_pgd_batched(pgd+i, native_make_pgd(0));
15786 + pax_close_kernel();
15787 + }
15788 +#endif
15789 +
15790 #ifdef CONFIG_SMP
15791 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15792 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15793 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15794 struct task_struct *tsk)
15795 {
15796 unsigned cpu = smp_processor_id();
15797 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15798 + int tlbstate = TLBSTATE_OK;
15799 +#endif
15800
15801 if (likely(prev != next)) {
15802 #ifdef CONFIG_SMP
15803 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15804 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15805 +#endif
15806 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15807 this_cpu_write(cpu_tlbstate.active_mm, next);
15808 #endif
15809 cpumask_set_cpu(cpu, mm_cpumask(next));
15810
15811 /* Re-load page tables */
15812 +#ifdef CONFIG_PAX_PER_CPU_PGD
15813 + pax_open_kernel();
15814 +
15815 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15816 + if (static_cpu_has(X86_FEATURE_PCID))
15817 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15818 + else
15819 +#endif
15820 +
15821 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15822 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15823 + pax_close_kernel();
15824 + 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));
15825 +
15826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15827 + if (static_cpu_has(X86_FEATURE_PCID)) {
15828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15829 + u64 descriptor[2];
15830 + descriptor[0] = PCID_USER;
15831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15832 + } else {
15833 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15834 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15835 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15836 + else
15837 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15838 + }
15839 + } else
15840 +#endif
15841 +
15842 + load_cr3(get_cpu_pgd(cpu, kernel));
15843 +#else
15844 load_cr3(next->pgd);
15845 +#endif
15846
15847 /* Stop flush ipis for the previous mm */
15848 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15849 @@ -51,9 +104,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15850 /* Load the LDT, if the LDT is different: */
15851 if (unlikely(prev->context.ldt != next->context.ldt))
15852 load_LDT_nolock(&next->context);
15853 +
15854 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15855 + if (!(__supported_pte_mask & _PAGE_NX)) {
15856 + smp_mb__before_clear_bit();
15857 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15858 + smp_mb__after_clear_bit();
15859 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15860 + }
15861 +#endif
15862 +
15863 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15864 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15865 + prev->context.user_cs_limit != next->context.user_cs_limit))
15866 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15867 +#ifdef CONFIG_SMP
15868 + else if (unlikely(tlbstate != TLBSTATE_OK))
15869 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15870 +#endif
15871 +#endif
15872 +
15873 }
15874 + else {
15875 +
15876 +#ifdef CONFIG_PAX_PER_CPU_PGD
15877 + pax_open_kernel();
15878 +
15879 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15880 + if (static_cpu_has(X86_FEATURE_PCID))
15881 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15882 + else
15883 +#endif
15884 +
15885 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15886 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15887 + pax_close_kernel();
15888 + 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));
15889 +
15890 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15891 + if (static_cpu_has(X86_FEATURE_PCID)) {
15892 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15893 + u64 descriptor[2];
15894 + descriptor[0] = PCID_USER;
15895 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15896 + } else {
15897 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15898 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15899 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15900 + else
15901 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15902 + }
15903 + } else
15904 +#endif
15905 +
15906 + load_cr3(get_cpu_pgd(cpu, kernel));
15907 +#endif
15908 +
15909 #ifdef CONFIG_SMP
15910 - else {
15911 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15912 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15913
15914 @@ -70,11 +177,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15915 * tlb flush IPI delivery. We must reload CR3
15916 * to make sure to use no freed page tables.
15917 */
15918 +
15919 +#ifndef CONFIG_PAX_PER_CPU_PGD
15920 load_cr3(next->pgd);
15921 +#endif
15922 +
15923 load_LDT_nolock(&next->context);
15924 +
15925 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15926 + if (!(__supported_pte_mask & _PAGE_NX))
15927 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15928 +#endif
15929 +
15930 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15931 +#ifdef CONFIG_PAX_PAGEEXEC
15932 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15933 +#endif
15934 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15935 +#endif
15936 +
15937 }
15938 +#endif
15939 }
15940 -#endif
15941 }
15942
15943 #define activate_mm(prev, next) \
15944 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15945 index e3b7819..b257c64 100644
15946 --- a/arch/x86/include/asm/module.h
15947 +++ b/arch/x86/include/asm/module.h
15948 @@ -5,6 +5,7 @@
15949
15950 #ifdef CONFIG_X86_64
15951 /* X86_64 does not define MODULE_PROC_FAMILY */
15952 +#define MODULE_PROC_FAMILY ""
15953 #elif defined CONFIG_M486
15954 #define MODULE_PROC_FAMILY "486 "
15955 #elif defined CONFIG_M586
15956 @@ -57,8 +58,20 @@
15957 #error unknown processor family
15958 #endif
15959
15960 -#ifdef CONFIG_X86_32
15961 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15962 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15963 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15964 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15965 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15966 +#else
15967 +#define MODULE_PAX_KERNEXEC ""
15968 #endif
15969
15970 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15971 +#define MODULE_PAX_UDEREF "UDEREF "
15972 +#else
15973 +#define MODULE_PAX_UDEREF ""
15974 +#endif
15975 +
15976 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15977 +
15978 #endif /* _ASM_X86_MODULE_H */
15979 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15980 index 86f9301..b365cda 100644
15981 --- a/arch/x86/include/asm/nmi.h
15982 +++ b/arch/x86/include/asm/nmi.h
15983 @@ -40,11 +40,11 @@ struct nmiaction {
15984 nmi_handler_t handler;
15985 unsigned long flags;
15986 const char *name;
15987 -};
15988 +} __do_const;
15989
15990 #define register_nmi_handler(t, fn, fg, n, init...) \
15991 ({ \
15992 - static struct nmiaction init fn##_na = { \
15993 + static const struct nmiaction init fn##_na = { \
15994 .handler = (fn), \
15995 .name = (n), \
15996 .flags = (fg), \
15997 @@ -52,7 +52,7 @@ struct nmiaction {
15998 __register_nmi_handler((t), &fn##_na); \
15999 })
16000
16001 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16002 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16003
16004 void unregister_nmi_handler(unsigned int, const char *);
16005
16006 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16007 index c878924..21f4889 100644
16008 --- a/arch/x86/include/asm/page.h
16009 +++ b/arch/x86/include/asm/page.h
16010 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16011 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16012
16013 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16014 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16015
16016 #define __boot_va(x) __va(x)
16017 #define __boot_pa(x) __pa(x)
16018 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16019 index 0f1ddee..e2fc3d1 100644
16020 --- a/arch/x86/include/asm/page_64.h
16021 +++ b/arch/x86/include/asm/page_64.h
16022 @@ -7,9 +7,9 @@
16023
16024 /* duplicated to the one in bootmem.h */
16025 extern unsigned long max_pfn;
16026 -extern unsigned long phys_base;
16027 +extern const unsigned long phys_base;
16028
16029 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16030 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16031 {
16032 unsigned long y = x - __START_KERNEL_map;
16033
16034 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16035 index cfdc9ee..3f7b5d6 100644
16036 --- a/arch/x86/include/asm/paravirt.h
16037 +++ b/arch/x86/include/asm/paravirt.h
16038 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16039 return (pmd_t) { ret };
16040 }
16041
16042 -static inline pmdval_t pmd_val(pmd_t pmd)
16043 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16044 {
16045 pmdval_t ret;
16046
16047 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16048 val);
16049 }
16050
16051 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16052 +{
16053 + pgdval_t val = native_pgd_val(pgd);
16054 +
16055 + if (sizeof(pgdval_t) > sizeof(long))
16056 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16057 + val, (u64)val >> 32);
16058 + else
16059 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16060 + val);
16061 +}
16062 +
16063 static inline void pgd_clear(pgd_t *pgdp)
16064 {
16065 set_pgd(pgdp, __pgd(0));
16066 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16067 pv_mmu_ops.set_fixmap(idx, phys, flags);
16068 }
16069
16070 +#ifdef CONFIG_PAX_KERNEXEC
16071 +static inline unsigned long pax_open_kernel(void)
16072 +{
16073 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16074 +}
16075 +
16076 +static inline unsigned long pax_close_kernel(void)
16077 +{
16078 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16079 +}
16080 +#else
16081 +static inline unsigned long pax_open_kernel(void) { return 0; }
16082 +static inline unsigned long pax_close_kernel(void) { return 0; }
16083 +#endif
16084 +
16085 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16086
16087 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16088 @@ -926,7 +953,7 @@ extern void default_banner(void);
16089
16090 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16091 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16092 -#define PARA_INDIRECT(addr) *%cs:addr
16093 +#define PARA_INDIRECT(addr) *%ss:addr
16094 #endif
16095
16096 #define INTERRUPT_RETURN \
16097 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16098 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16099 CLBR_NONE, \
16100 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16101 +
16102 +#define GET_CR0_INTO_RDI \
16103 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16104 + mov %rax,%rdi
16105 +
16106 +#define SET_RDI_INTO_CR0 \
16107 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16108 +
16109 +#define GET_CR3_INTO_RDI \
16110 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16111 + mov %rax,%rdi
16112 +
16113 +#define SET_RDI_INTO_CR3 \
16114 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16115 +
16116 #endif /* CONFIG_X86_32 */
16117
16118 #endif /* __ASSEMBLY__ */
16119 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16120 index 0db1fca..52310cc 100644
16121 --- a/arch/x86/include/asm/paravirt_types.h
16122 +++ b/arch/x86/include/asm/paravirt_types.h
16123 @@ -84,7 +84,7 @@ struct pv_init_ops {
16124 */
16125 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16126 unsigned long addr, unsigned len);
16127 -};
16128 +} __no_const;
16129
16130
16131 struct pv_lazy_ops {
16132 @@ -98,7 +98,7 @@ struct pv_time_ops {
16133 unsigned long long (*sched_clock)(void);
16134 unsigned long long (*steal_clock)(int cpu);
16135 unsigned long (*get_tsc_khz)(void);
16136 -};
16137 +} __no_const;
16138
16139 struct pv_cpu_ops {
16140 /* hooks for various privileged instructions */
16141 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16142
16143 void (*start_context_switch)(struct task_struct *prev);
16144 void (*end_context_switch)(struct task_struct *next);
16145 -};
16146 +} __no_const;
16147
16148 struct pv_irq_ops {
16149 /*
16150 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16151 unsigned long start_eip,
16152 unsigned long start_esp);
16153 #endif
16154 -};
16155 +} __no_const;
16156
16157 struct pv_mmu_ops {
16158 unsigned long (*read_cr2)(void);
16159 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16160 struct paravirt_callee_save make_pud;
16161
16162 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16163 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16164 #endif /* PAGETABLE_LEVELS == 4 */
16165 #endif /* PAGETABLE_LEVELS >= 3 */
16166
16167 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16168 an mfn. We can tell which is which from the index. */
16169 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16170 phys_addr_t phys, pgprot_t flags);
16171 +
16172 +#ifdef CONFIG_PAX_KERNEXEC
16173 + unsigned long (*pax_open_kernel)(void);
16174 + unsigned long (*pax_close_kernel)(void);
16175 +#endif
16176 +
16177 };
16178
16179 struct arch_spinlock;
16180 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16181 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16182 int (*spin_trylock)(struct arch_spinlock *lock);
16183 void (*spin_unlock)(struct arch_spinlock *lock);
16184 -};
16185 +} __no_const;
16186
16187 /* This contains all the paravirt structures: we get a convenient
16188 * number for each function using the offset which we use to indicate
16189 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16190 index b4389a4..7024269 100644
16191 --- a/arch/x86/include/asm/pgalloc.h
16192 +++ b/arch/x86/include/asm/pgalloc.h
16193 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16194 pmd_t *pmd, pte_t *pte)
16195 {
16196 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16197 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16198 +}
16199 +
16200 +static inline void pmd_populate_user(struct mm_struct *mm,
16201 + pmd_t *pmd, pte_t *pte)
16202 +{
16203 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16204 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16205 }
16206
16207 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16208
16209 #ifdef CONFIG_X86_PAE
16210 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16211 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16212 +{
16213 + pud_populate(mm, pudp, pmd);
16214 +}
16215 #else /* !CONFIG_X86_PAE */
16216 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16217 {
16218 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16219 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16220 }
16221 +
16222 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16223 +{
16224 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16225 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16226 +}
16227 #endif /* CONFIG_X86_PAE */
16228
16229 #if PAGETABLE_LEVELS > 3
16230 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16231 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16232 }
16233
16234 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16235 +{
16236 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16237 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16238 +}
16239 +
16240 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16241 {
16242 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16243 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16244 index 3bf2dd0..23d2a9f 100644
16245 --- a/arch/x86/include/asm/pgtable-2level.h
16246 +++ b/arch/x86/include/asm/pgtable-2level.h
16247 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16248
16249 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16250 {
16251 + pax_open_kernel();
16252 *pmdp = pmd;
16253 + pax_close_kernel();
16254 }
16255
16256 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16257 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16258 index 81bb91b..9392125 100644
16259 --- a/arch/x86/include/asm/pgtable-3level.h
16260 +++ b/arch/x86/include/asm/pgtable-3level.h
16261 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16262
16263 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16264 {
16265 + pax_open_kernel();
16266 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16267 + pax_close_kernel();
16268 }
16269
16270 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16271 {
16272 + pax_open_kernel();
16273 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16274 + pax_close_kernel();
16275 }
16276
16277 /*
16278 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16279 index 1c00631..845f898 100644
16280 --- a/arch/x86/include/asm/pgtable.h
16281 +++ b/arch/x86/include/asm/pgtable.h
16282 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16283
16284 #ifndef __PAGETABLE_PUD_FOLDED
16285 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16286 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16287 #define pgd_clear(pgd) native_pgd_clear(pgd)
16288 #endif
16289
16290 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16291
16292 #define arch_end_context_switch(prev) do {} while(0)
16293
16294 +#define pax_open_kernel() native_pax_open_kernel()
16295 +#define pax_close_kernel() native_pax_close_kernel()
16296 #endif /* CONFIG_PARAVIRT */
16297
16298 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16299 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16300 +
16301 +#ifdef CONFIG_PAX_KERNEXEC
16302 +static inline unsigned long native_pax_open_kernel(void)
16303 +{
16304 + unsigned long cr0;
16305 +
16306 + preempt_disable();
16307 + barrier();
16308 + cr0 = read_cr0() ^ X86_CR0_WP;
16309 + BUG_ON(cr0 & X86_CR0_WP);
16310 + write_cr0(cr0);
16311 + return cr0 ^ X86_CR0_WP;
16312 +}
16313 +
16314 +static inline unsigned long native_pax_close_kernel(void)
16315 +{
16316 + unsigned long cr0;
16317 +
16318 + cr0 = read_cr0() ^ X86_CR0_WP;
16319 + BUG_ON(!(cr0 & X86_CR0_WP));
16320 + write_cr0(cr0);
16321 + barrier();
16322 + preempt_enable_no_resched();
16323 + return cr0 ^ X86_CR0_WP;
16324 +}
16325 +#else
16326 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16327 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16328 +#endif
16329 +
16330 /*
16331 * The following only work if pte_present() is true.
16332 * Undefined behaviour if not..
16333 */
16334 +static inline int pte_user(pte_t pte)
16335 +{
16336 + return pte_val(pte) & _PAGE_USER;
16337 +}
16338 +
16339 static inline int pte_dirty(pte_t pte)
16340 {
16341 return pte_flags(pte) & _PAGE_DIRTY;
16342 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16343 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16344 }
16345
16346 +static inline unsigned long pgd_pfn(pgd_t pgd)
16347 +{
16348 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16349 +}
16350 +
16351 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16352
16353 static inline int pmd_large(pmd_t pte)
16354 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16355 return pte_clear_flags(pte, _PAGE_RW);
16356 }
16357
16358 +static inline pte_t pte_mkread(pte_t pte)
16359 +{
16360 + return __pte(pte_val(pte) | _PAGE_USER);
16361 +}
16362 +
16363 static inline pte_t pte_mkexec(pte_t pte)
16364 {
16365 - return pte_clear_flags(pte, _PAGE_NX);
16366 +#ifdef CONFIG_X86_PAE
16367 + if (__supported_pte_mask & _PAGE_NX)
16368 + return pte_clear_flags(pte, _PAGE_NX);
16369 + else
16370 +#endif
16371 + return pte_set_flags(pte, _PAGE_USER);
16372 +}
16373 +
16374 +static inline pte_t pte_exprotect(pte_t pte)
16375 +{
16376 +#ifdef CONFIG_X86_PAE
16377 + if (__supported_pte_mask & _PAGE_NX)
16378 + return pte_set_flags(pte, _PAGE_NX);
16379 + else
16380 +#endif
16381 + return pte_clear_flags(pte, _PAGE_USER);
16382 }
16383
16384 static inline pte_t pte_mkdirty(pte_t pte)
16385 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16386 #endif
16387
16388 #ifndef __ASSEMBLY__
16389 +
16390 +#ifdef CONFIG_PAX_PER_CPU_PGD
16391 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16392 +enum cpu_pgd_type {kernel = 0, user = 1};
16393 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16394 +{
16395 + return cpu_pgd[cpu][type];
16396 +}
16397 +#endif
16398 +
16399 #include <linux/mm_types.h>
16400 #include <linux/log2.h>
16401
16402 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16403 * Currently stuck as a macro due to indirect forward reference to
16404 * linux/mmzone.h's __section_mem_map_addr() definition:
16405 */
16406 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16407 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16408
16409 /* Find an entry in the second-level page table.. */
16410 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16411 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16412 * Currently stuck as a macro due to indirect forward reference to
16413 * linux/mmzone.h's __section_mem_map_addr() definition:
16414 */
16415 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16416 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16417
16418 /* to find an entry in a page-table-directory. */
16419 static inline unsigned long pud_index(unsigned long address)
16420 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16421
16422 static inline int pgd_bad(pgd_t pgd)
16423 {
16424 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16425 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16426 }
16427
16428 static inline int pgd_none(pgd_t pgd)
16429 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16430 * pgd_offset() returns a (pgd_t *)
16431 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16432 */
16433 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16434 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16435 +
16436 +#ifdef CONFIG_PAX_PER_CPU_PGD
16437 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16438 +#endif
16439 +
16440 /*
16441 * a shortcut which implies the use of the kernel's pgd, instead
16442 * of a process's
16443 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16444 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16445 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16446
16447 +#ifdef CONFIG_X86_32
16448 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16449 +#else
16450 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16451 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16452 +
16453 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16454 +#ifdef __ASSEMBLY__
16455 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16456 +#else
16457 +extern unsigned long pax_user_shadow_base;
16458 +extern pgdval_t clone_pgd_mask;
16459 +#endif
16460 +#endif
16461 +
16462 +#endif
16463 +
16464 #ifndef __ASSEMBLY__
16465
16466 extern int direct_gbpages;
16467 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16468 * dst and src can be on the same page, but the range must not overlap,
16469 * and must not cross a page boundary.
16470 */
16471 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16472 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16473 {
16474 - memcpy(dst, src, count * sizeof(pgd_t));
16475 + pax_open_kernel();
16476 + while (count--)
16477 + *dst++ = *src++;
16478 + pax_close_kernel();
16479 }
16480
16481 +#ifdef CONFIG_PAX_PER_CPU_PGD
16482 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16483 +#endif
16484 +
16485 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16486 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16487 +#else
16488 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16489 +#endif
16490 +
16491 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16492 static inline int page_level_shift(enum pg_level level)
16493 {
16494 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16495 index 9ee3221..b979c6b 100644
16496 --- a/arch/x86/include/asm/pgtable_32.h
16497 +++ b/arch/x86/include/asm/pgtable_32.h
16498 @@ -25,9 +25,6 @@
16499 struct mm_struct;
16500 struct vm_area_struct;
16501
16502 -extern pgd_t swapper_pg_dir[1024];
16503 -extern pgd_t initial_page_table[1024];
16504 -
16505 static inline void pgtable_cache_init(void) { }
16506 static inline void check_pgt_cache(void) { }
16507 void paging_init(void);
16508 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16509 # include <asm/pgtable-2level.h>
16510 #endif
16511
16512 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16513 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16514 +#ifdef CONFIG_X86_PAE
16515 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16516 +#endif
16517 +
16518 #if defined(CONFIG_HIGHPTE)
16519 #define pte_offset_map(dir, address) \
16520 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16521 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16522 /* Clear a kernel PTE and flush it from the TLB */
16523 #define kpte_clear_flush(ptep, vaddr) \
16524 do { \
16525 + pax_open_kernel(); \
16526 pte_clear(&init_mm, (vaddr), (ptep)); \
16527 + pax_close_kernel(); \
16528 __flush_tlb_one((vaddr)); \
16529 } while (0)
16530
16531 #endif /* !__ASSEMBLY__ */
16532
16533 +#define HAVE_ARCH_UNMAPPED_AREA
16534 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16535 +
16536 /*
16537 * kern_addr_valid() is (1) for FLATMEM and (0) for
16538 * SPARSEMEM and DISCONTIGMEM
16539 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16540 index ed5903b..c7fe163 100644
16541 --- a/arch/x86/include/asm/pgtable_32_types.h
16542 +++ b/arch/x86/include/asm/pgtable_32_types.h
16543 @@ -8,7 +8,7 @@
16544 */
16545 #ifdef CONFIG_X86_PAE
16546 # include <asm/pgtable-3level_types.h>
16547 -# define PMD_SIZE (1UL << PMD_SHIFT)
16548 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16549 # define PMD_MASK (~(PMD_SIZE - 1))
16550 #else
16551 # include <asm/pgtable-2level_types.h>
16552 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16553 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16554 #endif
16555
16556 +#ifdef CONFIG_PAX_KERNEXEC
16557 +#ifndef __ASSEMBLY__
16558 +extern unsigned char MODULES_EXEC_VADDR[];
16559 +extern unsigned char MODULES_EXEC_END[];
16560 +#endif
16561 +#include <asm/boot.h>
16562 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16563 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16564 +#else
16565 +#define ktla_ktva(addr) (addr)
16566 +#define ktva_ktla(addr) (addr)
16567 +#endif
16568 +
16569 #define MODULES_VADDR VMALLOC_START
16570 #define MODULES_END VMALLOC_END
16571 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16572 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16573 index e22c1db..23a625a 100644
16574 --- a/arch/x86/include/asm/pgtable_64.h
16575 +++ b/arch/x86/include/asm/pgtable_64.h
16576 @@ -16,10 +16,14 @@
16577
16578 extern pud_t level3_kernel_pgt[512];
16579 extern pud_t level3_ident_pgt[512];
16580 +extern pud_t level3_vmalloc_start_pgt[512];
16581 +extern pud_t level3_vmalloc_end_pgt[512];
16582 +extern pud_t level3_vmemmap_pgt[512];
16583 +extern pud_t level2_vmemmap_pgt[512];
16584 extern pmd_t level2_kernel_pgt[512];
16585 extern pmd_t level2_fixmap_pgt[512];
16586 -extern pmd_t level2_ident_pgt[512];
16587 -extern pgd_t init_level4_pgt[];
16588 +extern pmd_t level2_ident_pgt[512*2];
16589 +extern pgd_t init_level4_pgt[512];
16590
16591 #define swapper_pg_dir init_level4_pgt
16592
16593 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16594
16595 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16596 {
16597 + pax_open_kernel();
16598 *pmdp = pmd;
16599 + pax_close_kernel();
16600 }
16601
16602 static inline void native_pmd_clear(pmd_t *pmd)
16603 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16604
16605 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16606 {
16607 + pax_open_kernel();
16608 *pudp = pud;
16609 + pax_close_kernel();
16610 }
16611
16612 static inline void native_pud_clear(pud_t *pud)
16613 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16614
16615 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16616 {
16617 + pax_open_kernel();
16618 + *pgdp = pgd;
16619 + pax_close_kernel();
16620 +}
16621 +
16622 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16623 +{
16624 *pgdp = pgd;
16625 }
16626
16627 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16628 index 2d88344..4679fc3 100644
16629 --- a/arch/x86/include/asm/pgtable_64_types.h
16630 +++ b/arch/x86/include/asm/pgtable_64_types.h
16631 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16632 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16633 #define MODULES_END _AC(0xffffffffff000000, UL)
16634 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16635 +#define MODULES_EXEC_VADDR MODULES_VADDR
16636 +#define MODULES_EXEC_END MODULES_END
16637 +
16638 +#define ktla_ktva(addr) (addr)
16639 +#define ktva_ktla(addr) (addr)
16640
16641 #define EARLY_DYNAMIC_PAGE_TABLES 64
16642
16643 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16644 index f4843e0..a2526f8 100644
16645 --- a/arch/x86/include/asm/pgtable_types.h
16646 +++ b/arch/x86/include/asm/pgtable_types.h
16647 @@ -16,13 +16,12 @@
16648 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16649 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16650 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16651 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16652 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16653 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16654 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16655 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16656 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16657 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16658 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16659 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16660 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16661 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16662
16663 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16664 @@ -40,7 +39,6 @@
16665 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16666 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16667 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16668 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16669 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16670 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16671 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16672 @@ -84,8 +82,10 @@
16673
16674 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16675 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16676 -#else
16677 +#elif defined(CONFIG_KMEMCHECK)
16678 #define _PAGE_NX (_AT(pteval_t, 0))
16679 +#else
16680 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16681 #endif
16682
16683 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16684 @@ -143,6 +143,9 @@
16685 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16686 _PAGE_ACCESSED)
16687
16688 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16689 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16690 +
16691 #define __PAGE_KERNEL_EXEC \
16692 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16693 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16694 @@ -153,7 +156,7 @@
16695 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16696 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16697 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16698 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16699 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16700 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16701 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16702 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16703 @@ -215,8 +218,8 @@
16704 * bits are combined, this will alow user to access the high address mapped
16705 * VDSO in the presence of CONFIG_COMPAT_VDSO
16706 */
16707 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16708 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16709 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16710 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16711 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16712 #endif
16713
16714 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16715 {
16716 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16717 }
16718 +#endif
16719
16720 +#if PAGETABLE_LEVELS == 3
16721 +#include <asm-generic/pgtable-nopud.h>
16722 +#endif
16723 +
16724 +#if PAGETABLE_LEVELS == 2
16725 +#include <asm-generic/pgtable-nopmd.h>
16726 +#endif
16727 +
16728 +#ifndef __ASSEMBLY__
16729 #if PAGETABLE_LEVELS > 3
16730 typedef struct { pudval_t pud; } pud_t;
16731
16732 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16733 return pud.pud;
16734 }
16735 #else
16736 -#include <asm-generic/pgtable-nopud.h>
16737 -
16738 static inline pudval_t native_pud_val(pud_t pud)
16739 {
16740 return native_pgd_val(pud.pgd);
16741 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16742 return pmd.pmd;
16743 }
16744 #else
16745 -#include <asm-generic/pgtable-nopmd.h>
16746 -
16747 static inline pmdval_t native_pmd_val(pmd_t pmd)
16748 {
16749 return native_pgd_val(pmd.pud.pgd);
16750 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16751
16752 extern pteval_t __supported_pte_mask;
16753 extern void set_nx(void);
16754 -extern int nx_enabled;
16755
16756 #define pgprot_writecombine pgprot_writecombine
16757 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16758 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16759 index 24cf5ae..4d9fa2d 100644
16760 --- a/arch/x86/include/asm/processor.h
16761 +++ b/arch/x86/include/asm/processor.h
16762 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16763 : "memory");
16764 }
16765
16766 +/* invpcid (%rdx),%rax */
16767 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16768 +
16769 +#define INVPCID_SINGLE_ADDRESS 0UL
16770 +#define INVPCID_SINGLE_CONTEXT 1UL
16771 +#define INVPCID_ALL_GLOBAL 2UL
16772 +#define INVPCID_ALL_MONGLOBAL 3UL
16773 +
16774 +#define PCID_KERNEL 0UL
16775 +#define PCID_USER 1UL
16776 +#define PCID_NOFLUSH (1UL << 63)
16777 +
16778 static inline void load_cr3(pgd_t *pgdir)
16779 {
16780 - write_cr3(__pa(pgdir));
16781 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16782 }
16783
16784 #ifdef CONFIG_X86_32
16785 @@ -283,7 +295,7 @@ struct tss_struct {
16786
16787 } ____cacheline_aligned;
16788
16789 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16790 +extern struct tss_struct init_tss[NR_CPUS];
16791
16792 /*
16793 * Save the original ist values for checking stack pointers during debugging
16794 @@ -453,6 +465,7 @@ struct thread_struct {
16795 unsigned short ds;
16796 unsigned short fsindex;
16797 unsigned short gsindex;
16798 + unsigned short ss;
16799 #endif
16800 #ifdef CONFIG_X86_32
16801 unsigned long ip;
16802 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16803 extern unsigned long mmu_cr4_features;
16804 extern u32 *trampoline_cr4_features;
16805
16806 -static inline void set_in_cr4(unsigned long mask)
16807 -{
16808 - unsigned long cr4;
16809 -
16810 - mmu_cr4_features |= mask;
16811 - if (trampoline_cr4_features)
16812 - *trampoline_cr4_features = mmu_cr4_features;
16813 - cr4 = read_cr4();
16814 - cr4 |= mask;
16815 - write_cr4(cr4);
16816 -}
16817 -
16818 -static inline void clear_in_cr4(unsigned long mask)
16819 -{
16820 - unsigned long cr4;
16821 -
16822 - mmu_cr4_features &= ~mask;
16823 - if (trampoline_cr4_features)
16824 - *trampoline_cr4_features = mmu_cr4_features;
16825 - cr4 = read_cr4();
16826 - cr4 &= ~mask;
16827 - write_cr4(cr4);
16828 -}
16829 +extern void set_in_cr4(unsigned long mask);
16830 +extern void clear_in_cr4(unsigned long mask);
16831
16832 typedef struct {
16833 unsigned long seg;
16834 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16835 */
16836 #define TASK_SIZE PAGE_OFFSET
16837 #define TASK_SIZE_MAX TASK_SIZE
16838 +
16839 +#ifdef CONFIG_PAX_SEGMEXEC
16840 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16841 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16842 +#else
16843 #define STACK_TOP TASK_SIZE
16844 -#define STACK_TOP_MAX STACK_TOP
16845 +#endif
16846 +
16847 +#define STACK_TOP_MAX TASK_SIZE
16848
16849 #define INIT_THREAD { \
16850 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16851 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16852 .vm86_info = NULL, \
16853 .sysenter_cs = __KERNEL_CS, \
16854 .io_bitmap_ptr = NULL, \
16855 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16856 */
16857 #define INIT_TSS { \
16858 .x86_tss = { \
16859 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16860 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16861 .ss0 = __KERNEL_DS, \
16862 .ss1 = __KERNEL_CS, \
16863 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16864 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16865 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16866
16867 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16868 -#define KSTK_TOP(info) \
16869 -({ \
16870 - unsigned long *__ptr = (unsigned long *)(info); \
16871 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16872 -})
16873 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16874
16875 /*
16876 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16877 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16878 #define task_pt_regs(task) \
16879 ({ \
16880 struct pt_regs *__regs__; \
16881 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16882 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16883 __regs__ - 1; \
16884 })
16885
16886 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16887 /*
16888 * User space process size. 47bits minus one guard page.
16889 */
16890 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16891 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16892
16893 /* This decides where the kernel will search for a free chunk of vm
16894 * space during mmap's.
16895 */
16896 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16897 - 0xc0000000 : 0xFFFFe000)
16898 + 0xc0000000 : 0xFFFFf000)
16899
16900 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16901 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16902 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16903 #define STACK_TOP_MAX TASK_SIZE_MAX
16904
16905 #define INIT_THREAD { \
16906 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16907 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16908 }
16909
16910 #define INIT_TSS { \
16911 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16912 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16913 }
16914
16915 /*
16916 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16917 */
16918 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16919
16920 +#ifdef CONFIG_PAX_SEGMEXEC
16921 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16922 +#endif
16923 +
16924 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16925
16926 /* Get/set a process' ability to use the timestamp counter instruction */
16927 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16928 extern u16 amd_get_nb_id(int cpu);
16929
16930 struct aperfmperf {
16931 - u64 aperf, mperf;
16932 + u64 aperf __intentional_overflow(0);
16933 + u64 mperf __intentional_overflow(0);
16934 };
16935
16936 static inline void get_aperfmperf(struct aperfmperf *am)
16937 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16938 return ratio;
16939 }
16940
16941 -extern unsigned long arch_align_stack(unsigned long sp);
16942 +#define arch_align_stack(x) ((x) & ~0xfUL)
16943 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16944
16945 void default_idle(void);
16946 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16947 #define xen_set_default_idle 0
16948 #endif
16949
16950 -void stop_this_cpu(void *dummy);
16951 +void stop_this_cpu(void *dummy) __noreturn;
16952 void df_debug(struct pt_regs *regs, long error_code);
16953 #endif /* _ASM_X86_PROCESSOR_H */
16954 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16955 index 942a086..6c26446 100644
16956 --- a/arch/x86/include/asm/ptrace.h
16957 +++ b/arch/x86/include/asm/ptrace.h
16958 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16959 }
16960
16961 /*
16962 - * user_mode_vm(regs) determines whether a register set came from user mode.
16963 + * user_mode(regs) determines whether a register set came from user mode.
16964 * This is true if V8086 mode was enabled OR if the register set was from
16965 * protected mode with RPL-3 CS value. This tricky test checks that with
16966 * one comparison. Many places in the kernel can bypass this full check
16967 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16968 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16969 + * be used.
16970 */
16971 -static inline int user_mode(struct pt_regs *regs)
16972 +static inline int user_mode_novm(struct pt_regs *regs)
16973 {
16974 #ifdef CONFIG_X86_32
16975 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16976 #else
16977 - return !!(regs->cs & 3);
16978 + return !!(regs->cs & SEGMENT_RPL_MASK);
16979 #endif
16980 }
16981
16982 -static inline int user_mode_vm(struct pt_regs *regs)
16983 +static inline int user_mode(struct pt_regs *regs)
16984 {
16985 #ifdef CONFIG_X86_32
16986 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16987 USER_RPL;
16988 #else
16989 - return user_mode(regs);
16990 + return user_mode_novm(regs);
16991 #endif
16992 }
16993
16994 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
16995 #ifdef CONFIG_X86_64
16996 static inline bool user_64bit_mode(struct pt_regs *regs)
16997 {
16998 + unsigned long cs = regs->cs & 0xffff;
16999 #ifndef CONFIG_PARAVIRT
17000 /*
17001 * On non-paravirt systems, this is the only long mode CPL 3
17002 * selector. We do not allow long mode selectors in the LDT.
17003 */
17004 - return regs->cs == __USER_CS;
17005 + return cs == __USER_CS;
17006 #else
17007 /* Headers are too twisted for this to go in paravirt.h. */
17008 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17009 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17010 #endif
17011 }
17012
17013 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17014 * Traps from the kernel do not save sp and ss.
17015 * Use the helper function to retrieve sp.
17016 */
17017 - if (offset == offsetof(struct pt_regs, sp) &&
17018 - regs->cs == __KERNEL_CS)
17019 - return kernel_stack_pointer(regs);
17020 + if (offset == offsetof(struct pt_regs, sp)) {
17021 + unsigned long cs = regs->cs & 0xffff;
17022 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17023 + return kernel_stack_pointer(regs);
17024 + }
17025 #endif
17026 return *(unsigned long *)((unsigned long)regs + offset);
17027 }
17028 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17029 index 9c6b890..5305f53 100644
17030 --- a/arch/x86/include/asm/realmode.h
17031 +++ b/arch/x86/include/asm/realmode.h
17032 @@ -22,16 +22,14 @@ struct real_mode_header {
17033 #endif
17034 /* APM/BIOS reboot */
17035 u32 machine_real_restart_asm;
17036 -#ifdef CONFIG_X86_64
17037 u32 machine_real_restart_seg;
17038 -#endif
17039 };
17040
17041 /* This must match data at trampoline_32/64.S */
17042 struct trampoline_header {
17043 #ifdef CONFIG_X86_32
17044 u32 start;
17045 - u16 gdt_pad;
17046 + u16 boot_cs;
17047 u16 gdt_limit;
17048 u32 gdt_base;
17049 #else
17050 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17051 index a82c4f1..ac45053 100644
17052 --- a/arch/x86/include/asm/reboot.h
17053 +++ b/arch/x86/include/asm/reboot.h
17054 @@ -6,13 +6,13 @@
17055 struct pt_regs;
17056
17057 struct machine_ops {
17058 - void (*restart)(char *cmd);
17059 - void (*halt)(void);
17060 - void (*power_off)(void);
17061 + void (* __noreturn restart)(char *cmd);
17062 + void (* __noreturn halt)(void);
17063 + void (* __noreturn power_off)(void);
17064 void (*shutdown)(void);
17065 void (*crash_shutdown)(struct pt_regs *);
17066 - void (*emergency_restart)(void);
17067 -};
17068 + void (* __noreturn emergency_restart)(void);
17069 +} __no_const;
17070
17071 extern struct machine_ops machine_ops;
17072
17073 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17074 index cad82c9..2e5c5c1 100644
17075 --- a/arch/x86/include/asm/rwsem.h
17076 +++ b/arch/x86/include/asm/rwsem.h
17077 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17078 {
17079 asm volatile("# beginning down_read\n\t"
17080 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17081 +
17082 +#ifdef CONFIG_PAX_REFCOUNT
17083 + "jno 0f\n"
17084 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17085 + "int $4\n0:\n"
17086 + _ASM_EXTABLE(0b, 0b)
17087 +#endif
17088 +
17089 /* adds 0x00000001 */
17090 " jns 1f\n"
17091 " call call_rwsem_down_read_failed\n"
17092 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17093 "1:\n\t"
17094 " mov %1,%2\n\t"
17095 " add %3,%2\n\t"
17096 +
17097 +#ifdef CONFIG_PAX_REFCOUNT
17098 + "jno 0f\n"
17099 + "sub %3,%2\n"
17100 + "int $4\n0:\n"
17101 + _ASM_EXTABLE(0b, 0b)
17102 +#endif
17103 +
17104 " jle 2f\n\t"
17105 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17106 " jnz 1b\n\t"
17107 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17108 long tmp;
17109 asm volatile("# beginning down_write\n\t"
17110 LOCK_PREFIX " xadd %1,(%2)\n\t"
17111 +
17112 +#ifdef CONFIG_PAX_REFCOUNT
17113 + "jno 0f\n"
17114 + "mov %1,(%2)\n"
17115 + "int $4\n0:\n"
17116 + _ASM_EXTABLE(0b, 0b)
17117 +#endif
17118 +
17119 /* adds 0xffff0001, returns the old value */
17120 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17121 /* was the active mask 0 before? */
17122 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17123 long tmp;
17124 asm volatile("# beginning __up_read\n\t"
17125 LOCK_PREFIX " xadd %1,(%2)\n\t"
17126 +
17127 +#ifdef CONFIG_PAX_REFCOUNT
17128 + "jno 0f\n"
17129 + "mov %1,(%2)\n"
17130 + "int $4\n0:\n"
17131 + _ASM_EXTABLE(0b, 0b)
17132 +#endif
17133 +
17134 /* subtracts 1, returns the old value */
17135 " jns 1f\n\t"
17136 " call call_rwsem_wake\n" /* expects old value in %edx */
17137 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17138 long tmp;
17139 asm volatile("# beginning __up_write\n\t"
17140 LOCK_PREFIX " xadd %1,(%2)\n\t"
17141 +
17142 +#ifdef CONFIG_PAX_REFCOUNT
17143 + "jno 0f\n"
17144 + "mov %1,(%2)\n"
17145 + "int $4\n0:\n"
17146 + _ASM_EXTABLE(0b, 0b)
17147 +#endif
17148 +
17149 /* subtracts 0xffff0001, returns the old value */
17150 " jns 1f\n\t"
17151 " call call_rwsem_wake\n" /* expects old value in %edx */
17152 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17153 {
17154 asm volatile("# beginning __downgrade_write\n\t"
17155 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17156 +
17157 +#ifdef CONFIG_PAX_REFCOUNT
17158 + "jno 0f\n"
17159 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17160 + "int $4\n0:\n"
17161 + _ASM_EXTABLE(0b, 0b)
17162 +#endif
17163 +
17164 /*
17165 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17166 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17167 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17168 */
17169 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17170 {
17171 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17172 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17173 +
17174 +#ifdef CONFIG_PAX_REFCOUNT
17175 + "jno 0f\n"
17176 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17177 + "int $4\n0:\n"
17178 + _ASM_EXTABLE(0b, 0b)
17179 +#endif
17180 +
17181 : "+m" (sem->count)
17182 : "er" (delta));
17183 }
17184 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17185 */
17186 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17187 {
17188 - return delta + xadd(&sem->count, delta);
17189 + return delta + xadd_check_overflow(&sem->count, delta);
17190 }
17191
17192 #endif /* __KERNEL__ */
17193 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17194 index c48a950..bc40804 100644
17195 --- a/arch/x86/include/asm/segment.h
17196 +++ b/arch/x86/include/asm/segment.h
17197 @@ -64,10 +64,15 @@
17198 * 26 - ESPFIX small SS
17199 * 27 - per-cpu [ offset to per-cpu data area ]
17200 * 28 - stack_canary-20 [ for stack protector ]
17201 - * 29 - unused
17202 - * 30 - unused
17203 + * 29 - PCI BIOS CS
17204 + * 30 - PCI BIOS DS
17205 * 31 - TSS for double fault handler
17206 */
17207 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17208 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17209 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17210 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17211 +
17212 #define GDT_ENTRY_TLS_MIN 6
17213 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17214
17215 @@ -79,6 +84,8 @@
17216
17217 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17218
17219 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17220 +
17221 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17222
17223 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17224 @@ -104,6 +111,12 @@
17225 #define __KERNEL_STACK_CANARY 0
17226 #endif
17227
17228 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17229 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17230 +
17231 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17232 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17233 +
17234 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17235
17236 /*
17237 @@ -141,7 +154,7 @@
17238 */
17239
17240 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17241 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17242 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17243
17244
17245 #else
17246 @@ -165,6 +178,8 @@
17247 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17248 #define __USER32_DS __USER_DS
17249
17250 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17251 +
17252 #define GDT_ENTRY_TSS 8 /* needs two entries */
17253 #define GDT_ENTRY_LDT 10 /* needs two entries */
17254 #define GDT_ENTRY_TLS_MIN 12
17255 @@ -173,6 +188,8 @@
17256 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17257 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17258
17259 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17260 +
17261 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17262 #define FS_TLS 0
17263 #define GS_TLS 1
17264 @@ -180,12 +197,14 @@
17265 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17266 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17267
17268 -#define GDT_ENTRIES 16
17269 +#define GDT_ENTRIES 17
17270
17271 #endif
17272
17273 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17274 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17275 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17276 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17277 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17278 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17279 #ifndef CONFIG_PARAVIRT
17280 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17281 {
17282 unsigned long __limit;
17283 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17284 - return __limit + 1;
17285 + return __limit;
17286 }
17287
17288 #endif /* !__ASSEMBLY__ */
17289 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17290 index 8d3120f..352b440 100644
17291 --- a/arch/x86/include/asm/smap.h
17292 +++ b/arch/x86/include/asm/smap.h
17293 @@ -25,11 +25,40 @@
17294
17295 #include <asm/alternative-asm.h>
17296
17297 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17298 +#define ASM_PAX_OPEN_USERLAND \
17299 + 661: jmp 663f; \
17300 + .pushsection .altinstr_replacement, "a" ; \
17301 + 662: pushq %rax; nop; \
17302 + .popsection ; \
17303 + .pushsection .altinstructions, "a" ; \
17304 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17305 + .popsection ; \
17306 + call __pax_open_userland; \
17307 + popq %rax; \
17308 + 663:
17309 +
17310 +#define ASM_PAX_CLOSE_USERLAND \
17311 + 661: jmp 663f; \
17312 + .pushsection .altinstr_replacement, "a" ; \
17313 + 662: pushq %rax; nop; \
17314 + .popsection; \
17315 + .pushsection .altinstructions, "a" ; \
17316 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17317 + .popsection; \
17318 + call __pax_close_userland; \
17319 + popq %rax; \
17320 + 663:
17321 +#else
17322 +#define ASM_PAX_OPEN_USERLAND
17323 +#define ASM_PAX_CLOSE_USERLAND
17324 +#endif
17325 +
17326 #ifdef CONFIG_X86_SMAP
17327
17328 #define ASM_CLAC \
17329 661: ASM_NOP3 ; \
17330 - .pushsection .altinstr_replacement, "ax" ; \
17331 + .pushsection .altinstr_replacement, "a" ; \
17332 662: __ASM_CLAC ; \
17333 .popsection ; \
17334 .pushsection .altinstructions, "a" ; \
17335 @@ -38,7 +67,7 @@
17336
17337 #define ASM_STAC \
17338 661: ASM_NOP3 ; \
17339 - .pushsection .altinstr_replacement, "ax" ; \
17340 + .pushsection .altinstr_replacement, "a" ; \
17341 662: __ASM_STAC ; \
17342 .popsection ; \
17343 .pushsection .altinstructions, "a" ; \
17344 @@ -56,6 +85,37 @@
17345
17346 #include <asm/alternative.h>
17347
17348 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17349 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17350 +
17351 +extern void __pax_open_userland(void);
17352 +static __always_inline unsigned long pax_open_userland(void)
17353 +{
17354 +
17355 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17356 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17357 + :
17358 + : [open] "i" (__pax_open_userland)
17359 + : "memory", "rax");
17360 +#endif
17361 +
17362 + return 0;
17363 +}
17364 +
17365 +extern void __pax_close_userland(void);
17366 +static __always_inline unsigned long pax_close_userland(void)
17367 +{
17368 +
17369 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17370 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17371 + :
17372 + : [close] "i" (__pax_close_userland)
17373 + : "memory", "rax");
17374 +#endif
17375 +
17376 + return 0;
17377 +}
17378 +
17379 #ifdef CONFIG_X86_SMAP
17380
17381 static __always_inline void clac(void)
17382 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17383 index 4137890..03fa172 100644
17384 --- a/arch/x86/include/asm/smp.h
17385 +++ b/arch/x86/include/asm/smp.h
17386 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17387 /* cpus sharing the last level cache: */
17388 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17389 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17390 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17391 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17392
17393 static inline struct cpumask *cpu_sibling_mask(int cpu)
17394 {
17395 @@ -79,7 +79,7 @@ struct smp_ops {
17396
17397 void (*send_call_func_ipi)(const struct cpumask *mask);
17398 void (*send_call_func_single_ipi)(int cpu);
17399 -};
17400 +} __no_const;
17401
17402 /* Globals due to paravirt */
17403 extern void set_cpu_sibling_map(int cpu);
17404 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17405 extern int safe_smp_processor_id(void);
17406
17407 #elif defined(CONFIG_X86_64_SMP)
17408 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17409 -
17410 -#define stack_smp_processor_id() \
17411 -({ \
17412 - struct thread_info *ti; \
17413 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17414 - ti->cpu; \
17415 -})
17416 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17417 +#define stack_smp_processor_id() raw_smp_processor_id()
17418 #define safe_smp_processor_id() smp_processor_id()
17419
17420 #endif
17421 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17422 index e3ddd7d..3611fce 100644
17423 --- a/arch/x86/include/asm/spinlock.h
17424 +++ b/arch/x86/include/asm/spinlock.h
17425 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17426 static inline void arch_read_lock(arch_rwlock_t *rw)
17427 {
17428 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17429 +
17430 +#ifdef CONFIG_PAX_REFCOUNT
17431 + "jno 0f\n"
17432 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17433 + "int $4\n0:\n"
17434 + _ASM_EXTABLE(0b, 0b)
17435 +#endif
17436 +
17437 "jns 1f\n"
17438 "call __read_lock_failed\n\t"
17439 "1:\n"
17440 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17441 static inline void arch_write_lock(arch_rwlock_t *rw)
17442 {
17443 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17444 +
17445 +#ifdef CONFIG_PAX_REFCOUNT
17446 + "jno 0f\n"
17447 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17448 + "int $4\n0:\n"
17449 + _ASM_EXTABLE(0b, 0b)
17450 +#endif
17451 +
17452 "jz 1f\n"
17453 "call __write_lock_failed\n\t"
17454 "1:\n"
17455 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17456
17457 static inline void arch_read_unlock(arch_rwlock_t *rw)
17458 {
17459 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17460 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17461 +
17462 +#ifdef CONFIG_PAX_REFCOUNT
17463 + "jno 0f\n"
17464 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17465 + "int $4\n0:\n"
17466 + _ASM_EXTABLE(0b, 0b)
17467 +#endif
17468 +
17469 :"+m" (rw->lock) : : "memory");
17470 }
17471
17472 static inline void arch_write_unlock(arch_rwlock_t *rw)
17473 {
17474 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17475 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17476 +
17477 +#ifdef CONFIG_PAX_REFCOUNT
17478 + "jno 0f\n"
17479 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17480 + "int $4\n0:\n"
17481 + _ASM_EXTABLE(0b, 0b)
17482 +#endif
17483 +
17484 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17485 }
17486
17487 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17488 index 6a99859..03cb807 100644
17489 --- a/arch/x86/include/asm/stackprotector.h
17490 +++ b/arch/x86/include/asm/stackprotector.h
17491 @@ -47,7 +47,7 @@
17492 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17493 */
17494 #define GDT_STACK_CANARY_INIT \
17495 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17496 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17497
17498 /*
17499 * Initialize the stackprotector canary value.
17500 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17501
17502 static inline void load_stack_canary_segment(void)
17503 {
17504 -#ifdef CONFIG_X86_32
17505 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17506 asm volatile ("mov %0, %%gs" : : "r" (0));
17507 #endif
17508 }
17509 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17510 index 70bbe39..4ae2bd4 100644
17511 --- a/arch/x86/include/asm/stacktrace.h
17512 +++ b/arch/x86/include/asm/stacktrace.h
17513 @@ -11,28 +11,20 @@
17514
17515 extern int kstack_depth_to_print;
17516
17517 -struct thread_info;
17518 +struct task_struct;
17519 struct stacktrace_ops;
17520
17521 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17522 - unsigned long *stack,
17523 - unsigned long bp,
17524 - const struct stacktrace_ops *ops,
17525 - void *data,
17526 - unsigned long *end,
17527 - int *graph);
17528 +typedef unsigned long walk_stack_t(struct task_struct *task,
17529 + void *stack_start,
17530 + unsigned long *stack,
17531 + unsigned long bp,
17532 + const struct stacktrace_ops *ops,
17533 + void *data,
17534 + unsigned long *end,
17535 + int *graph);
17536
17537 -extern unsigned long
17538 -print_context_stack(struct thread_info *tinfo,
17539 - unsigned long *stack, unsigned long bp,
17540 - const struct stacktrace_ops *ops, void *data,
17541 - unsigned long *end, int *graph);
17542 -
17543 -extern unsigned long
17544 -print_context_stack_bp(struct thread_info *tinfo,
17545 - unsigned long *stack, unsigned long bp,
17546 - const struct stacktrace_ops *ops, void *data,
17547 - unsigned long *end, int *graph);
17548 +extern walk_stack_t print_context_stack;
17549 +extern walk_stack_t print_context_stack_bp;
17550
17551 /* Generic stack tracer with callbacks */
17552
17553 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17554 void (*address)(void *data, unsigned long address, int reliable);
17555 /* On negative return stop dumping */
17556 int (*stack)(void *data, char *name);
17557 - walk_stack_t walk_stack;
17558 + walk_stack_t *walk_stack;
17559 };
17560
17561 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17562 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17563 index 4ec45b3..a4f0a8a 100644
17564 --- a/arch/x86/include/asm/switch_to.h
17565 +++ b/arch/x86/include/asm/switch_to.h
17566 @@ -108,7 +108,7 @@ do { \
17567 "call __switch_to\n\t" \
17568 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17569 __switch_canary \
17570 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17571 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17572 "movq %%rax,%%rdi\n\t" \
17573 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17574 "jnz ret_from_fork\n\t" \
17575 @@ -119,7 +119,7 @@ do { \
17576 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17577 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17578 [_tif_fork] "i" (_TIF_FORK), \
17579 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17580 + [thread_info] "m" (current_tinfo), \
17581 [current_task] "m" (current_task) \
17582 __switch_canary_iparam \
17583 : "memory", "cc" __EXTRA_CLOBBER)
17584 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17585 index 2781119..618b59b 100644
17586 --- a/arch/x86/include/asm/thread_info.h
17587 +++ b/arch/x86/include/asm/thread_info.h
17588 @@ -10,6 +10,7 @@
17589 #include <linux/compiler.h>
17590 #include <asm/page.h>
17591 #include <asm/types.h>
17592 +#include <asm/percpu.h>
17593
17594 /*
17595 * low level task data that entry.S needs immediate access to
17596 @@ -23,7 +24,6 @@ struct exec_domain;
17597 #include <linux/atomic.h>
17598
17599 struct thread_info {
17600 - struct task_struct *task; /* main task structure */
17601 struct exec_domain *exec_domain; /* execution domain */
17602 __u32 flags; /* low level flags */
17603 __u32 status; /* thread synchronous flags */
17604 @@ -33,19 +33,13 @@ struct thread_info {
17605 mm_segment_t addr_limit;
17606 struct restart_block restart_block;
17607 void __user *sysenter_return;
17608 -#ifdef CONFIG_X86_32
17609 - unsigned long previous_esp; /* ESP of the previous stack in
17610 - case of nested (IRQ) stacks
17611 - */
17612 - __u8 supervisor_stack[0];
17613 -#endif
17614 + unsigned long lowest_stack;
17615 unsigned int sig_on_uaccess_error:1;
17616 unsigned int uaccess_err:1; /* uaccess failed */
17617 };
17618
17619 -#define INIT_THREAD_INFO(tsk) \
17620 +#define INIT_THREAD_INFO \
17621 { \
17622 - .task = &tsk, \
17623 .exec_domain = &default_exec_domain, \
17624 .flags = 0, \
17625 .cpu = 0, \
17626 @@ -56,7 +50,7 @@ struct thread_info {
17627 }, \
17628 }
17629
17630 -#define init_thread_info (init_thread_union.thread_info)
17631 +#define init_thread_info (init_thread_union.stack)
17632 #define init_stack (init_thread_union.stack)
17633
17634 #else /* !__ASSEMBLY__ */
17635 @@ -96,6 +90,7 @@ struct thread_info {
17636 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17637 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17638 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17639 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17640
17641 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17642 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17643 @@ -119,17 +114,18 @@ struct thread_info {
17644 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17645 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17646 #define _TIF_X32 (1 << TIF_X32)
17647 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17648
17649 /* work to do in syscall_trace_enter() */
17650 #define _TIF_WORK_SYSCALL_ENTRY \
17651 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17652 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17653 - _TIF_NOHZ)
17654 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17655
17656 /* work to do in syscall_trace_leave() */
17657 #define _TIF_WORK_SYSCALL_EXIT \
17658 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17659 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17660 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17661
17662 /* work to do on interrupt/exception return */
17663 #define _TIF_WORK_MASK \
17664 @@ -140,7 +136,7 @@ struct thread_info {
17665 /* work to do on any return to user space */
17666 #define _TIF_ALLWORK_MASK \
17667 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17668 - _TIF_NOHZ)
17669 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17670
17671 /* Only used for 64 bit */
17672 #define _TIF_DO_NOTIFY_MASK \
17673 @@ -156,45 +152,40 @@ struct thread_info {
17674
17675 #define PREEMPT_ACTIVE 0x10000000
17676
17677 -#ifdef CONFIG_X86_32
17678 -
17679 -#define STACK_WARN (THREAD_SIZE/8)
17680 -/*
17681 - * macros/functions for gaining access to the thread information structure
17682 - *
17683 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17684 - */
17685 -#ifndef __ASSEMBLY__
17686 -
17687 -
17688 -/* how to get the current stack pointer from C */
17689 -register unsigned long current_stack_pointer asm("esp") __used;
17690 -
17691 -/* how to get the thread information struct from C */
17692 -static inline struct thread_info *current_thread_info(void)
17693 -{
17694 - return (struct thread_info *)
17695 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17696 -}
17697 -
17698 -#else /* !__ASSEMBLY__ */
17699 -
17700 +#ifdef __ASSEMBLY__
17701 /* how to get the thread information struct from ASM */
17702 #define GET_THREAD_INFO(reg) \
17703 - movl $-THREAD_SIZE, reg; \
17704 - andl %esp, reg
17705 + mov PER_CPU_VAR(current_tinfo), reg
17706
17707 /* use this one if reg already contains %esp */
17708 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17709 - andl $-THREAD_SIZE, reg
17710 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17711 +#else
17712 +/* how to get the thread information struct from C */
17713 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17714 +
17715 +static __always_inline struct thread_info *current_thread_info(void)
17716 +{
17717 + return this_cpu_read_stable(current_tinfo);
17718 +}
17719 +#endif
17720 +
17721 +#ifdef CONFIG_X86_32
17722 +
17723 +#define STACK_WARN (THREAD_SIZE/8)
17724 +/*
17725 + * macros/functions for gaining access to the thread information structure
17726 + *
17727 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17728 + */
17729 +#ifndef __ASSEMBLY__
17730 +
17731 +/* how to get the current stack pointer from C */
17732 +register unsigned long current_stack_pointer asm("esp") __used;
17733
17734 #endif
17735
17736 #else /* X86_32 */
17737
17738 -#include <asm/percpu.h>
17739 -#define KERNEL_STACK_OFFSET (5*8)
17740 -
17741 /*
17742 * macros/functions for gaining access to the thread information structure
17743 * preempt_count needs to be 1 initially, until the scheduler is functional.
17744 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17745 #ifndef __ASSEMBLY__
17746 DECLARE_PER_CPU(unsigned long, kernel_stack);
17747
17748 -static inline struct thread_info *current_thread_info(void)
17749 -{
17750 - struct thread_info *ti;
17751 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17752 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17753 - return ti;
17754 -}
17755 -
17756 -#else /* !__ASSEMBLY__ */
17757 -
17758 -/* how to get the thread information struct from ASM */
17759 -#define GET_THREAD_INFO(reg) \
17760 - movq PER_CPU_VAR(kernel_stack),reg ; \
17761 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17762 -
17763 -/*
17764 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17765 - * a certain register (to be used in assembler memory operands).
17766 - */
17767 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17768 -
17769 +/* how to get the current stack pointer from C */
17770 +register unsigned long current_stack_pointer asm("rsp") __used;
17771 #endif
17772
17773 #endif /* !X86_32 */
17774 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17775 extern void arch_task_cache_init(void);
17776 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17777 extern void arch_release_task_struct(struct task_struct *tsk);
17778 +
17779 +#define __HAVE_THREAD_FUNCTIONS
17780 +#define task_thread_info(task) (&(task)->tinfo)
17781 +#define task_stack_page(task) ((task)->stack)
17782 +#define setup_thread_stack(p, org) do {} while (0)
17783 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17784 +
17785 #endif
17786 #endif /* _ASM_X86_THREAD_INFO_H */
17787 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17788 index cf51200..63ff068 100644
17789 --- a/arch/x86/include/asm/tlbflush.h
17790 +++ b/arch/x86/include/asm/tlbflush.h
17791 @@ -17,18 +17,44 @@
17792
17793 static inline void __native_flush_tlb(void)
17794 {
17795 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17796 + u64 descriptor[2];
17797 +
17798 + descriptor[0] = PCID_KERNEL;
17799 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17800 + return;
17801 + }
17802 +
17803 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17804 + if (static_cpu_has(X86_FEATURE_PCID)) {
17805 + unsigned int cpu = raw_get_cpu();
17806 +
17807 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17808 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17809 + raw_put_cpu_no_resched();
17810 + return;
17811 + }
17812 +#endif
17813 +
17814 native_write_cr3(native_read_cr3());
17815 }
17816
17817 static inline void __native_flush_tlb_global_irq_disabled(void)
17818 {
17819 - unsigned long cr4;
17820 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17821 + u64 descriptor[2];
17822
17823 - cr4 = native_read_cr4();
17824 - /* clear PGE */
17825 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17826 - /* write old PGE again and flush TLBs */
17827 - native_write_cr4(cr4);
17828 + descriptor[0] = PCID_KERNEL;
17829 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17830 + } else {
17831 + unsigned long cr4;
17832 +
17833 + cr4 = native_read_cr4();
17834 + /* clear PGE */
17835 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17836 + /* write old PGE again and flush TLBs */
17837 + native_write_cr4(cr4);
17838 + }
17839 }
17840
17841 static inline void __native_flush_tlb_global(void)
17842 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17843
17844 static inline void __native_flush_tlb_single(unsigned long addr)
17845 {
17846 +
17847 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17848 + u64 descriptor[2];
17849 +
17850 + descriptor[0] = PCID_KERNEL;
17851 + descriptor[1] = addr;
17852 +
17853 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17854 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17855 + if (addr < TASK_SIZE_MAX)
17856 + descriptor[1] += pax_user_shadow_base;
17857 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17858 + }
17859 +
17860 + descriptor[0] = PCID_USER;
17861 + descriptor[1] = addr;
17862 +#endif
17863 +
17864 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17865 + return;
17866 + }
17867 +
17868 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17869 + if (static_cpu_has(X86_FEATURE_PCID)) {
17870 + unsigned int cpu = raw_get_cpu();
17871 +
17872 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17873 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17874 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17875 + raw_put_cpu_no_resched();
17876 +
17877 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17878 + addr += pax_user_shadow_base;
17879 + }
17880 +#endif
17881 +
17882 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17883 }
17884
17885 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17886 index 5ee2687..74590b9 100644
17887 --- a/arch/x86/include/asm/uaccess.h
17888 +++ b/arch/x86/include/asm/uaccess.h
17889 @@ -7,6 +7,7 @@
17890 #include <linux/compiler.h>
17891 #include <linux/thread_info.h>
17892 #include <linux/string.h>
17893 +#include <linux/sched.h>
17894 #include <asm/asm.h>
17895 #include <asm/page.h>
17896 #include <asm/smap.h>
17897 @@ -29,7 +30,12 @@
17898
17899 #define get_ds() (KERNEL_DS)
17900 #define get_fs() (current_thread_info()->addr_limit)
17901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17902 +void __set_fs(mm_segment_t x);
17903 +void set_fs(mm_segment_t x);
17904 +#else
17905 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17906 +#endif
17907
17908 #define segment_eq(a, b) ((a).seg == (b).seg)
17909
17910 @@ -77,8 +83,33 @@
17911 * checks that the pointer is in the user space range - after calling
17912 * this function, memory access functions may still return -EFAULT.
17913 */
17914 -#define access_ok(type, addr, size) \
17915 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17916 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17917 +#define access_ok(type, addr, size) \
17918 +({ \
17919 + long __size = size; \
17920 + unsigned long __addr = (unsigned long)addr; \
17921 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17922 + unsigned long __end_ao = __addr + __size - 1; \
17923 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17924 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17925 + while(__addr_ao <= __end_ao) { \
17926 + char __c_ao; \
17927 + __addr_ao += PAGE_SIZE; \
17928 + if (__size > PAGE_SIZE) \
17929 + cond_resched(); \
17930 + if (__get_user(__c_ao, (char __user *)__addr)) \
17931 + break; \
17932 + if (type != VERIFY_WRITE) { \
17933 + __addr = __addr_ao; \
17934 + continue; \
17935 + } \
17936 + if (__put_user(__c_ao, (char __user *)__addr)) \
17937 + break; \
17938 + __addr = __addr_ao; \
17939 + } \
17940 + } \
17941 + __ret_ao; \
17942 +})
17943
17944 /*
17945 * The exception table consists of pairs of addresses relative to the
17946 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17947 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17948 __chk_user_ptr(ptr); \
17949 might_fault(); \
17950 + pax_open_userland(); \
17951 asm volatile("call __get_user_%P3" \
17952 : "=a" (__ret_gu), "=r" (__val_gu) \
17953 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17954 (x) = (__typeof__(*(ptr))) __val_gu; \
17955 + pax_close_userland(); \
17956 __ret_gu; \
17957 })
17958
17959 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17960 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17961 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17962
17963 -
17964 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17965 +#define __copyuser_seg "gs;"
17966 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17967 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17968 +#else
17969 +#define __copyuser_seg
17970 +#define __COPYUSER_SET_ES
17971 +#define __COPYUSER_RESTORE_ES
17972 +#endif
17973
17974 #ifdef CONFIG_X86_32
17975 #define __put_user_asm_u64(x, addr, err, errret) \
17976 asm volatile(ASM_STAC "\n" \
17977 - "1: movl %%eax,0(%2)\n" \
17978 - "2: movl %%edx,4(%2)\n" \
17979 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17980 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17981 "3: " ASM_CLAC "\n" \
17982 ".section .fixup,\"ax\"\n" \
17983 "4: movl %3,%0\n" \
17984 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17985
17986 #define __put_user_asm_ex_u64(x, addr) \
17987 asm volatile(ASM_STAC "\n" \
17988 - "1: movl %%eax,0(%1)\n" \
17989 - "2: movl %%edx,4(%1)\n" \
17990 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17991 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
17992 "3: " ASM_CLAC "\n" \
17993 _ASM_EXTABLE_EX(1b, 2b) \
17994 _ASM_EXTABLE_EX(2b, 3b) \
17995 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
17996 __typeof__(*(ptr)) __pu_val; \
17997 __chk_user_ptr(ptr); \
17998 might_fault(); \
17999 - __pu_val = x; \
18000 + __pu_val = (x); \
18001 + pax_open_userland(); \
18002 switch (sizeof(*(ptr))) { \
18003 case 1: \
18004 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18005 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18006 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18007 break; \
18008 } \
18009 + pax_close_userland(); \
18010 __ret_pu; \
18011 })
18012
18013 @@ -344,8 +387,10 @@ do { \
18014 } while (0)
18015
18016 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18017 +do { \
18018 + pax_open_userland(); \
18019 asm volatile(ASM_STAC "\n" \
18020 - "1: mov"itype" %2,%"rtype"1\n" \
18021 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18022 "2: " ASM_CLAC "\n" \
18023 ".section .fixup,\"ax\"\n" \
18024 "3: mov %3,%0\n" \
18025 @@ -353,8 +398,10 @@ do { \
18026 " jmp 2b\n" \
18027 ".previous\n" \
18028 _ASM_EXTABLE(1b, 3b) \
18029 - : "=r" (err), ltype(x) \
18030 - : "m" (__m(addr)), "i" (errret), "0" (err))
18031 + : "=r" (err), ltype (x) \
18032 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18033 + pax_close_userland(); \
18034 +} while (0)
18035
18036 #define __get_user_size_ex(x, ptr, size) \
18037 do { \
18038 @@ -378,7 +425,7 @@ do { \
18039 } while (0)
18040
18041 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18042 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18043 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18044 "2:\n" \
18045 _ASM_EXTABLE_EX(1b, 2b) \
18046 : ltype(x) : "m" (__m(addr)))
18047 @@ -395,13 +442,24 @@ do { \
18048 int __gu_err; \
18049 unsigned long __gu_val; \
18050 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18051 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18052 + (x) = (__typeof__(*(ptr)))__gu_val; \
18053 __gu_err; \
18054 })
18055
18056 /* FIXME: this hack is definitely wrong -AK */
18057 struct __large_struct { unsigned long buf[100]; };
18058 -#define __m(x) (*(struct __large_struct __user *)(x))
18059 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18060 +#define ____m(x) \
18061 +({ \
18062 + unsigned long ____x = (unsigned long)(x); \
18063 + if (____x < pax_user_shadow_base) \
18064 + ____x += pax_user_shadow_base; \
18065 + (typeof(x))____x; \
18066 +})
18067 +#else
18068 +#define ____m(x) (x)
18069 +#endif
18070 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18071
18072 /*
18073 * Tell gcc we read from memory instead of writing: this is because
18074 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18075 * aliasing issues.
18076 */
18077 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18078 +do { \
18079 + pax_open_userland(); \
18080 asm volatile(ASM_STAC "\n" \
18081 - "1: mov"itype" %"rtype"1,%2\n" \
18082 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18083 "2: " ASM_CLAC "\n" \
18084 ".section .fixup,\"ax\"\n" \
18085 "3: mov %3,%0\n" \
18086 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18087 ".previous\n" \
18088 _ASM_EXTABLE(1b, 3b) \
18089 : "=r"(err) \
18090 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18091 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18092 + pax_close_userland(); \
18093 +} while (0)
18094
18095 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18096 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18097 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18098 "2:\n" \
18099 _ASM_EXTABLE_EX(1b, 2b) \
18100 : : ltype(x), "m" (__m(addr)))
18101 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18102 */
18103 #define uaccess_try do { \
18104 current_thread_info()->uaccess_err = 0; \
18105 + pax_open_userland(); \
18106 stac(); \
18107 barrier();
18108
18109 #define uaccess_catch(err) \
18110 clac(); \
18111 + pax_close_userland(); \
18112 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18113 } while (0)
18114
18115 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18116 * On error, the variable @x is set to zero.
18117 */
18118
18119 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18120 +#define __get_user(x, ptr) get_user((x), (ptr))
18121 +#else
18122 #define __get_user(x, ptr) \
18123 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18124 +#endif
18125
18126 /**
18127 * __put_user: - Write a simple value into user space, with less checking.
18128 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18129 * Returns zero on success, or -EFAULT on error.
18130 */
18131
18132 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18133 +#define __put_user(x, ptr) put_user((x), (ptr))
18134 +#else
18135 #define __put_user(x, ptr) \
18136 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18137 +#endif
18138
18139 #define __get_user_unaligned __get_user
18140 #define __put_user_unaligned __put_user
18141 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18142 #define get_user_ex(x, ptr) do { \
18143 unsigned long __gue_val; \
18144 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18145 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18146 + (x) = (__typeof__(*(ptr)))__gue_val; \
18147 } while (0)
18148
18149 #define put_user_try uaccess_try
18150 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18151 extern __must_check long strlen_user(const char __user *str);
18152 extern __must_check long strnlen_user(const char __user *str, long n);
18153
18154 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18155 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18156 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18157 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18158
18159 /*
18160 * movsl can be slow when source and dest are not both 8-byte aligned
18161 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18162 index 7f760a9..04b1c65 100644
18163 --- a/arch/x86/include/asm/uaccess_32.h
18164 +++ b/arch/x86/include/asm/uaccess_32.h
18165 @@ -11,15 +11,15 @@
18166 #include <asm/page.h>
18167
18168 unsigned long __must_check __copy_to_user_ll
18169 - (void __user *to, const void *from, unsigned long n);
18170 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18171 unsigned long __must_check __copy_from_user_ll
18172 - (void *to, const void __user *from, unsigned long n);
18173 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18174 unsigned long __must_check __copy_from_user_ll_nozero
18175 - (void *to, const void __user *from, unsigned long n);
18176 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18177 unsigned long __must_check __copy_from_user_ll_nocache
18178 - (void *to, const void __user *from, unsigned long n);
18179 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18180 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18181 - (void *to, const void __user *from, unsigned long n);
18182 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18183
18184 /**
18185 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18186 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18187 static __always_inline unsigned long __must_check
18188 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18189 {
18190 + if ((long)n < 0)
18191 + return n;
18192 +
18193 + check_object_size(from, n, true);
18194 +
18195 if (__builtin_constant_p(n)) {
18196 unsigned long ret;
18197
18198 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18199 __copy_to_user(void __user *to, const void *from, unsigned long n)
18200 {
18201 might_fault();
18202 +
18203 return __copy_to_user_inatomic(to, from, n);
18204 }
18205
18206 static __always_inline unsigned long
18207 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18208 {
18209 + if ((long)n < 0)
18210 + return n;
18211 +
18212 /* Avoid zeroing the tail if the copy fails..
18213 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18214 * but as the zeroing behaviour is only significant when n is not
18215 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18216 __copy_from_user(void *to, const void __user *from, unsigned long n)
18217 {
18218 might_fault();
18219 +
18220 + if ((long)n < 0)
18221 + return n;
18222 +
18223 + check_object_size(to, n, false);
18224 +
18225 if (__builtin_constant_p(n)) {
18226 unsigned long ret;
18227
18228 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18229 const void __user *from, unsigned long n)
18230 {
18231 might_fault();
18232 +
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 if (__builtin_constant_p(n)) {
18237 unsigned long ret;
18238
18239 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18240 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18241 unsigned long n)
18242 {
18243 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18248 }
18249
18250 -unsigned long __must_check copy_to_user(void __user *to,
18251 - const void *from, unsigned long n);
18252 -unsigned long __must_check _copy_from_user(void *to,
18253 - const void __user *from,
18254 - unsigned long n);
18255 -
18256 +extern void copy_to_user_overflow(void)
18257 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18258 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18259 +#else
18260 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18261 +#endif
18262 +;
18263
18264 extern void copy_from_user_overflow(void)
18265 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18267 #endif
18268 ;
18269
18270 -static inline unsigned long __must_check copy_from_user(void *to,
18271 - const void __user *from,
18272 - unsigned long n)
18273 +/**
18274 + * copy_to_user: - Copy a block of data into user space.
18275 + * @to: Destination address, in user space.
18276 + * @from: Source address, in kernel space.
18277 + * @n: Number of bytes to copy.
18278 + *
18279 + * Context: User context only. This function may sleep.
18280 + *
18281 + * Copy data from kernel space to user space.
18282 + *
18283 + * Returns number of bytes that could not be copied.
18284 + * On success, this will be zero.
18285 + */
18286 +static inline unsigned long __must_check
18287 +copy_to_user(void __user *to, const void *from, unsigned long n)
18288 {
18289 - int sz = __compiletime_object_size(to);
18290 + size_t sz = __compiletime_object_size(from);
18291
18292 - if (likely(sz == -1 || sz >= n))
18293 - n = _copy_from_user(to, from, n);
18294 - else
18295 + if (unlikely(sz != (size_t)-1 && sz < n))
18296 + copy_to_user_overflow();
18297 + else if (access_ok(VERIFY_WRITE, to, n))
18298 + n = __copy_to_user(to, from, n);
18299 + return n;
18300 +}
18301 +
18302 +/**
18303 + * copy_from_user: - Copy a block of data from user space.
18304 + * @to: Destination address, in kernel space.
18305 + * @from: Source address, in user space.
18306 + * @n: Number of bytes to copy.
18307 + *
18308 + * Context: User context only. This function may sleep.
18309 + *
18310 + * Copy data from user space to kernel space.
18311 + *
18312 + * Returns number of bytes that could not be copied.
18313 + * On success, this will be zero.
18314 + *
18315 + * If some data could not be copied, this function will pad the copied
18316 + * data to the requested size using zero bytes.
18317 + */
18318 +static inline unsigned long __must_check
18319 +copy_from_user(void *to, const void __user *from, unsigned long n)
18320 +{
18321 + size_t sz = __compiletime_object_size(to);
18322 +
18323 + check_object_size(to, n, false);
18324 +
18325 + if (unlikely(sz != (size_t)-1 && sz < n))
18326 copy_from_user_overflow();
18327 -
18328 + else if (access_ok(VERIFY_READ, from, n))
18329 + n = __copy_from_user(to, from, n);
18330 + else if ((long)n > 0)
18331 + memset(to, 0, n);
18332 return n;
18333 }
18334
18335 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18336 index 4f7923d..20cb24e 100644
18337 --- a/arch/x86/include/asm/uaccess_64.h
18338 +++ b/arch/x86/include/asm/uaccess_64.h
18339 @@ -10,6 +10,9 @@
18340 #include <asm/alternative.h>
18341 #include <asm/cpufeature.h>
18342 #include <asm/page.h>
18343 +#include <asm/pgtable.h>
18344 +
18345 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18346
18347 /*
18348 * Copy To/From Userspace
18349 @@ -17,13 +20,13 @@
18350
18351 /* Handles exceptions in both to and from, but doesn't do access_ok */
18352 __must_check unsigned long
18353 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18354 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18355 __must_check unsigned long
18356 -copy_user_generic_string(void *to, const void *from, unsigned len);
18357 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18358 __must_check unsigned long
18359 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18360 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18361
18362 -static __always_inline __must_check unsigned long
18363 +static __always_inline __must_check __size_overflow(3) unsigned long
18364 copy_user_generic(void *to, const void *from, unsigned len)
18365 {
18366 unsigned ret;
18367 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
18368 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
18369 "=d" (len)),
18370 "1" (to), "2" (from), "3" (len)
18371 - : "memory", "rcx", "r8", "r9", "r10", "r11");
18372 + : "memory", "rcx", "r8", "r9", "r11");
18373 return ret;
18374 }
18375
18376 +static __always_inline __must_check unsigned long
18377 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18378 +static __always_inline __must_check unsigned long
18379 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18380 __must_check unsigned long
18381 -_copy_to_user(void __user *to, const void *from, unsigned len);
18382 -__must_check unsigned long
18383 -_copy_from_user(void *to, const void __user *from, unsigned len);
18384 -__must_check unsigned long
18385 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18386 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18387 +
18388 +extern void copy_to_user_overflow(void)
18389 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18390 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18391 +#else
18392 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18393 +#endif
18394 +;
18395 +
18396 +extern void copy_from_user_overflow(void)
18397 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18398 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18399 +#else
18400 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18401 +#endif
18402 +;
18403
18404 static inline unsigned long __must_check copy_from_user(void *to,
18405 const void __user *from,
18406 unsigned long n)
18407 {
18408 - int sz = __compiletime_object_size(to);
18409 -
18410 might_fault();
18411 - if (likely(sz == -1 || sz >= n))
18412 - n = _copy_from_user(to, from, n);
18413 -#ifdef CONFIG_DEBUG_VM
18414 - else
18415 - WARN(1, "Buffer overflow detected!\n");
18416 -#endif
18417 +
18418 + check_object_size(to, n, false);
18419 +
18420 + if (access_ok(VERIFY_READ, from, n))
18421 + n = __copy_from_user(to, from, n);
18422 + else if (n < INT_MAX)
18423 + memset(to, 0, n);
18424 return n;
18425 }
18426
18427 static __always_inline __must_check
18428 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18429 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18430 {
18431 might_fault();
18432
18433 - return _copy_to_user(dst, src, size);
18434 + if (access_ok(VERIFY_WRITE, dst, size))
18435 + size = __copy_to_user(dst, src, size);
18436 + return size;
18437 }
18438
18439 static __always_inline __must_check
18440 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18441 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18442 {
18443 - int ret = 0;
18444 + size_t sz = __compiletime_object_size(dst);
18445 + unsigned ret = 0;
18446
18447 might_fault();
18448 +
18449 + if (size > INT_MAX)
18450 + return size;
18451 +
18452 + check_object_size(dst, size, false);
18453 +
18454 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18455 + if (!__access_ok(VERIFY_READ, src, size))
18456 + return size;
18457 +#endif
18458 +
18459 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18460 + copy_from_user_overflow();
18461 + return size;
18462 + }
18463 +
18464 if (!__builtin_constant_p(size))
18465 - return copy_user_generic(dst, (__force void *)src, size);
18466 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18467 switch (size) {
18468 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18469 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18470 ret, "b", "b", "=q", 1);
18471 return ret;
18472 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18473 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18474 ret, "w", "w", "=r", 2);
18475 return ret;
18476 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18477 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18478 ret, "l", "k", "=r", 4);
18479 return ret;
18480 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18481 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18482 ret, "q", "", "=r", 8);
18483 return ret;
18484 case 10:
18485 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18486 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18487 ret, "q", "", "=r", 10);
18488 if (unlikely(ret))
18489 return ret;
18490 __get_user_asm(*(u16 *)(8 + (char *)dst),
18491 - (u16 __user *)(8 + (char __user *)src),
18492 + (const u16 __user *)(8 + (const char __user *)src),
18493 ret, "w", "w", "=r", 2);
18494 return ret;
18495 case 16:
18496 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18497 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18498 ret, "q", "", "=r", 16);
18499 if (unlikely(ret))
18500 return ret;
18501 __get_user_asm(*(u64 *)(8 + (char *)dst),
18502 - (u64 __user *)(8 + (char __user *)src),
18503 + (const u64 __user *)(8 + (const char __user *)src),
18504 ret, "q", "", "=r", 8);
18505 return ret;
18506 default:
18507 - return copy_user_generic(dst, (__force void *)src, size);
18508 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18509 }
18510 }
18511
18512 static __always_inline __must_check
18513 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18514 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18515 {
18516 - int ret = 0;
18517 + size_t sz = __compiletime_object_size(src);
18518 + unsigned ret = 0;
18519
18520 might_fault();
18521 +
18522 + if (size > INT_MAX)
18523 + return size;
18524 +
18525 + check_object_size(src, size, true);
18526 +
18527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18528 + if (!__access_ok(VERIFY_WRITE, dst, size))
18529 + return size;
18530 +#endif
18531 +
18532 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18533 + copy_to_user_overflow();
18534 + return size;
18535 + }
18536 +
18537 if (!__builtin_constant_p(size))
18538 - return copy_user_generic((__force void *)dst, src, size);
18539 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18540 switch (size) {
18541 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18542 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18543 ret, "b", "b", "iq", 1);
18544 return ret;
18545 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18546 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18547 ret, "w", "w", "ir", 2);
18548 return ret;
18549 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18550 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18551 ret, "l", "k", "ir", 4);
18552 return ret;
18553 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18554 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18555 ret, "q", "", "er", 8);
18556 return ret;
18557 case 10:
18558 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18559 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18560 ret, "q", "", "er", 10);
18561 if (unlikely(ret))
18562 return ret;
18563 asm("":::"memory");
18564 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18565 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18566 ret, "w", "w", "ir", 2);
18567 return ret;
18568 case 16:
18569 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18570 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18571 ret, "q", "", "er", 16);
18572 if (unlikely(ret))
18573 return ret;
18574 asm("":::"memory");
18575 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18576 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18577 ret, "q", "", "er", 8);
18578 return ret;
18579 default:
18580 - return copy_user_generic((__force void *)dst, src, size);
18581 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18582 }
18583 }
18584
18585 static __always_inline __must_check
18586 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18587 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18588 {
18589 - int ret = 0;
18590 + unsigned ret = 0;
18591
18592 might_fault();
18593 +
18594 + if (size > INT_MAX)
18595 + return size;
18596 +
18597 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18598 + if (!__access_ok(VERIFY_READ, src, size))
18599 + return size;
18600 + if (!__access_ok(VERIFY_WRITE, dst, size))
18601 + return size;
18602 +#endif
18603 +
18604 if (!__builtin_constant_p(size))
18605 - return copy_user_generic((__force void *)dst,
18606 - (__force void *)src, size);
18607 + return copy_user_generic((__force_kernel void *)____m(dst),
18608 + (__force_kernel const void *)____m(src), size);
18609 switch (size) {
18610 case 1: {
18611 u8 tmp;
18612 - __get_user_asm(tmp, (u8 __user *)src,
18613 + __get_user_asm(tmp, (const u8 __user *)src,
18614 ret, "b", "b", "=q", 1);
18615 if (likely(!ret))
18616 __put_user_asm(tmp, (u8 __user *)dst,
18617 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18618 }
18619 case 2: {
18620 u16 tmp;
18621 - __get_user_asm(tmp, (u16 __user *)src,
18622 + __get_user_asm(tmp, (const u16 __user *)src,
18623 ret, "w", "w", "=r", 2);
18624 if (likely(!ret))
18625 __put_user_asm(tmp, (u16 __user *)dst,
18626 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18627
18628 case 4: {
18629 u32 tmp;
18630 - __get_user_asm(tmp, (u32 __user *)src,
18631 + __get_user_asm(tmp, (const u32 __user *)src,
18632 ret, "l", "k", "=r", 4);
18633 if (likely(!ret))
18634 __put_user_asm(tmp, (u32 __user *)dst,
18635 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18636 }
18637 case 8: {
18638 u64 tmp;
18639 - __get_user_asm(tmp, (u64 __user *)src,
18640 + __get_user_asm(tmp, (const u64 __user *)src,
18641 ret, "q", "", "=r", 8);
18642 if (likely(!ret))
18643 __put_user_asm(tmp, (u64 __user *)dst,
18644 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18645 return ret;
18646 }
18647 default:
18648 - return copy_user_generic((__force void *)dst,
18649 - (__force void *)src, size);
18650 + return copy_user_generic((__force_kernel void *)____m(dst),
18651 + (__force_kernel const void *)____m(src), size);
18652 }
18653 }
18654
18655 -static __must_check __always_inline int
18656 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18657 +static __must_check __always_inline unsigned long
18658 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18659 {
18660 - return copy_user_generic(dst, (__force const void *)src, size);
18661 + if (size > INT_MAX)
18662 + return size;
18663 +
18664 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18665 + if (!__access_ok(VERIFY_READ, src, size))
18666 + return size;
18667 +#endif
18668 +
18669 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18670 }
18671
18672 -static __must_check __always_inline int
18673 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18674 +static __must_check __always_inline unsigned long
18675 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18676 {
18677 - return copy_user_generic((__force void *)dst, src, size);
18678 + if (size > INT_MAX)
18679 + return size;
18680 +
18681 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18682 + if (!__access_ok(VERIFY_WRITE, dst, size))
18683 + return size;
18684 +#endif
18685 +
18686 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18687 }
18688
18689 -extern long __copy_user_nocache(void *dst, const void __user *src,
18690 - unsigned size, int zerorest);
18691 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18692 + unsigned long size, int zerorest) __size_overflow(3);
18693
18694 -static inline int
18695 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18696 +static inline unsigned long
18697 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18698 {
18699 might_fault();
18700 +
18701 + if (size > INT_MAX)
18702 + return size;
18703 +
18704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18705 + if (!__access_ok(VERIFY_READ, src, size))
18706 + return size;
18707 +#endif
18708 +
18709 return __copy_user_nocache(dst, src, size, 1);
18710 }
18711
18712 -static inline int
18713 +static inline unsigned long
18714 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18715 - unsigned size)
18716 + unsigned long size)
18717 {
18718 + if (size > INT_MAX)
18719 + return size;
18720 +
18721 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18722 + if (!__access_ok(VERIFY_READ, src, size))
18723 + return size;
18724 +#endif
18725 +
18726 return __copy_user_nocache(dst, src, size, 0);
18727 }
18728
18729 unsigned long
18730 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18731 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18732
18733 #endif /* _ASM_X86_UACCESS_64_H */
18734 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18735 index 5b238981..77fdd78 100644
18736 --- a/arch/x86/include/asm/word-at-a-time.h
18737 +++ b/arch/x86/include/asm/word-at-a-time.h
18738 @@ -11,7 +11,7 @@
18739 * and shift, for example.
18740 */
18741 struct word_at_a_time {
18742 - const unsigned long one_bits, high_bits;
18743 + unsigned long one_bits, high_bits;
18744 };
18745
18746 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18747 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18748 index 828a156..650e625 100644
18749 --- a/arch/x86/include/asm/x86_init.h
18750 +++ b/arch/x86/include/asm/x86_init.h
18751 @@ -129,7 +129,7 @@ struct x86_init_ops {
18752 struct x86_init_timers timers;
18753 struct x86_init_iommu iommu;
18754 struct x86_init_pci pci;
18755 -};
18756 +} __no_const;
18757
18758 /**
18759 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18760 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18761 void (*setup_percpu_clockev)(void);
18762 void (*early_percpu_clock_init)(void);
18763 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18764 -};
18765 +} __no_const;
18766
18767 struct timespec;
18768
18769 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18770 void (*save_sched_clock_state)(void);
18771 void (*restore_sched_clock_state)(void);
18772 void (*apic_post_init)(void);
18773 -};
18774 +} __no_const;
18775
18776 struct pci_dev;
18777 struct msi_msg;
18778 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18779 void (*teardown_msi_irqs)(struct pci_dev *dev);
18780 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18781 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18782 -};
18783 +} __no_const;
18784
18785 struct IO_APIC_route_entry;
18786 struct io_apic_irq_attr;
18787 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18788 unsigned int destination, int vector,
18789 struct io_apic_irq_attr *attr);
18790 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18791 -};
18792 +} __no_const;
18793
18794 extern struct x86_init_ops x86_init;
18795 extern struct x86_cpuinit_ops x86_cpuinit;
18796 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18797 index 0415cda..3b22adc 100644
18798 --- a/arch/x86/include/asm/xsave.h
18799 +++ b/arch/x86/include/asm/xsave.h
18800 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18801 if (unlikely(err))
18802 return -EFAULT;
18803
18804 + pax_open_userland();
18805 __asm__ __volatile__(ASM_STAC "\n"
18806 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18807 + "1:"
18808 + __copyuser_seg
18809 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18810 "2: " ASM_CLAC "\n"
18811 ".section .fixup,\"ax\"\n"
18812 "3: movl $-1,%[err]\n"
18813 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18814 : [err] "=r" (err)
18815 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18816 : "memory");
18817 + pax_close_userland();
18818 return err;
18819 }
18820
18821 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18822 {
18823 int err;
18824 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18825 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18826 u32 lmask = mask;
18827 u32 hmask = mask >> 32;
18828
18829 + pax_open_userland();
18830 __asm__ __volatile__(ASM_STAC "\n"
18831 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18832 + "1:"
18833 + __copyuser_seg
18834 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18835 "2: " ASM_CLAC "\n"
18836 ".section .fixup,\"ax\"\n"
18837 "3: movl $-1,%[err]\n"
18838 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18839 : [err] "=r" (err)
18840 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18841 : "memory"); /* memory required? */
18842 + pax_close_userland();
18843 return err;
18844 }
18845
18846 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18847 index bbae024..e1528f9 100644
18848 --- a/arch/x86/include/uapi/asm/e820.h
18849 +++ b/arch/x86/include/uapi/asm/e820.h
18850 @@ -63,7 +63,7 @@ struct e820map {
18851 #define ISA_START_ADDRESS 0xa0000
18852 #define ISA_END_ADDRESS 0x100000
18853
18854 -#define BIOS_BEGIN 0x000a0000
18855 +#define BIOS_BEGIN 0x000c0000
18856 #define BIOS_END 0x00100000
18857
18858 #define BIOS_ROM_BASE 0xffe00000
18859 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18860 index 88d99ea..9fc7e17 100644
18861 --- a/arch/x86/kernel/Makefile
18862 +++ b/arch/x86/kernel/Makefile
18863 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18864 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18865 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18866 obj-y += probe_roms.o
18867 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18868 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18869 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18870 obj-y += syscall_$(BITS).o
18871 obj-$(CONFIG_X86_64) += vsyscall_64.o
18872 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18873 index 2627a81..cd8325e 100644
18874 --- a/arch/x86/kernel/acpi/boot.c
18875 +++ b/arch/x86/kernel/acpi/boot.c
18876 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18877 * If your system is blacklisted here, but you find that acpi=force
18878 * works for you, please contact linux-acpi@vger.kernel.org
18879 */
18880 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18881 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18882 /*
18883 * Boxes that need ACPI disabled
18884 */
18885 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18886 };
18887
18888 /* second table for DMI checks that should run after early-quirks */
18889 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18890 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18891 /*
18892 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18893 * which includes some code which overrides all temperature
18894 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18895 index 3312010..a65ca7b 100644
18896 --- a/arch/x86/kernel/acpi/sleep.c
18897 +++ b/arch/x86/kernel/acpi/sleep.c
18898 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18899 #else /* CONFIG_64BIT */
18900 #ifdef CONFIG_SMP
18901 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18902 +
18903 + pax_open_kernel();
18904 early_gdt_descr.address =
18905 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18906 + pax_close_kernel();
18907 +
18908 initial_gs = per_cpu_offset(smp_processor_id());
18909 #endif
18910 initial_code = (unsigned long)wakeup_long64;
18911 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18912 index d1daa66..59fecba 100644
18913 --- a/arch/x86/kernel/acpi/wakeup_32.S
18914 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18915 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18916 # and restore the stack ... but you need gdt for this to work
18917 movl saved_context_esp, %esp
18918
18919 - movl %cs:saved_magic, %eax
18920 - cmpl $0x12345678, %eax
18921 + cmpl $0x12345678, saved_magic
18922 jne bogus_magic
18923
18924 # jump to place where we left off
18925 - movl saved_eip, %eax
18926 - jmp *%eax
18927 + jmp *(saved_eip)
18928
18929 bogus_magic:
18930 jmp bogus_magic
18931 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18932 index c15cf9a..0e63558 100644
18933 --- a/arch/x86/kernel/alternative.c
18934 +++ b/arch/x86/kernel/alternative.c
18935 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18936 */
18937 for (a = start; a < end; a++) {
18938 instr = (u8 *)&a->instr_offset + a->instr_offset;
18939 +
18940 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18941 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18942 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18943 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18944 +#endif
18945 +
18946 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18947 BUG_ON(a->replacementlen > a->instrlen);
18948 BUG_ON(a->instrlen > sizeof(insnbuf));
18949 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18950 for (poff = start; poff < end; poff++) {
18951 u8 *ptr = (u8 *)poff + *poff;
18952
18953 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18954 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18955 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18956 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18957 +#endif
18958 +
18959 if (!*poff || ptr < text || ptr >= text_end)
18960 continue;
18961 /* turn DS segment override prefix into lock prefix */
18962 - if (*ptr == 0x3e)
18963 + if (*ktla_ktva(ptr) == 0x3e)
18964 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18965 }
18966 mutex_unlock(&text_mutex);
18967 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18968 for (poff = start; poff < end; poff++) {
18969 u8 *ptr = (u8 *)poff + *poff;
18970
18971 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18972 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18973 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18974 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18975 +#endif
18976 +
18977 if (!*poff || ptr < text || ptr >= text_end)
18978 continue;
18979 /* turn lock prefix into DS segment override prefix */
18980 - if (*ptr == 0xf0)
18981 + if (*ktla_ktva(ptr) == 0xf0)
18982 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18983 }
18984 mutex_unlock(&text_mutex);
18985 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18986
18987 BUG_ON(p->len > MAX_PATCH_LEN);
18988 /* prep the buffer with the original instructions */
18989 - memcpy(insnbuf, p->instr, p->len);
18990 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18991 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18992 (unsigned long)p->instr, p->len);
18993
18994 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
18995 if (!uniproc_patched || num_possible_cpus() == 1)
18996 free_init_pages("SMP alternatives",
18997 (unsigned long)__smp_locks,
18998 - (unsigned long)__smp_locks_end);
18999 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19000 #endif
19001
19002 apply_paravirt(__parainstructions, __parainstructions_end);
19003 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19004 * instructions. And on the local CPU you need to be protected again NMI or MCE
19005 * handlers seeing an inconsistent instruction while you patch.
19006 */
19007 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19008 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19009 size_t len)
19010 {
19011 unsigned long flags;
19012 local_irq_save(flags);
19013 - memcpy(addr, opcode, len);
19014 +
19015 + pax_open_kernel();
19016 + memcpy(ktla_ktva(addr), opcode, len);
19017 sync_core();
19018 + pax_close_kernel();
19019 +
19020 local_irq_restore(flags);
19021 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19022 that causes hangs on some VIA CPUs. */
19023 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19024 */
19025 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19026 {
19027 - unsigned long flags;
19028 - char *vaddr;
19029 + unsigned char *vaddr = ktla_ktva(addr);
19030 struct page *pages[2];
19031 - int i;
19032 + size_t i;
19033
19034 if (!core_kernel_text((unsigned long)addr)) {
19035 - pages[0] = vmalloc_to_page(addr);
19036 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19037 + pages[0] = vmalloc_to_page(vaddr);
19038 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19039 } else {
19040 - pages[0] = virt_to_page(addr);
19041 + pages[0] = virt_to_page(vaddr);
19042 WARN_ON(!PageReserved(pages[0]));
19043 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19044 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19045 }
19046 BUG_ON(!pages[0]);
19047 - local_irq_save(flags);
19048 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19049 - if (pages[1])
19050 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19051 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19052 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19053 - clear_fixmap(FIX_TEXT_POKE0);
19054 - if (pages[1])
19055 - clear_fixmap(FIX_TEXT_POKE1);
19056 - local_flush_tlb();
19057 - sync_core();
19058 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19059 - that causes hangs on some VIA CPUs. */
19060 + text_poke_early(addr, opcode, len);
19061 for (i = 0; i < len; i++)
19062 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19063 - local_irq_restore(flags);
19064 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19065 return addr;
19066 }
19067
19068 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19069 index eca89c5..d566b78 100644
19070 --- a/arch/x86/kernel/apic/apic.c
19071 +++ b/arch/x86/kernel/apic/apic.c
19072 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19073 /*
19074 * Debug level, exported for io_apic.c
19075 */
19076 -unsigned int apic_verbosity;
19077 +int apic_verbosity;
19078
19079 int pic_mode;
19080
19081 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19082 apic_write(APIC_ESR, 0);
19083 v1 = apic_read(APIC_ESR);
19084 ack_APIC_irq();
19085 - atomic_inc(&irq_err_count);
19086 + atomic_inc_unchecked(&irq_err_count);
19087
19088 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19089 smp_processor_id(), v0 , v1);
19090 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19091 index 00c77cf..2dc6a2d 100644
19092 --- a/arch/x86/kernel/apic/apic_flat_64.c
19093 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19094 @@ -157,7 +157,7 @@ static int flat_probe(void)
19095 return 1;
19096 }
19097
19098 -static struct apic apic_flat = {
19099 +static struct apic apic_flat __read_only = {
19100 .name = "flat",
19101 .probe = flat_probe,
19102 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19103 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19104 return 0;
19105 }
19106
19107 -static struct apic apic_physflat = {
19108 +static struct apic apic_physflat __read_only = {
19109
19110 .name = "physical flat",
19111 .probe = physflat_probe,
19112 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19113 index e145f28..2752888 100644
19114 --- a/arch/x86/kernel/apic/apic_noop.c
19115 +++ b/arch/x86/kernel/apic/apic_noop.c
19116 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19117 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19118 }
19119
19120 -struct apic apic_noop = {
19121 +struct apic apic_noop __read_only = {
19122 .name = "noop",
19123 .probe = noop_probe,
19124 .acpi_madt_oem_check = NULL,
19125 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19126 index d50e364..543bee3 100644
19127 --- a/arch/x86/kernel/apic/bigsmp_32.c
19128 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19129 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19130 return dmi_bigsmp;
19131 }
19132
19133 -static struct apic apic_bigsmp = {
19134 +static struct apic apic_bigsmp __read_only = {
19135
19136 .name = "bigsmp",
19137 .probe = probe_bigsmp,
19138 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19139 index c552247..587a316 100644
19140 --- a/arch/x86/kernel/apic/es7000_32.c
19141 +++ b/arch/x86/kernel/apic/es7000_32.c
19142 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19143 return ret && es7000_apic_is_cluster();
19144 }
19145
19146 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19147 -static struct apic __refdata apic_es7000_cluster = {
19148 +static struct apic apic_es7000_cluster __read_only = {
19149
19150 .name = "es7000",
19151 .probe = probe_es7000,
19152 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19153 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19154 };
19155
19156 -static struct apic __refdata apic_es7000 = {
19157 +static struct apic apic_es7000 __read_only = {
19158
19159 .name = "es7000",
19160 .probe = probe_es7000,
19161 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19162 index 9ed796c..e930fe4 100644
19163 --- a/arch/x86/kernel/apic/io_apic.c
19164 +++ b/arch/x86/kernel/apic/io_apic.c
19165 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19166 }
19167 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19168
19169 -void lock_vector_lock(void)
19170 +void lock_vector_lock(void) __acquires(vector_lock)
19171 {
19172 /* Used to the online set of cpus does not change
19173 * during assign_irq_vector.
19174 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19175 raw_spin_lock(&vector_lock);
19176 }
19177
19178 -void unlock_vector_lock(void)
19179 +void unlock_vector_lock(void) __releases(vector_lock)
19180 {
19181 raw_spin_unlock(&vector_lock);
19182 }
19183 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19184 ack_APIC_irq();
19185 }
19186
19187 -atomic_t irq_mis_count;
19188 +atomic_unchecked_t irq_mis_count;
19189
19190 #ifdef CONFIG_GENERIC_PENDING_IRQ
19191 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19192 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19193 * at the cpu.
19194 */
19195 if (!(v & (1 << (i & 0x1f)))) {
19196 - atomic_inc(&irq_mis_count);
19197 + atomic_inc_unchecked(&irq_mis_count);
19198
19199 eoi_ioapic_irq(irq, cfg);
19200 }
19201 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19202 index 1e42e8f..daacf44 100644
19203 --- a/arch/x86/kernel/apic/numaq_32.c
19204 +++ b/arch/x86/kernel/apic/numaq_32.c
19205 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19206 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19207 }
19208
19209 -/* Use __refdata to keep false positive warning calm. */
19210 -static struct apic __refdata apic_numaq = {
19211 +static struct apic apic_numaq __read_only = {
19212
19213 .name = "NUMAQ",
19214 .probe = probe_numaq,
19215 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19216 index eb35ef9..f184a21 100644
19217 --- a/arch/x86/kernel/apic/probe_32.c
19218 +++ b/arch/x86/kernel/apic/probe_32.c
19219 @@ -72,7 +72,7 @@ static int probe_default(void)
19220 return 1;
19221 }
19222
19223 -static struct apic apic_default = {
19224 +static struct apic apic_default __read_only = {
19225
19226 .name = "default",
19227 .probe = probe_default,
19228 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19229 index 77c95c0..434f8a4 100644
19230 --- a/arch/x86/kernel/apic/summit_32.c
19231 +++ b/arch/x86/kernel/apic/summit_32.c
19232 @@ -486,7 +486,7 @@ void setup_summit(void)
19233 }
19234 #endif
19235
19236 -static struct apic apic_summit = {
19237 +static struct apic apic_summit __read_only = {
19238
19239 .name = "summit",
19240 .probe = probe_summit,
19241 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19242 index 140e29d..d88bc95 100644
19243 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19244 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19245 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19246 return notifier_from_errno(err);
19247 }
19248
19249 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19250 +static struct notifier_block x2apic_cpu_notifier = {
19251 .notifier_call = update_clusterinfo,
19252 };
19253
19254 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19255 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19256 }
19257
19258 -static struct apic apic_x2apic_cluster = {
19259 +static struct apic apic_x2apic_cluster __read_only = {
19260
19261 .name = "cluster x2apic",
19262 .probe = x2apic_cluster_probe,
19263 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19264 index 562a76d..a003c0f 100644
19265 --- a/arch/x86/kernel/apic/x2apic_phys.c
19266 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19267 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19268 return apic == &apic_x2apic_phys;
19269 }
19270
19271 -static struct apic apic_x2apic_phys = {
19272 +static struct apic apic_x2apic_phys __read_only = {
19273
19274 .name = "physical x2apic",
19275 .probe = x2apic_phys_probe,
19276 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19277 index 1191ac1..2335fa4 100644
19278 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19279 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19280 @@ -357,7 +357,7 @@ static int uv_probe(void)
19281 return apic == &apic_x2apic_uv_x;
19282 }
19283
19284 -static struct apic __refdata apic_x2apic_uv_x = {
19285 +static struct apic apic_x2apic_uv_x __read_only = {
19286
19287 .name = "UV large system",
19288 .probe = uv_probe,
19289 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19290 index 53a4e27..038760a 100644
19291 --- a/arch/x86/kernel/apm_32.c
19292 +++ b/arch/x86/kernel/apm_32.c
19293 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19294 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19295 * even though they are called in protected mode.
19296 */
19297 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19298 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19299 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19300
19301 static const char driver_version[] = "1.16ac"; /* no spaces */
19302 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19303 BUG_ON(cpu != 0);
19304 gdt = get_cpu_gdt_table(cpu);
19305 save_desc_40 = gdt[0x40 / 8];
19306 +
19307 + pax_open_kernel();
19308 gdt[0x40 / 8] = bad_bios_desc;
19309 + pax_close_kernel();
19310
19311 apm_irq_save(flags);
19312 APM_DO_SAVE_SEGS;
19313 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19314 &call->esi);
19315 APM_DO_RESTORE_SEGS;
19316 apm_irq_restore(flags);
19317 +
19318 + pax_open_kernel();
19319 gdt[0x40 / 8] = save_desc_40;
19320 + pax_close_kernel();
19321 +
19322 put_cpu();
19323
19324 return call->eax & 0xff;
19325 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19326 BUG_ON(cpu != 0);
19327 gdt = get_cpu_gdt_table(cpu);
19328 save_desc_40 = gdt[0x40 / 8];
19329 +
19330 + pax_open_kernel();
19331 gdt[0x40 / 8] = bad_bios_desc;
19332 + pax_close_kernel();
19333
19334 apm_irq_save(flags);
19335 APM_DO_SAVE_SEGS;
19336 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19337 &call->eax);
19338 APM_DO_RESTORE_SEGS;
19339 apm_irq_restore(flags);
19340 +
19341 + pax_open_kernel();
19342 gdt[0x40 / 8] = save_desc_40;
19343 + pax_close_kernel();
19344 +
19345 put_cpu();
19346 return error;
19347 }
19348 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19349 * code to that CPU.
19350 */
19351 gdt = get_cpu_gdt_table(0);
19352 +
19353 + pax_open_kernel();
19354 set_desc_base(&gdt[APM_CS >> 3],
19355 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19356 set_desc_base(&gdt[APM_CS_16 >> 3],
19357 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19358 set_desc_base(&gdt[APM_DS >> 3],
19359 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19360 + pax_close_kernel();
19361
19362 proc_create("apm", 0, NULL, &apm_file_ops);
19363
19364 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19365 index 2861082..6d4718e 100644
19366 --- a/arch/x86/kernel/asm-offsets.c
19367 +++ b/arch/x86/kernel/asm-offsets.c
19368 @@ -33,6 +33,8 @@ void common(void) {
19369 OFFSET(TI_status, thread_info, status);
19370 OFFSET(TI_addr_limit, thread_info, addr_limit);
19371 OFFSET(TI_preempt_count, thread_info, preempt_count);
19372 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19373 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19374
19375 BLANK();
19376 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19377 @@ -53,8 +55,26 @@ void common(void) {
19378 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19379 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19380 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19381 +
19382 +#ifdef CONFIG_PAX_KERNEXEC
19383 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19384 #endif
19385
19386 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19387 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19388 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19389 +#ifdef CONFIG_X86_64
19390 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19391 +#endif
19392 +#endif
19393 +
19394 +#endif
19395 +
19396 + BLANK();
19397 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19398 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19399 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19400 +
19401 #ifdef CONFIG_XEN
19402 BLANK();
19403 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19404 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19405 index e7c798b..2b2019b 100644
19406 --- a/arch/x86/kernel/asm-offsets_64.c
19407 +++ b/arch/x86/kernel/asm-offsets_64.c
19408 @@ -77,6 +77,7 @@ int main(void)
19409 BLANK();
19410 #undef ENTRY
19411
19412 + DEFINE(TSS_size, sizeof(struct tss_struct));
19413 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19414 BLANK();
19415
19416 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19417 index 47b56a7..efc2bc6 100644
19418 --- a/arch/x86/kernel/cpu/Makefile
19419 +++ b/arch/x86/kernel/cpu/Makefile
19420 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19421 CFLAGS_REMOVE_perf_event.o = -pg
19422 endif
19423
19424 -# Make sure load_percpu_segment has no stackprotector
19425 -nostackp := $(call cc-option, -fno-stack-protector)
19426 -CFLAGS_common.o := $(nostackp)
19427 -
19428 obj-y := intel_cacheinfo.o scattered.o topology.o
19429 obj-y += proc.o capflags.o powerflags.o common.o
19430 obj-y += rdrand.o
19431 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19432 index 08a0890..e557865 100644
19433 --- a/arch/x86/kernel/cpu/amd.c
19434 +++ b/arch/x86/kernel/cpu/amd.c
19435 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19436 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19437 {
19438 /* AMD errata T13 (order #21922) */
19439 - if ((c->x86 == 6)) {
19440 + if (c->x86 == 6) {
19441 /* Duron Rev A0 */
19442 if (c->x86_model == 3 && c->x86_mask == 0)
19443 size = 64;
19444 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19445 index 25eb274..3a92d93 100644
19446 --- a/arch/x86/kernel/cpu/common.c
19447 +++ b/arch/x86/kernel/cpu/common.c
19448 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19449
19450 static const struct cpu_dev *this_cpu = &default_cpu;
19451
19452 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19453 -#ifdef CONFIG_X86_64
19454 - /*
19455 - * We need valid kernel segments for data and code in long mode too
19456 - * IRET will check the segment types kkeil 2000/10/28
19457 - * Also sysret mandates a special GDT layout
19458 - *
19459 - * TLS descriptors are currently at a different place compared to i386.
19460 - * Hopefully nobody expects them at a fixed place (Wine?)
19461 - */
19462 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19463 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19464 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19465 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19466 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19467 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19468 -#else
19469 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19470 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19471 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19472 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19473 - /*
19474 - * Segments used for calling PnP BIOS have byte granularity.
19475 - * They code segments and data segments have fixed 64k limits,
19476 - * the transfer segment sizes are set at run time.
19477 - */
19478 - /* 32-bit code */
19479 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19480 - /* 16-bit code */
19481 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19482 - /* 16-bit data */
19483 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19484 - /* 16-bit data */
19485 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19486 - /* 16-bit data */
19487 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19488 - /*
19489 - * The APM segments have byte granularity and their bases
19490 - * are set at run time. All have 64k limits.
19491 - */
19492 - /* 32-bit code */
19493 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19494 - /* 16-bit code */
19495 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19496 - /* data */
19497 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19498 -
19499 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19500 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19501 - GDT_STACK_CANARY_INIT
19502 -#endif
19503 -} };
19504 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19505 -
19506 static int __init x86_xsave_setup(char *s)
19507 {
19508 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19509 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19510 set_in_cr4(X86_CR4_SMAP);
19511 }
19512
19513 +#ifdef CONFIG_X86_64
19514 +static __init int setup_disable_pcid(char *arg)
19515 +{
19516 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19517 +
19518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19519 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19520 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19521 +#endif
19522 +
19523 + return 1;
19524 +}
19525 +__setup("nopcid", setup_disable_pcid);
19526 +
19527 +static void setup_pcid(struct cpuinfo_x86 *c)
19528 +{
19529 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19530 +
19531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19532 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19533 + pax_open_kernel();
19534 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19535 + pax_close_kernel();
19536 + printk("PAX: slow and weak UDEREF enabled\n");
19537 + } else
19538 + printk("PAX: UDEREF disabled\n");
19539 +#endif
19540 +
19541 + return;
19542 + }
19543 +
19544 + printk("PAX: PCID detected\n");
19545 + set_in_cr4(X86_CR4_PCIDE);
19546 +
19547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19548 + pax_open_kernel();
19549 + clone_pgd_mask = ~(pgdval_t)0UL;
19550 + pax_close_kernel();
19551 + if (pax_user_shadow_base)
19552 + printk("PAX: weak UDEREF enabled\n");
19553 + else {
19554 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19555 + printk("PAX: strong UDEREF enabled\n");
19556 + }
19557 +#endif
19558 +
19559 + if (cpu_has(c, X86_FEATURE_INVPCID))
19560 + printk("PAX: INVPCID detected\n");
19561 +}
19562 +#endif
19563 +
19564 /*
19565 * Some CPU features depend on higher CPUID levels, which may not always
19566 * be available due to CPUID level capping or broken virtualization
19567 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19568 {
19569 struct desc_ptr gdt_descr;
19570
19571 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19572 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19573 gdt_descr.size = GDT_SIZE - 1;
19574 load_gdt(&gdt_descr);
19575 /* Reload the per-cpu base */
19576 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19577 setup_smep(c);
19578 setup_smap(c);
19579
19580 +#ifdef CONFIG_X86_64
19581 + setup_pcid(c);
19582 +#endif
19583 +
19584 /*
19585 * The vendor-specific functions might have changed features.
19586 * Now we do "generic changes."
19587 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19588 /* Filter out anything that depends on CPUID levels we don't have */
19589 filter_cpuid_features(c, true);
19590
19591 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19592 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19593 +#endif
19594 +
19595 /* If the model name is still unset, do table lookup. */
19596 if (!c->x86_model_id[0]) {
19597 const char *p;
19598 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19599 }
19600 __setup("clearcpuid=", setup_disablecpuid);
19601
19602 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19603 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19604 +
19605 #ifdef CONFIG_X86_64
19606 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19607 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19608 - (unsigned long) debug_idt_table };
19609 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19610 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19611
19612 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19613 irq_stack_union) __aligned(PAGE_SIZE);
19614 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19615 EXPORT_PER_CPU_SYMBOL(current_task);
19616
19617 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19618 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19619 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19620 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19621
19622 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19623 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19624 load_ucode_ap();
19625
19626 cpu = stack_smp_processor_id();
19627 - t = &per_cpu(init_tss, cpu);
19628 + t = init_tss + cpu;
19629 oist = &per_cpu(orig_ist, cpu);
19630
19631 #ifdef CONFIG_NUMA
19632 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19633 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19634 barrier();
19635
19636 - x86_configure_nx();
19637 enable_x2apic();
19638
19639 /*
19640 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19641 {
19642 int cpu = smp_processor_id();
19643 struct task_struct *curr = current;
19644 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19645 + struct tss_struct *t = init_tss + cpu;
19646 struct thread_struct *thread = &curr->thread;
19647
19648 show_ucode_info_early();
19649 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19650 index 1414c90..1159406 100644
19651 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19652 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19653 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19654 };
19655
19656 #ifdef CONFIG_AMD_NB
19657 +static struct attribute *default_attrs_amd_nb[] = {
19658 + &type.attr,
19659 + &level.attr,
19660 + &coherency_line_size.attr,
19661 + &physical_line_partition.attr,
19662 + &ways_of_associativity.attr,
19663 + &number_of_sets.attr,
19664 + &size.attr,
19665 + &shared_cpu_map.attr,
19666 + &shared_cpu_list.attr,
19667 + NULL,
19668 + NULL,
19669 + NULL,
19670 + NULL
19671 +};
19672 +
19673 static struct attribute **amd_l3_attrs(void)
19674 {
19675 static struct attribute **attrs;
19676 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19677
19678 n = ARRAY_SIZE(default_attrs);
19679
19680 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19681 - n += 2;
19682 -
19683 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19684 - n += 1;
19685 -
19686 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19687 - if (attrs == NULL)
19688 - return attrs = default_attrs;
19689 -
19690 - for (n = 0; default_attrs[n]; n++)
19691 - attrs[n] = default_attrs[n];
19692 + attrs = default_attrs_amd_nb;
19693
19694 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19695 attrs[n++] = &cache_disable_0.attr;
19696 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19697 .default_attrs = default_attrs,
19698 };
19699
19700 +#ifdef CONFIG_AMD_NB
19701 +static struct kobj_type ktype_cache_amd_nb = {
19702 + .sysfs_ops = &sysfs_ops,
19703 + .default_attrs = default_attrs_amd_nb,
19704 +};
19705 +#endif
19706 +
19707 static struct kobj_type ktype_percpu_entry = {
19708 .sysfs_ops = &sysfs_ops,
19709 };
19710 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19711 return retval;
19712 }
19713
19714 +#ifdef CONFIG_AMD_NB
19715 + amd_l3_attrs();
19716 +#endif
19717 +
19718 for (i = 0; i < num_cache_leaves; i++) {
19719 + struct kobj_type *ktype;
19720 +
19721 this_object = INDEX_KOBJECT_PTR(cpu, i);
19722 this_object->cpu = cpu;
19723 this_object->index = i;
19724
19725 this_leaf = CPUID4_INFO_IDX(cpu, i);
19726
19727 - ktype_cache.default_attrs = default_attrs;
19728 + ktype = &ktype_cache;
19729 #ifdef CONFIG_AMD_NB
19730 if (this_leaf->base.nb)
19731 - ktype_cache.default_attrs = amd_l3_attrs();
19732 + ktype = &ktype_cache_amd_nb;
19733 #endif
19734 retval = kobject_init_and_add(&(this_object->kobj),
19735 - &ktype_cache,
19736 + ktype,
19737 per_cpu(ici_cache_kobject, cpu),
19738 "index%1lu", i);
19739 if (unlikely(retval)) {
19740 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19741 index 87a65c9..92fcce6 100644
19742 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19743 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19744 @@ -45,6 +45,7 @@
19745 #include <asm/processor.h>
19746 #include <asm/mce.h>
19747 #include <asm/msr.h>
19748 +#include <asm/local.h>
19749
19750 #include "mce-internal.h"
19751
19752 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19753 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19754 m->cs, m->ip);
19755
19756 - if (m->cs == __KERNEL_CS)
19757 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19758 print_symbol("{%s}", m->ip);
19759 pr_cont("\n");
19760 }
19761 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19762
19763 #define PANIC_TIMEOUT 5 /* 5 seconds */
19764
19765 -static atomic_t mce_paniced;
19766 +static atomic_unchecked_t mce_paniced;
19767
19768 static int fake_panic;
19769 -static atomic_t mce_fake_paniced;
19770 +static atomic_unchecked_t mce_fake_paniced;
19771
19772 /* Panic in progress. Enable interrupts and wait for final IPI */
19773 static void wait_for_panic(void)
19774 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19775 /*
19776 * Make sure only one CPU runs in machine check panic
19777 */
19778 - if (atomic_inc_return(&mce_paniced) > 1)
19779 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19780 wait_for_panic();
19781 barrier();
19782
19783 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19784 console_verbose();
19785 } else {
19786 /* Don't log too much for fake panic */
19787 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19788 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19789 return;
19790 }
19791 /* First print corrected ones that are still unlogged */
19792 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19793 if (!fake_panic) {
19794 if (panic_timeout == 0)
19795 panic_timeout = mca_cfg.panic_timeout;
19796 - panic(msg);
19797 + panic("%s", msg);
19798 } else
19799 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19800 }
19801 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19802 * might have been modified by someone else.
19803 */
19804 rmb();
19805 - if (atomic_read(&mce_paniced))
19806 + if (atomic_read_unchecked(&mce_paniced))
19807 wait_for_panic();
19808 if (!mca_cfg.monarch_timeout)
19809 goto out;
19810 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19811 }
19812
19813 /* Call the installed machine check handler for this CPU setup. */
19814 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19815 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19816 unexpected_machine_check;
19817
19818 /*
19819 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19820 return;
19821 }
19822
19823 + pax_open_kernel();
19824 machine_check_vector = do_machine_check;
19825 + pax_close_kernel();
19826
19827 __mcheck_cpu_init_generic();
19828 __mcheck_cpu_init_vendor(c);
19829 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19830 */
19831
19832 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19833 -static int mce_chrdev_open_count; /* #times opened */
19834 +static local_t mce_chrdev_open_count; /* #times opened */
19835 static int mce_chrdev_open_exclu; /* already open exclusive? */
19836
19837 static int mce_chrdev_open(struct inode *inode, struct file *file)
19838 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19839 spin_lock(&mce_chrdev_state_lock);
19840
19841 if (mce_chrdev_open_exclu ||
19842 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19843 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19844 spin_unlock(&mce_chrdev_state_lock);
19845
19846 return -EBUSY;
19847 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19848
19849 if (file->f_flags & O_EXCL)
19850 mce_chrdev_open_exclu = 1;
19851 - mce_chrdev_open_count++;
19852 + local_inc(&mce_chrdev_open_count);
19853
19854 spin_unlock(&mce_chrdev_state_lock);
19855
19856 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19857 {
19858 spin_lock(&mce_chrdev_state_lock);
19859
19860 - mce_chrdev_open_count--;
19861 + local_dec(&mce_chrdev_open_count);
19862 mce_chrdev_open_exclu = 0;
19863
19864 spin_unlock(&mce_chrdev_state_lock);
19865 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19866
19867 for (i = 0; i < mca_cfg.banks; i++) {
19868 struct mce_bank *b = &mce_banks[i];
19869 - struct device_attribute *a = &b->attr;
19870 + device_attribute_no_const *a = &b->attr;
19871
19872 sysfs_attr_init(&a->attr);
19873 a->attr.name = b->attrname;
19874 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19875 static void mce_reset(void)
19876 {
19877 cpu_missing = 0;
19878 - atomic_set(&mce_fake_paniced, 0);
19879 + atomic_set_unchecked(&mce_fake_paniced, 0);
19880 atomic_set(&mce_executing, 0);
19881 atomic_set(&mce_callin, 0);
19882 atomic_set(&global_nwo, 0);
19883 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19884 index 1c044b1..37a2a43 100644
19885 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19886 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19887 @@ -11,6 +11,7 @@
19888 #include <asm/processor.h>
19889 #include <asm/mce.h>
19890 #include <asm/msr.h>
19891 +#include <asm/pgtable.h>
19892
19893 /* By default disabled */
19894 int mce_p5_enabled __read_mostly;
19895 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19896 if (!cpu_has(c, X86_FEATURE_MCE))
19897 return;
19898
19899 + pax_open_kernel();
19900 machine_check_vector = pentium_machine_check;
19901 + pax_close_kernel();
19902 /* Make sure the vector pointer is visible before we enable MCEs: */
19903 wmb();
19904
19905 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19906 index e9a701a..35317d6 100644
19907 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19908 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19909 @@ -10,6 +10,7 @@
19910 #include <asm/processor.h>
19911 #include <asm/mce.h>
19912 #include <asm/msr.h>
19913 +#include <asm/pgtable.h>
19914
19915 /* Machine check handler for WinChip C6: */
19916 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19917 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19918 {
19919 u32 lo, hi;
19920
19921 + pax_open_kernel();
19922 machine_check_vector = winchip_machine_check;
19923 + pax_close_kernel();
19924 /* Make sure the vector pointer is visible before we enable MCEs: */
19925 wmb();
19926
19927 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19928 index f961de9..8a9d332 100644
19929 --- a/arch/x86/kernel/cpu/mtrr/main.c
19930 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19931 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19932 u64 size_or_mask, size_and_mask;
19933 static bool mtrr_aps_delayed_init;
19934
19935 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19936 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19937
19938 const struct mtrr_ops *mtrr_if;
19939
19940 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19941 index df5e41f..816c719 100644
19942 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19943 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19944 @@ -25,7 +25,7 @@ struct mtrr_ops {
19945 int (*validate_add_page)(unsigned long base, unsigned long size,
19946 unsigned int type);
19947 int (*have_wrcomb)(void);
19948 -};
19949 +} __do_const;
19950
19951 extern int generic_get_free_region(unsigned long base, unsigned long size,
19952 int replace_reg);
19953 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19954 index a7c7305..b9705ab 100644
19955 --- a/arch/x86/kernel/cpu/perf_event.c
19956 +++ b/arch/x86/kernel/cpu/perf_event.c
19957 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19958 pr_info("no hardware sampling interrupt available.\n");
19959 }
19960
19961 -static struct attribute_group x86_pmu_format_group = {
19962 +static attribute_group_no_const x86_pmu_format_group = {
19963 .name = "format",
19964 .attrs = NULL,
19965 };
19966 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19967 NULL,
19968 };
19969
19970 -static struct attribute_group x86_pmu_events_group = {
19971 +static attribute_group_no_const x86_pmu_events_group = {
19972 .name = "events",
19973 .attrs = events_attr,
19974 };
19975 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19976 if (idx > GDT_ENTRIES)
19977 return 0;
19978
19979 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19980 + desc = get_cpu_gdt_table(smp_processor_id());
19981 }
19982
19983 return get_desc_base(desc + idx);
19984 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19985 break;
19986
19987 perf_callchain_store(entry, frame.return_address);
19988 - fp = frame.next_frame;
19989 + fp = (const void __force_user *)frame.next_frame;
19990 }
19991 }
19992
19993 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19994 index 639d128..e92d7e5 100644
19995 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19996 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19997 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
19998 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
19999 {
20000 struct attribute **attrs;
20001 - struct attribute_group *attr_group;
20002 + attribute_group_no_const *attr_group;
20003 int i = 0, j;
20004
20005 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20006 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20007 index a45d8d4..8abd32c 100644
20008 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20009 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20010 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20011 * v2 and above have a perf capabilities MSR
20012 */
20013 if (version > 1) {
20014 - u64 capabilities;
20015 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20016
20017 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20018 - x86_pmu.intel_cap.capabilities = capabilities;
20019 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20020 + x86_pmu.intel_cap.capabilities = capabilities;
20021 }
20022
20023 intel_ds_init();
20024 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20025 index 1fb6c72..f5fa2a3 100644
20026 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20027 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20028 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20029 static int __init uncore_type_init(struct intel_uncore_type *type)
20030 {
20031 struct intel_uncore_pmu *pmus;
20032 - struct attribute_group *attr_group;
20033 + attribute_group_no_const *attr_group;
20034 struct attribute **attrs;
20035 int i, j;
20036
20037 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20038 index 47b3d00c..2cf1751 100644
20039 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20040 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20041 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20042 struct uncore_event_desc {
20043 struct kobj_attribute attr;
20044 const char *config;
20045 -};
20046 +} __do_const;
20047
20048 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20049 { \
20050 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20051 index 7d9481c..99c7e4b 100644
20052 --- a/arch/x86/kernel/cpuid.c
20053 +++ b/arch/x86/kernel/cpuid.c
20054 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20055 return notifier_from_errno(err);
20056 }
20057
20058 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20059 +static struct notifier_block cpuid_class_cpu_notifier =
20060 {
20061 .notifier_call = cpuid_class_cpu_callback,
20062 };
20063 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20064 index 74467fe..18793d5 100644
20065 --- a/arch/x86/kernel/crash.c
20066 +++ b/arch/x86/kernel/crash.c
20067 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20068 {
20069 #ifdef CONFIG_X86_32
20070 struct pt_regs fixed_regs;
20071 -#endif
20072
20073 -#ifdef CONFIG_X86_32
20074 - if (!user_mode_vm(regs)) {
20075 + if (!user_mode(regs)) {
20076 crash_fixup_ss_esp(&fixed_regs, regs);
20077 regs = &fixed_regs;
20078 }
20079 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20080 index afa64ad..dce67dd 100644
20081 --- a/arch/x86/kernel/crash_dump_64.c
20082 +++ b/arch/x86/kernel/crash_dump_64.c
20083 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20084 return -ENOMEM;
20085
20086 if (userbuf) {
20087 - if (copy_to_user(buf, vaddr + offset, csize)) {
20088 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20089 iounmap(vaddr);
20090 return -EFAULT;
20091 }
20092 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20093 index 5d3fe8d..02e1429 100644
20094 --- a/arch/x86/kernel/doublefault.c
20095 +++ b/arch/x86/kernel/doublefault.c
20096 @@ -13,7 +13,7 @@
20097
20098 #define DOUBLEFAULT_STACKSIZE (1024)
20099 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20100 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20101 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20102
20103 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20104
20105 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20106 unsigned long gdt, tss;
20107
20108 native_store_gdt(&gdt_desc);
20109 - gdt = gdt_desc.address;
20110 + gdt = (unsigned long)gdt_desc.address;
20111
20112 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20113
20114 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20115 /* 0x2 bit is always set */
20116 .flags = X86_EFLAGS_SF | 0x2,
20117 .sp = STACK_START,
20118 - .es = __USER_DS,
20119 + .es = __KERNEL_DS,
20120 .cs = __KERNEL_CS,
20121 .ss = __KERNEL_DS,
20122 - .ds = __USER_DS,
20123 + .ds = __KERNEL_DS,
20124 .fs = __KERNEL_PERCPU,
20125
20126 .__cr3 = __pa_nodebug(swapper_pg_dir),
20127 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20128 index deb6421..76bbc12 100644
20129 --- a/arch/x86/kernel/dumpstack.c
20130 +++ b/arch/x86/kernel/dumpstack.c
20131 @@ -2,6 +2,9 @@
20132 * Copyright (C) 1991, 1992 Linus Torvalds
20133 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20134 */
20135 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20136 +#define __INCLUDED_BY_HIDESYM 1
20137 +#endif
20138 #include <linux/kallsyms.h>
20139 #include <linux/kprobes.h>
20140 #include <linux/uaccess.h>
20141 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20142 static void
20143 print_ftrace_graph_addr(unsigned long addr, void *data,
20144 const struct stacktrace_ops *ops,
20145 - struct thread_info *tinfo, int *graph)
20146 + struct task_struct *task, int *graph)
20147 {
20148 - struct task_struct *task;
20149 unsigned long ret_addr;
20150 int index;
20151
20152 if (addr != (unsigned long)return_to_handler)
20153 return;
20154
20155 - task = tinfo->task;
20156 index = task->curr_ret_stack;
20157
20158 if (!task->ret_stack || index < *graph)
20159 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20160 static inline void
20161 print_ftrace_graph_addr(unsigned long addr, void *data,
20162 const struct stacktrace_ops *ops,
20163 - struct thread_info *tinfo, int *graph)
20164 + struct task_struct *task, int *graph)
20165 { }
20166 #endif
20167
20168 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20169 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20170 */
20171
20172 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20173 - void *p, unsigned int size, void *end)
20174 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20175 {
20176 - void *t = tinfo;
20177 if (end) {
20178 if (p < end && p >= (end-THREAD_SIZE))
20179 return 1;
20180 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20181 }
20182
20183 unsigned long
20184 -print_context_stack(struct thread_info *tinfo,
20185 +print_context_stack(struct task_struct *task, void *stack_start,
20186 unsigned long *stack, unsigned long bp,
20187 const struct stacktrace_ops *ops, void *data,
20188 unsigned long *end, int *graph)
20189 {
20190 struct stack_frame *frame = (struct stack_frame *)bp;
20191
20192 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20193 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20194 unsigned long addr;
20195
20196 addr = *stack;
20197 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20198 } else {
20199 ops->address(data, addr, 0);
20200 }
20201 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20202 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20203 }
20204 stack++;
20205 }
20206 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20207 EXPORT_SYMBOL_GPL(print_context_stack);
20208
20209 unsigned long
20210 -print_context_stack_bp(struct thread_info *tinfo,
20211 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20212 unsigned long *stack, unsigned long bp,
20213 const struct stacktrace_ops *ops, void *data,
20214 unsigned long *end, int *graph)
20215 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20216 struct stack_frame *frame = (struct stack_frame *)bp;
20217 unsigned long *ret_addr = &frame->return_address;
20218
20219 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20220 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20221 unsigned long addr = *ret_addr;
20222
20223 if (!__kernel_text_address(addr))
20224 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20225 ops->address(data, addr, 1);
20226 frame = frame->next_frame;
20227 ret_addr = &frame->return_address;
20228 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20229 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20230 }
20231
20232 return (unsigned long)frame;
20233 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20234 static void print_trace_address(void *data, unsigned long addr, int reliable)
20235 {
20236 touch_nmi_watchdog();
20237 - printk(data);
20238 + printk("%s", (char *)data);
20239 printk_address(addr, reliable);
20240 }
20241
20242 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20243 }
20244 EXPORT_SYMBOL_GPL(oops_begin);
20245
20246 +extern void gr_handle_kernel_exploit(void);
20247 +
20248 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20249 {
20250 if (regs && kexec_should_crash(current))
20251 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20252 panic("Fatal exception in interrupt");
20253 if (panic_on_oops)
20254 panic("Fatal exception");
20255 - do_exit(signr);
20256 +
20257 + gr_handle_kernel_exploit();
20258 +
20259 + do_group_exit(signr);
20260 }
20261
20262 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20263 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20264 print_modules();
20265 show_regs(regs);
20266 #ifdef CONFIG_X86_32
20267 - if (user_mode_vm(regs)) {
20268 + if (user_mode(regs)) {
20269 sp = regs->sp;
20270 ss = regs->ss & 0xffff;
20271 } else {
20272 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20273 unsigned long flags = oops_begin();
20274 int sig = SIGSEGV;
20275
20276 - if (!user_mode_vm(regs))
20277 + if (!user_mode(regs))
20278 report_bug(regs->ip, regs);
20279
20280 if (__die(str, regs, err))
20281 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20282 index f2a1770..540657f 100644
20283 --- a/arch/x86/kernel/dumpstack_32.c
20284 +++ b/arch/x86/kernel/dumpstack_32.c
20285 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20286 bp = stack_frame(task, regs);
20287
20288 for (;;) {
20289 - struct thread_info *context;
20290 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20291
20292 - context = (struct thread_info *)
20293 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20294 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20295 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20296
20297 - stack = (unsigned long *)context->previous_esp;
20298 - if (!stack)
20299 + if (stack_start == task_stack_page(task))
20300 break;
20301 + stack = *(unsigned long **)stack_start;
20302 if (ops->stack(data, "IRQ") < 0)
20303 break;
20304 touch_nmi_watchdog();
20305 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20306 int i;
20307
20308 show_regs_print_info(KERN_EMERG);
20309 - __show_regs(regs, !user_mode_vm(regs));
20310 + __show_regs(regs, !user_mode(regs));
20311
20312 /*
20313 * When in-kernel, we also print out the stack and code at the
20314 * time of the fault..
20315 */
20316 - if (!user_mode_vm(regs)) {
20317 + if (!user_mode(regs)) {
20318 unsigned int code_prologue = code_bytes * 43 / 64;
20319 unsigned int code_len = code_bytes;
20320 unsigned char c;
20321 u8 *ip;
20322 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20323
20324 pr_emerg("Stack:\n");
20325 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20326
20327 pr_emerg("Code:");
20328
20329 - ip = (u8 *)regs->ip - code_prologue;
20330 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20331 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20332 /* try starting at IP */
20333 - ip = (u8 *)regs->ip;
20334 + ip = (u8 *)regs->ip + cs_base;
20335 code_len = code_len - code_prologue + 1;
20336 }
20337 for (i = 0; i < code_len; i++, ip++) {
20338 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20339 pr_cont(" Bad EIP value.");
20340 break;
20341 }
20342 - if (ip == (u8 *)regs->ip)
20343 + if (ip == (u8 *)regs->ip + cs_base)
20344 pr_cont(" <%02x>", c);
20345 else
20346 pr_cont(" %02x", c);
20347 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20348 {
20349 unsigned short ud2;
20350
20351 + ip = ktla_ktva(ip);
20352 if (ip < PAGE_OFFSET)
20353 return 0;
20354 if (probe_kernel_address((unsigned short *)ip, ud2))
20355 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20356
20357 return ud2 == 0x0b0f;
20358 }
20359 +
20360 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20361 +void pax_check_alloca(unsigned long size)
20362 +{
20363 + unsigned long sp = (unsigned long)&sp, stack_left;
20364 +
20365 + /* all kernel stacks are of the same size */
20366 + stack_left = sp & (THREAD_SIZE - 1);
20367 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20368 +}
20369 +EXPORT_SYMBOL(pax_check_alloca);
20370 +#endif
20371 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20372 index addb207..99635fa 100644
20373 --- a/arch/x86/kernel/dumpstack_64.c
20374 +++ b/arch/x86/kernel/dumpstack_64.c
20375 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20376 unsigned long *irq_stack_end =
20377 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20378 unsigned used = 0;
20379 - struct thread_info *tinfo;
20380 int graph = 0;
20381 unsigned long dummy;
20382 + void *stack_start;
20383
20384 if (!task)
20385 task = current;
20386 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20387 * current stack address. If the stacks consist of nested
20388 * exceptions
20389 */
20390 - tinfo = task_thread_info(task);
20391 for (;;) {
20392 char *id;
20393 unsigned long *estack_end;
20394 +
20395 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20396 &used, &id);
20397
20398 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20399 if (ops->stack(data, id) < 0)
20400 break;
20401
20402 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20403 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20404 data, estack_end, &graph);
20405 ops->stack(data, "<EOE>");
20406 /*
20407 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20408 * second-to-last pointer (index -2 to end) in the
20409 * exception stack:
20410 */
20411 + if ((u16)estack_end[-1] != __KERNEL_DS)
20412 + goto out;
20413 stack = (unsigned long *) estack_end[-2];
20414 continue;
20415 }
20416 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20417 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20418 if (ops->stack(data, "IRQ") < 0)
20419 break;
20420 - bp = ops->walk_stack(tinfo, stack, bp,
20421 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20422 ops, data, irq_stack_end, &graph);
20423 /*
20424 * We link to the next stack (which would be
20425 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20426 /*
20427 * This handles the process stack:
20428 */
20429 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20430 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20431 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20432 +out:
20433 put_cpu();
20434 }
20435 EXPORT_SYMBOL(dump_trace);
20436 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20437
20438 return ud2 == 0x0b0f;
20439 }
20440 +
20441 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20442 +void pax_check_alloca(unsigned long size)
20443 +{
20444 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20445 + unsigned cpu, used;
20446 + char *id;
20447 +
20448 + /* check the process stack first */
20449 + stack_start = (unsigned long)task_stack_page(current);
20450 + stack_end = stack_start + THREAD_SIZE;
20451 + if (likely(stack_start <= sp && sp < stack_end)) {
20452 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20453 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20454 + return;
20455 + }
20456 +
20457 + cpu = get_cpu();
20458 +
20459 + /* check the irq stacks */
20460 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20461 + stack_start = stack_end - IRQ_STACK_SIZE;
20462 + if (stack_start <= sp && sp < stack_end) {
20463 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20464 + put_cpu();
20465 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20466 + return;
20467 + }
20468 +
20469 + /* check the exception stacks */
20470 + used = 0;
20471 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20472 + stack_start = stack_end - EXCEPTION_STKSZ;
20473 + if (stack_end && stack_start <= sp && sp < stack_end) {
20474 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20475 + put_cpu();
20476 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20477 + return;
20478 + }
20479 +
20480 + put_cpu();
20481 +
20482 + /* unknown stack */
20483 + BUG();
20484 +}
20485 +EXPORT_SYMBOL(pax_check_alloca);
20486 +#endif
20487 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20488 index d32abea..74daf4f 100644
20489 --- a/arch/x86/kernel/e820.c
20490 +++ b/arch/x86/kernel/e820.c
20491 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20492
20493 static void early_panic(char *msg)
20494 {
20495 - early_printk(msg);
20496 - panic(msg);
20497 + early_printk("%s", msg);
20498 + panic("%s", msg);
20499 }
20500
20501 static int userdef __initdata;
20502 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20503 index d15f575..d692043 100644
20504 --- a/arch/x86/kernel/early_printk.c
20505 +++ b/arch/x86/kernel/early_printk.c
20506 @@ -7,6 +7,7 @@
20507 #include <linux/pci_regs.h>
20508 #include <linux/pci_ids.h>
20509 #include <linux/errno.h>
20510 +#include <linux/sched.h>
20511 #include <asm/io.h>
20512 #include <asm/processor.h>
20513 #include <asm/fcntl.h>
20514 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20515 index 2cfbc3a..b756682 100644
20516 --- a/arch/x86/kernel/entry_32.S
20517 +++ b/arch/x86/kernel/entry_32.S
20518 @@ -177,13 +177,153 @@
20519 /*CFI_REL_OFFSET gs, PT_GS*/
20520 .endm
20521 .macro SET_KERNEL_GS reg
20522 +
20523 +#ifdef CONFIG_CC_STACKPROTECTOR
20524 movl $(__KERNEL_STACK_CANARY), \reg
20525 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20526 + movl $(__USER_DS), \reg
20527 +#else
20528 + xorl \reg, \reg
20529 +#endif
20530 +
20531 movl \reg, %gs
20532 .endm
20533
20534 #endif /* CONFIG_X86_32_LAZY_GS */
20535
20536 -.macro SAVE_ALL
20537 +.macro pax_enter_kernel
20538 +#ifdef CONFIG_PAX_KERNEXEC
20539 + call pax_enter_kernel
20540 +#endif
20541 +.endm
20542 +
20543 +.macro pax_exit_kernel
20544 +#ifdef CONFIG_PAX_KERNEXEC
20545 + call pax_exit_kernel
20546 +#endif
20547 +.endm
20548 +
20549 +#ifdef CONFIG_PAX_KERNEXEC
20550 +ENTRY(pax_enter_kernel)
20551 +#ifdef CONFIG_PARAVIRT
20552 + pushl %eax
20553 + pushl %ecx
20554 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20555 + mov %eax, %esi
20556 +#else
20557 + mov %cr0, %esi
20558 +#endif
20559 + bts $16, %esi
20560 + jnc 1f
20561 + mov %cs, %esi
20562 + cmp $__KERNEL_CS, %esi
20563 + jz 3f
20564 + ljmp $__KERNEL_CS, $3f
20565 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20566 +2:
20567 +#ifdef CONFIG_PARAVIRT
20568 + mov %esi, %eax
20569 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20570 +#else
20571 + mov %esi, %cr0
20572 +#endif
20573 +3:
20574 +#ifdef CONFIG_PARAVIRT
20575 + popl %ecx
20576 + popl %eax
20577 +#endif
20578 + ret
20579 +ENDPROC(pax_enter_kernel)
20580 +
20581 +ENTRY(pax_exit_kernel)
20582 +#ifdef CONFIG_PARAVIRT
20583 + pushl %eax
20584 + pushl %ecx
20585 +#endif
20586 + mov %cs, %esi
20587 + cmp $__KERNEXEC_KERNEL_CS, %esi
20588 + jnz 2f
20589 +#ifdef CONFIG_PARAVIRT
20590 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20591 + mov %eax, %esi
20592 +#else
20593 + mov %cr0, %esi
20594 +#endif
20595 + btr $16, %esi
20596 + ljmp $__KERNEL_CS, $1f
20597 +1:
20598 +#ifdef CONFIG_PARAVIRT
20599 + mov %esi, %eax
20600 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20601 +#else
20602 + mov %esi, %cr0
20603 +#endif
20604 +2:
20605 +#ifdef CONFIG_PARAVIRT
20606 + popl %ecx
20607 + popl %eax
20608 +#endif
20609 + ret
20610 +ENDPROC(pax_exit_kernel)
20611 +#endif
20612 +
20613 + .macro pax_erase_kstack
20614 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20615 + call pax_erase_kstack
20616 +#endif
20617 + .endm
20618 +
20619 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20620 +/*
20621 + * ebp: thread_info
20622 + */
20623 +ENTRY(pax_erase_kstack)
20624 + pushl %edi
20625 + pushl %ecx
20626 + pushl %eax
20627 +
20628 + mov TI_lowest_stack(%ebp), %edi
20629 + mov $-0xBEEF, %eax
20630 + std
20631 +
20632 +1: mov %edi, %ecx
20633 + and $THREAD_SIZE_asm - 1, %ecx
20634 + shr $2, %ecx
20635 + repne scasl
20636 + jecxz 2f
20637 +
20638 + cmp $2*16, %ecx
20639 + jc 2f
20640 +
20641 + mov $2*16, %ecx
20642 + repe scasl
20643 + jecxz 2f
20644 + jne 1b
20645 +
20646 +2: cld
20647 + mov %esp, %ecx
20648 + sub %edi, %ecx
20649 +
20650 + cmp $THREAD_SIZE_asm, %ecx
20651 + jb 3f
20652 + ud2
20653 +3:
20654 +
20655 + shr $2, %ecx
20656 + rep stosl
20657 +
20658 + mov TI_task_thread_sp0(%ebp), %edi
20659 + sub $128, %edi
20660 + mov %edi, TI_lowest_stack(%ebp)
20661 +
20662 + popl %eax
20663 + popl %ecx
20664 + popl %edi
20665 + ret
20666 +ENDPROC(pax_erase_kstack)
20667 +#endif
20668 +
20669 +.macro __SAVE_ALL _DS
20670 cld
20671 PUSH_GS
20672 pushl_cfi %fs
20673 @@ -206,7 +346,7 @@
20674 CFI_REL_OFFSET ecx, 0
20675 pushl_cfi %ebx
20676 CFI_REL_OFFSET ebx, 0
20677 - movl $(__USER_DS), %edx
20678 + movl $\_DS, %edx
20679 movl %edx, %ds
20680 movl %edx, %es
20681 movl $(__KERNEL_PERCPU), %edx
20682 @@ -214,6 +354,15 @@
20683 SET_KERNEL_GS %edx
20684 .endm
20685
20686 +.macro SAVE_ALL
20687 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20688 + __SAVE_ALL __KERNEL_DS
20689 + pax_enter_kernel
20690 +#else
20691 + __SAVE_ALL __USER_DS
20692 +#endif
20693 +.endm
20694 +
20695 .macro RESTORE_INT_REGS
20696 popl_cfi %ebx
20697 CFI_RESTORE ebx
20698 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20699 popfl_cfi
20700 jmp syscall_exit
20701 CFI_ENDPROC
20702 -END(ret_from_fork)
20703 +ENDPROC(ret_from_fork)
20704
20705 ENTRY(ret_from_kernel_thread)
20706 CFI_STARTPROC
20707 @@ -344,7 +493,15 @@ ret_from_intr:
20708 andl $SEGMENT_RPL_MASK, %eax
20709 #endif
20710 cmpl $USER_RPL, %eax
20711 +
20712 +#ifdef CONFIG_PAX_KERNEXEC
20713 + jae resume_userspace
20714 +
20715 + pax_exit_kernel
20716 + jmp resume_kernel
20717 +#else
20718 jb resume_kernel # not returning to v8086 or userspace
20719 +#endif
20720
20721 ENTRY(resume_userspace)
20722 LOCKDEP_SYS_EXIT
20723 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20724 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20725 # int/exception return?
20726 jne work_pending
20727 - jmp restore_all
20728 -END(ret_from_exception)
20729 + jmp restore_all_pax
20730 +ENDPROC(ret_from_exception)
20731
20732 #ifdef CONFIG_PREEMPT
20733 ENTRY(resume_kernel)
20734 @@ -372,7 +529,7 @@ need_resched:
20735 jz restore_all
20736 call preempt_schedule_irq
20737 jmp need_resched
20738 -END(resume_kernel)
20739 +ENDPROC(resume_kernel)
20740 #endif
20741 CFI_ENDPROC
20742 /*
20743 @@ -406,30 +563,45 @@ sysenter_past_esp:
20744 /*CFI_REL_OFFSET cs, 0*/
20745 /*
20746 * Push current_thread_info()->sysenter_return to the stack.
20747 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20748 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20749 */
20750 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20751 + pushl_cfi $0
20752 CFI_REL_OFFSET eip, 0
20753
20754 pushl_cfi %eax
20755 SAVE_ALL
20756 + GET_THREAD_INFO(%ebp)
20757 + movl TI_sysenter_return(%ebp),%ebp
20758 + movl %ebp,PT_EIP(%esp)
20759 ENABLE_INTERRUPTS(CLBR_NONE)
20760
20761 /*
20762 * Load the potential sixth argument from user stack.
20763 * Careful about security.
20764 */
20765 + movl PT_OLDESP(%esp),%ebp
20766 +
20767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20768 + mov PT_OLDSS(%esp),%ds
20769 +1: movl %ds:(%ebp),%ebp
20770 + push %ss
20771 + pop %ds
20772 +#else
20773 cmpl $__PAGE_OFFSET-3,%ebp
20774 jae syscall_fault
20775 ASM_STAC
20776 1: movl (%ebp),%ebp
20777 ASM_CLAC
20778 +#endif
20779 +
20780 movl %ebp,PT_EBP(%esp)
20781 _ASM_EXTABLE(1b,syscall_fault)
20782
20783 GET_THREAD_INFO(%ebp)
20784
20785 +#ifdef CONFIG_PAX_RANDKSTACK
20786 + pax_erase_kstack
20787 +#endif
20788 +
20789 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20790 jnz sysenter_audit
20791 sysenter_do_call:
20792 @@ -444,12 +616,24 @@ sysenter_do_call:
20793 testl $_TIF_ALLWORK_MASK, %ecx
20794 jne sysexit_audit
20795 sysenter_exit:
20796 +
20797 +#ifdef CONFIG_PAX_RANDKSTACK
20798 + pushl_cfi %eax
20799 + movl %esp, %eax
20800 + call pax_randomize_kstack
20801 + popl_cfi %eax
20802 +#endif
20803 +
20804 + pax_erase_kstack
20805 +
20806 /* if something modifies registers it must also disable sysexit */
20807 movl PT_EIP(%esp), %edx
20808 movl PT_OLDESP(%esp), %ecx
20809 xorl %ebp,%ebp
20810 TRACE_IRQS_ON
20811 1: mov PT_FS(%esp), %fs
20812 +2: mov PT_DS(%esp), %ds
20813 +3: mov PT_ES(%esp), %es
20814 PTGS_TO_GS
20815 ENABLE_INTERRUPTS_SYSEXIT
20816
20817 @@ -466,6 +650,9 @@ sysenter_audit:
20818 movl %eax,%edx /* 2nd arg: syscall number */
20819 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20820 call __audit_syscall_entry
20821 +
20822 + pax_erase_kstack
20823 +
20824 pushl_cfi %ebx
20825 movl PT_EAX(%esp),%eax /* reload syscall number */
20826 jmp sysenter_do_call
20827 @@ -491,10 +678,16 @@ sysexit_audit:
20828
20829 CFI_ENDPROC
20830 .pushsection .fixup,"ax"
20831 -2: movl $0,PT_FS(%esp)
20832 +4: movl $0,PT_FS(%esp)
20833 + jmp 1b
20834 +5: movl $0,PT_DS(%esp)
20835 + jmp 1b
20836 +6: movl $0,PT_ES(%esp)
20837 jmp 1b
20838 .popsection
20839 - _ASM_EXTABLE(1b,2b)
20840 + _ASM_EXTABLE(1b,4b)
20841 + _ASM_EXTABLE(2b,5b)
20842 + _ASM_EXTABLE(3b,6b)
20843 PTGS_TO_GS_EX
20844 ENDPROC(ia32_sysenter_target)
20845
20846 @@ -509,6 +702,11 @@ ENTRY(system_call)
20847 pushl_cfi %eax # save orig_eax
20848 SAVE_ALL
20849 GET_THREAD_INFO(%ebp)
20850 +
20851 +#ifdef CONFIG_PAX_RANDKSTACK
20852 + pax_erase_kstack
20853 +#endif
20854 +
20855 # system call tracing in operation / emulation
20856 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20857 jnz syscall_trace_entry
20858 @@ -527,6 +725,15 @@ syscall_exit:
20859 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20860 jne syscall_exit_work
20861
20862 +restore_all_pax:
20863 +
20864 +#ifdef CONFIG_PAX_RANDKSTACK
20865 + movl %esp, %eax
20866 + call pax_randomize_kstack
20867 +#endif
20868 +
20869 + pax_erase_kstack
20870 +
20871 restore_all:
20872 TRACE_IRQS_IRET
20873 restore_all_notrace:
20874 @@ -583,14 +790,34 @@ ldt_ss:
20875 * compensating for the offset by changing to the ESPFIX segment with
20876 * a base address that matches for the difference.
20877 */
20878 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20879 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20880 mov %esp, %edx /* load kernel esp */
20881 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20882 mov %dx, %ax /* eax: new kernel esp */
20883 sub %eax, %edx /* offset (low word is 0) */
20884 +#ifdef CONFIG_SMP
20885 + movl PER_CPU_VAR(cpu_number), %ebx
20886 + shll $PAGE_SHIFT_asm, %ebx
20887 + addl $cpu_gdt_table, %ebx
20888 +#else
20889 + movl $cpu_gdt_table, %ebx
20890 +#endif
20891 shr $16, %edx
20892 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20893 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20894 +
20895 +#ifdef CONFIG_PAX_KERNEXEC
20896 + mov %cr0, %esi
20897 + btr $16, %esi
20898 + mov %esi, %cr0
20899 +#endif
20900 +
20901 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20902 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20903 +
20904 +#ifdef CONFIG_PAX_KERNEXEC
20905 + bts $16, %esi
20906 + mov %esi, %cr0
20907 +#endif
20908 +
20909 pushl_cfi $__ESPFIX_SS
20910 pushl_cfi %eax /* new kernel esp */
20911 /* Disable interrupts, but do not irqtrace this section: we
20912 @@ -619,20 +846,18 @@ work_resched:
20913 movl TI_flags(%ebp), %ecx
20914 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20915 # than syscall tracing?
20916 - jz restore_all
20917 + jz restore_all_pax
20918 testb $_TIF_NEED_RESCHED, %cl
20919 jnz work_resched
20920
20921 work_notifysig: # deal with pending signals and
20922 # notify-resume requests
20923 + movl %esp, %eax
20924 #ifdef CONFIG_VM86
20925 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20926 - movl %esp, %eax
20927 jne work_notifysig_v86 # returning to kernel-space or
20928 # vm86-space
20929 1:
20930 -#else
20931 - movl %esp, %eax
20932 #endif
20933 TRACE_IRQS_ON
20934 ENABLE_INTERRUPTS(CLBR_NONE)
20935 @@ -653,7 +878,7 @@ work_notifysig_v86:
20936 movl %eax, %esp
20937 jmp 1b
20938 #endif
20939 -END(work_pending)
20940 +ENDPROC(work_pending)
20941
20942 # perform syscall exit tracing
20943 ALIGN
20944 @@ -661,11 +886,14 @@ syscall_trace_entry:
20945 movl $-ENOSYS,PT_EAX(%esp)
20946 movl %esp, %eax
20947 call syscall_trace_enter
20948 +
20949 + pax_erase_kstack
20950 +
20951 /* What it returned is what we'll actually use. */
20952 cmpl $(NR_syscalls), %eax
20953 jnae syscall_call
20954 jmp syscall_exit
20955 -END(syscall_trace_entry)
20956 +ENDPROC(syscall_trace_entry)
20957
20958 # perform syscall exit tracing
20959 ALIGN
20960 @@ -678,21 +906,25 @@ syscall_exit_work:
20961 movl %esp, %eax
20962 call syscall_trace_leave
20963 jmp resume_userspace
20964 -END(syscall_exit_work)
20965 +ENDPROC(syscall_exit_work)
20966 CFI_ENDPROC
20967
20968 RING0_INT_FRAME # can't unwind into user space anyway
20969 syscall_fault:
20970 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20971 + push %ss
20972 + pop %ds
20973 +#endif
20974 ASM_CLAC
20975 GET_THREAD_INFO(%ebp)
20976 movl $-EFAULT,PT_EAX(%esp)
20977 jmp resume_userspace
20978 -END(syscall_fault)
20979 +ENDPROC(syscall_fault)
20980
20981 syscall_badsys:
20982 movl $-ENOSYS,PT_EAX(%esp)
20983 jmp resume_userspace
20984 -END(syscall_badsys)
20985 +ENDPROC(syscall_badsys)
20986 CFI_ENDPROC
20987 /*
20988 * End of kprobes section
20989 @@ -708,8 +940,15 @@ END(syscall_badsys)
20990 * normal stack and adjusts ESP with the matching offset.
20991 */
20992 /* fixup the stack */
20993 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20994 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
20995 +#ifdef CONFIG_SMP
20996 + movl PER_CPU_VAR(cpu_number), %ebx
20997 + shll $PAGE_SHIFT_asm, %ebx
20998 + addl $cpu_gdt_table, %ebx
20999 +#else
21000 + movl $cpu_gdt_table, %ebx
21001 +#endif
21002 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21003 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21004 shl $16, %eax
21005 addl %esp, %eax /* the adjusted stack pointer */
21006 pushl_cfi $__KERNEL_DS
21007 @@ -762,7 +1001,7 @@ vector=vector+1
21008 .endr
21009 2: jmp common_interrupt
21010 .endr
21011 -END(irq_entries_start)
21012 +ENDPROC(irq_entries_start)
21013
21014 .previous
21015 END(interrupt)
21016 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21017 pushl_cfi $do_coprocessor_error
21018 jmp error_code
21019 CFI_ENDPROC
21020 -END(coprocessor_error)
21021 +ENDPROC(coprocessor_error)
21022
21023 ENTRY(simd_coprocessor_error)
21024 RING0_INT_FRAME
21025 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21026 .section .altinstructions,"a"
21027 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21028 .previous
21029 -.section .altinstr_replacement,"ax"
21030 +.section .altinstr_replacement,"a"
21031 663: pushl $do_simd_coprocessor_error
21032 664:
21033 .previous
21034 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21035 #endif
21036 jmp error_code
21037 CFI_ENDPROC
21038 -END(simd_coprocessor_error)
21039 +ENDPROC(simd_coprocessor_error)
21040
21041 ENTRY(device_not_available)
21042 RING0_INT_FRAME
21043 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21044 pushl_cfi $do_device_not_available
21045 jmp error_code
21046 CFI_ENDPROC
21047 -END(device_not_available)
21048 +ENDPROC(device_not_available)
21049
21050 #ifdef CONFIG_PARAVIRT
21051 ENTRY(native_iret)
21052 iret
21053 _ASM_EXTABLE(native_iret, iret_exc)
21054 -END(native_iret)
21055 +ENDPROC(native_iret)
21056
21057 ENTRY(native_irq_enable_sysexit)
21058 sti
21059 sysexit
21060 -END(native_irq_enable_sysexit)
21061 +ENDPROC(native_irq_enable_sysexit)
21062 #endif
21063
21064 ENTRY(overflow)
21065 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21066 pushl_cfi $do_overflow
21067 jmp error_code
21068 CFI_ENDPROC
21069 -END(overflow)
21070 +ENDPROC(overflow)
21071
21072 ENTRY(bounds)
21073 RING0_INT_FRAME
21074 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21075 pushl_cfi $do_bounds
21076 jmp error_code
21077 CFI_ENDPROC
21078 -END(bounds)
21079 +ENDPROC(bounds)
21080
21081 ENTRY(invalid_op)
21082 RING0_INT_FRAME
21083 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21084 pushl_cfi $do_invalid_op
21085 jmp error_code
21086 CFI_ENDPROC
21087 -END(invalid_op)
21088 +ENDPROC(invalid_op)
21089
21090 ENTRY(coprocessor_segment_overrun)
21091 RING0_INT_FRAME
21092 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21093 pushl_cfi $do_coprocessor_segment_overrun
21094 jmp error_code
21095 CFI_ENDPROC
21096 -END(coprocessor_segment_overrun)
21097 +ENDPROC(coprocessor_segment_overrun)
21098
21099 ENTRY(invalid_TSS)
21100 RING0_EC_FRAME
21101 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21102 pushl_cfi $do_invalid_TSS
21103 jmp error_code
21104 CFI_ENDPROC
21105 -END(invalid_TSS)
21106 +ENDPROC(invalid_TSS)
21107
21108 ENTRY(segment_not_present)
21109 RING0_EC_FRAME
21110 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21111 pushl_cfi $do_segment_not_present
21112 jmp error_code
21113 CFI_ENDPROC
21114 -END(segment_not_present)
21115 +ENDPROC(segment_not_present)
21116
21117 ENTRY(stack_segment)
21118 RING0_EC_FRAME
21119 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21120 pushl_cfi $do_stack_segment
21121 jmp error_code
21122 CFI_ENDPROC
21123 -END(stack_segment)
21124 +ENDPROC(stack_segment)
21125
21126 ENTRY(alignment_check)
21127 RING0_EC_FRAME
21128 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21129 pushl_cfi $do_alignment_check
21130 jmp error_code
21131 CFI_ENDPROC
21132 -END(alignment_check)
21133 +ENDPROC(alignment_check)
21134
21135 ENTRY(divide_error)
21136 RING0_INT_FRAME
21137 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21138 pushl_cfi $do_divide_error
21139 jmp error_code
21140 CFI_ENDPROC
21141 -END(divide_error)
21142 +ENDPROC(divide_error)
21143
21144 #ifdef CONFIG_X86_MCE
21145 ENTRY(machine_check)
21146 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21147 pushl_cfi machine_check_vector
21148 jmp error_code
21149 CFI_ENDPROC
21150 -END(machine_check)
21151 +ENDPROC(machine_check)
21152 #endif
21153
21154 ENTRY(spurious_interrupt_bug)
21155 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21156 pushl_cfi $do_spurious_interrupt_bug
21157 jmp error_code
21158 CFI_ENDPROC
21159 -END(spurious_interrupt_bug)
21160 +ENDPROC(spurious_interrupt_bug)
21161 /*
21162 * End of kprobes section
21163 */
21164 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21165
21166 ENTRY(mcount)
21167 ret
21168 -END(mcount)
21169 +ENDPROC(mcount)
21170
21171 ENTRY(ftrace_caller)
21172 cmpl $0, function_trace_stop
21173 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21174 .globl ftrace_stub
21175 ftrace_stub:
21176 ret
21177 -END(ftrace_caller)
21178 +ENDPROC(ftrace_caller)
21179
21180 ENTRY(ftrace_regs_caller)
21181 pushf /* push flags before compare (in cs location) */
21182 @@ -1207,7 +1446,7 @@ trace:
21183 popl %ecx
21184 popl %eax
21185 jmp ftrace_stub
21186 -END(mcount)
21187 +ENDPROC(mcount)
21188 #endif /* CONFIG_DYNAMIC_FTRACE */
21189 #endif /* CONFIG_FUNCTION_TRACER */
21190
21191 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21192 popl %ecx
21193 popl %eax
21194 ret
21195 -END(ftrace_graph_caller)
21196 +ENDPROC(ftrace_graph_caller)
21197
21198 .globl return_to_handler
21199 return_to_handler:
21200 @@ -1281,15 +1520,18 @@ error_code:
21201 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21202 REG_TO_PTGS %ecx
21203 SET_KERNEL_GS %ecx
21204 - movl $(__USER_DS), %ecx
21205 + movl $(__KERNEL_DS), %ecx
21206 movl %ecx, %ds
21207 movl %ecx, %es
21208 +
21209 + pax_enter_kernel
21210 +
21211 TRACE_IRQS_OFF
21212 movl %esp,%eax # pt_regs pointer
21213 call *%edi
21214 jmp ret_from_exception
21215 CFI_ENDPROC
21216 -END(page_fault)
21217 +ENDPROC(page_fault)
21218
21219 /*
21220 * Debug traps and NMI can happen at the one SYSENTER instruction
21221 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21222 call do_debug
21223 jmp ret_from_exception
21224 CFI_ENDPROC
21225 -END(debug)
21226 +ENDPROC(debug)
21227
21228 /*
21229 * NMI is doubly nasty. It can happen _while_ we're handling
21230 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21231 xorl %edx,%edx # zero error code
21232 movl %esp,%eax # pt_regs pointer
21233 call do_nmi
21234 +
21235 + pax_exit_kernel
21236 +
21237 jmp restore_all_notrace
21238 CFI_ENDPROC
21239
21240 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21241 FIXUP_ESPFIX_STACK # %eax == %esp
21242 xorl %edx,%edx # zero error code
21243 call do_nmi
21244 +
21245 + pax_exit_kernel
21246 +
21247 RESTORE_REGS
21248 lss 12+4(%esp), %esp # back to espfix stack
21249 CFI_ADJUST_CFA_OFFSET -24
21250 jmp irq_return
21251 CFI_ENDPROC
21252 -END(nmi)
21253 +ENDPROC(nmi)
21254
21255 ENTRY(int3)
21256 RING0_INT_FRAME
21257 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21258 call do_int3
21259 jmp ret_from_exception
21260 CFI_ENDPROC
21261 -END(int3)
21262 +ENDPROC(int3)
21263
21264 ENTRY(general_protection)
21265 RING0_EC_FRAME
21266 pushl_cfi $do_general_protection
21267 jmp error_code
21268 CFI_ENDPROC
21269 -END(general_protection)
21270 +ENDPROC(general_protection)
21271
21272 #ifdef CONFIG_KVM_GUEST
21273 ENTRY(async_page_fault)
21274 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21275 pushl_cfi $do_async_page_fault
21276 jmp error_code
21277 CFI_ENDPROC
21278 -END(async_page_fault)
21279 +ENDPROC(async_page_fault)
21280 #endif
21281
21282 /*
21283 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21284 index 1b69951..8430a6d 100644
21285 --- a/arch/x86/kernel/entry_64.S
21286 +++ b/arch/x86/kernel/entry_64.S
21287 @@ -59,6 +59,8 @@
21288 #include <asm/context_tracking.h>
21289 #include <asm/smap.h>
21290 #include <linux/err.h>
21291 +#include <asm/pgtable.h>
21292 +#include <asm/alternative-asm.h>
21293
21294 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21295 #include <linux/elf-em.h>
21296 @@ -80,8 +82,9 @@
21297 #ifdef CONFIG_DYNAMIC_FTRACE
21298
21299 ENTRY(function_hook)
21300 + pax_force_retaddr
21301 retq
21302 -END(function_hook)
21303 +ENDPROC(function_hook)
21304
21305 /* skip is set if stack has been adjusted */
21306 .macro ftrace_caller_setup skip=0
21307 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21308 #endif
21309
21310 GLOBAL(ftrace_stub)
21311 + pax_force_retaddr
21312 retq
21313 -END(ftrace_caller)
21314 +ENDPROC(ftrace_caller)
21315
21316 ENTRY(ftrace_regs_caller)
21317 /* Save the current flags before compare (in SS location)*/
21318 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21319 popfq
21320 jmp ftrace_stub
21321
21322 -END(ftrace_regs_caller)
21323 +ENDPROC(ftrace_regs_caller)
21324
21325
21326 #else /* ! CONFIG_DYNAMIC_FTRACE */
21327 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21328 #endif
21329
21330 GLOBAL(ftrace_stub)
21331 + pax_force_retaddr
21332 retq
21333
21334 trace:
21335 @@ -225,12 +230,13 @@ trace:
21336 #endif
21337 subq $MCOUNT_INSN_SIZE, %rdi
21338
21339 + pax_force_fptr ftrace_trace_function
21340 call *ftrace_trace_function
21341
21342 MCOUNT_RESTORE_FRAME
21343
21344 jmp ftrace_stub
21345 -END(function_hook)
21346 +ENDPROC(function_hook)
21347 #endif /* CONFIG_DYNAMIC_FTRACE */
21348 #endif /* CONFIG_FUNCTION_TRACER */
21349
21350 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21351
21352 MCOUNT_RESTORE_FRAME
21353
21354 + pax_force_retaddr
21355 retq
21356 -END(ftrace_graph_caller)
21357 +ENDPROC(ftrace_graph_caller)
21358
21359 GLOBAL(return_to_handler)
21360 subq $24, %rsp
21361 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21362 movq 8(%rsp), %rdx
21363 movq (%rsp), %rax
21364 addq $24, %rsp
21365 + pax_force_fptr %rdi
21366 jmp *%rdi
21367 +ENDPROC(return_to_handler)
21368 #endif
21369
21370
21371 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21372 ENDPROC(native_usergs_sysret64)
21373 #endif /* CONFIG_PARAVIRT */
21374
21375 + .macro ljmpq sel, off
21376 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21377 + .byte 0x48; ljmp *1234f(%rip)
21378 + .pushsection .rodata
21379 + .align 16
21380 + 1234: .quad \off; .word \sel
21381 + .popsection
21382 +#else
21383 + pushq $\sel
21384 + pushq $\off
21385 + lretq
21386 +#endif
21387 + .endm
21388 +
21389 + .macro pax_enter_kernel
21390 + pax_set_fptr_mask
21391 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21392 + call pax_enter_kernel
21393 +#endif
21394 + .endm
21395 +
21396 + .macro pax_exit_kernel
21397 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21398 + call pax_exit_kernel
21399 +#endif
21400 +
21401 + .endm
21402 +
21403 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21404 +ENTRY(pax_enter_kernel)
21405 + pushq %rdi
21406 +
21407 +#ifdef CONFIG_PARAVIRT
21408 + PV_SAVE_REGS(CLBR_RDI)
21409 +#endif
21410 +
21411 +#ifdef CONFIG_PAX_KERNEXEC
21412 + GET_CR0_INTO_RDI
21413 + bts $16,%rdi
21414 + jnc 3f
21415 + mov %cs,%edi
21416 + cmp $__KERNEL_CS,%edi
21417 + jnz 2f
21418 +1:
21419 +#endif
21420 +
21421 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21422 + 661: jmp 111f
21423 + .pushsection .altinstr_replacement, "a"
21424 + 662: ASM_NOP2
21425 + .popsection
21426 + .pushsection .altinstructions, "a"
21427 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21428 + .popsection
21429 + GET_CR3_INTO_RDI
21430 + cmp $0,%dil
21431 + jnz 112f
21432 + mov $__KERNEL_DS,%edi
21433 + mov %edi,%ss
21434 + jmp 111f
21435 +112: cmp $1,%dil
21436 + jz 113f
21437 + ud2
21438 +113: sub $4097,%rdi
21439 + bts $63,%rdi
21440 + SET_RDI_INTO_CR3
21441 + mov $__UDEREF_KERNEL_DS,%edi
21442 + mov %edi,%ss
21443 +111:
21444 +#endif
21445 +
21446 +#ifdef CONFIG_PARAVIRT
21447 + PV_RESTORE_REGS(CLBR_RDI)
21448 +#endif
21449 +
21450 + popq %rdi
21451 + pax_force_retaddr
21452 + retq
21453 +
21454 +#ifdef CONFIG_PAX_KERNEXEC
21455 +2: ljmpq __KERNEL_CS,1b
21456 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21457 +4: SET_RDI_INTO_CR0
21458 + jmp 1b
21459 +#endif
21460 +ENDPROC(pax_enter_kernel)
21461 +
21462 +ENTRY(pax_exit_kernel)
21463 + pushq %rdi
21464 +
21465 +#ifdef CONFIG_PARAVIRT
21466 + PV_SAVE_REGS(CLBR_RDI)
21467 +#endif
21468 +
21469 +#ifdef CONFIG_PAX_KERNEXEC
21470 + mov %cs,%rdi
21471 + cmp $__KERNEXEC_KERNEL_CS,%edi
21472 + jz 2f
21473 + GET_CR0_INTO_RDI
21474 + bts $16,%rdi
21475 + jnc 4f
21476 +1:
21477 +#endif
21478 +
21479 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21480 + 661: jmp 111f
21481 + .pushsection .altinstr_replacement, "a"
21482 + 662: ASM_NOP2
21483 + .popsection
21484 + .pushsection .altinstructions, "a"
21485 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21486 + .popsection
21487 + mov %ss,%edi
21488 + cmp $__UDEREF_KERNEL_DS,%edi
21489 + jnz 111f
21490 + GET_CR3_INTO_RDI
21491 + cmp $0,%dil
21492 + jz 112f
21493 + ud2
21494 +112: add $4097,%rdi
21495 + bts $63,%rdi
21496 + SET_RDI_INTO_CR3
21497 + mov $__KERNEL_DS,%edi
21498 + mov %edi,%ss
21499 +111:
21500 +#endif
21501 +
21502 +#ifdef CONFIG_PARAVIRT
21503 + PV_RESTORE_REGS(CLBR_RDI);
21504 +#endif
21505 +
21506 + popq %rdi
21507 + pax_force_retaddr
21508 + retq
21509 +
21510 +#ifdef CONFIG_PAX_KERNEXEC
21511 +2: GET_CR0_INTO_RDI
21512 + btr $16,%rdi
21513 + jnc 4f
21514 + ljmpq __KERNEL_CS,3f
21515 +3: SET_RDI_INTO_CR0
21516 + jmp 1b
21517 +4: ud2
21518 + jmp 4b
21519 +#endif
21520 +ENDPROC(pax_exit_kernel)
21521 +#endif
21522 +
21523 + .macro pax_enter_kernel_user
21524 + pax_set_fptr_mask
21525 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21526 + call pax_enter_kernel_user
21527 +#endif
21528 + .endm
21529 +
21530 + .macro pax_exit_kernel_user
21531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21532 + call pax_exit_kernel_user
21533 +#endif
21534 +#ifdef CONFIG_PAX_RANDKSTACK
21535 + pushq %rax
21536 + pushq %r11
21537 + call pax_randomize_kstack
21538 + popq %r11
21539 + popq %rax
21540 +#endif
21541 + .endm
21542 +
21543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21544 +ENTRY(pax_enter_kernel_user)
21545 + pushq %rdi
21546 + pushq %rbx
21547 +
21548 +#ifdef CONFIG_PARAVIRT
21549 + PV_SAVE_REGS(CLBR_RDI)
21550 +#endif
21551 +
21552 + 661: jmp 111f
21553 + .pushsection .altinstr_replacement, "a"
21554 + 662: ASM_NOP2
21555 + .popsection
21556 + .pushsection .altinstructions, "a"
21557 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21558 + .popsection
21559 + GET_CR3_INTO_RDI
21560 + cmp $1,%dil
21561 + jnz 4f
21562 + sub $4097,%rdi
21563 + bts $63,%rdi
21564 + SET_RDI_INTO_CR3
21565 + jmp 3f
21566 +111:
21567 +
21568 + GET_CR3_INTO_RDI
21569 + mov %rdi,%rbx
21570 + add $__START_KERNEL_map,%rbx
21571 + sub phys_base(%rip),%rbx
21572 +
21573 +#ifdef CONFIG_PARAVIRT
21574 + cmpl $0, pv_info+PARAVIRT_enabled
21575 + jz 1f
21576 + pushq %rdi
21577 + i = 0
21578 + .rept USER_PGD_PTRS
21579 + mov i*8(%rbx),%rsi
21580 + mov $0,%sil
21581 + lea i*8(%rbx),%rdi
21582 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21583 + i = i + 1
21584 + .endr
21585 + popq %rdi
21586 + jmp 2f
21587 +1:
21588 +#endif
21589 +
21590 + i = 0
21591 + .rept USER_PGD_PTRS
21592 + movb $0,i*8(%rbx)
21593 + i = i + 1
21594 + .endr
21595 +
21596 +2: SET_RDI_INTO_CR3
21597 +
21598 +#ifdef CONFIG_PAX_KERNEXEC
21599 + GET_CR0_INTO_RDI
21600 + bts $16,%rdi
21601 + SET_RDI_INTO_CR0
21602 +#endif
21603 +
21604 +3:
21605 +
21606 +#ifdef CONFIG_PARAVIRT
21607 + PV_RESTORE_REGS(CLBR_RDI)
21608 +#endif
21609 +
21610 + popq %rbx
21611 + popq %rdi
21612 + pax_force_retaddr
21613 + retq
21614 +4: ud2
21615 +ENDPROC(pax_enter_kernel_user)
21616 +
21617 +ENTRY(pax_exit_kernel_user)
21618 + pushq %rdi
21619 + pushq %rbx
21620 +
21621 +#ifdef CONFIG_PARAVIRT
21622 + PV_SAVE_REGS(CLBR_RDI)
21623 +#endif
21624 +
21625 + GET_CR3_INTO_RDI
21626 + 661: jmp 1f
21627 + .pushsection .altinstr_replacement, "a"
21628 + 662: ASM_NOP2
21629 + .popsection
21630 + .pushsection .altinstructions, "a"
21631 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21632 + .popsection
21633 + cmp $0,%dil
21634 + jnz 3f
21635 + add $4097,%rdi
21636 + bts $63,%rdi
21637 + SET_RDI_INTO_CR3
21638 + jmp 2f
21639 +1:
21640 +
21641 + mov %rdi,%rbx
21642 +
21643 +#ifdef CONFIG_PAX_KERNEXEC
21644 + GET_CR0_INTO_RDI
21645 + btr $16,%rdi
21646 + jnc 3f
21647 + SET_RDI_INTO_CR0
21648 +#endif
21649 +
21650 + add $__START_KERNEL_map,%rbx
21651 + sub phys_base(%rip),%rbx
21652 +
21653 +#ifdef CONFIG_PARAVIRT
21654 + cmpl $0, pv_info+PARAVIRT_enabled
21655 + jz 1f
21656 + i = 0
21657 + .rept USER_PGD_PTRS
21658 + mov i*8(%rbx),%rsi
21659 + mov $0x67,%sil
21660 + lea i*8(%rbx),%rdi
21661 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21662 + i = i + 1
21663 + .endr
21664 + jmp 2f
21665 +1:
21666 +#endif
21667 +
21668 + i = 0
21669 + .rept USER_PGD_PTRS
21670 + movb $0x67,i*8(%rbx)
21671 + i = i + 1
21672 + .endr
21673 +2:
21674 +
21675 +#ifdef CONFIG_PARAVIRT
21676 + PV_RESTORE_REGS(CLBR_RDI)
21677 +#endif
21678 +
21679 + popq %rbx
21680 + popq %rdi
21681 + pax_force_retaddr
21682 + retq
21683 +3: ud2
21684 +ENDPROC(pax_exit_kernel_user)
21685 +#endif
21686 +
21687 + .macro pax_enter_kernel_nmi
21688 + pax_set_fptr_mask
21689 +
21690 +#ifdef CONFIG_PAX_KERNEXEC
21691 + GET_CR0_INTO_RDI
21692 + bts $16,%rdi
21693 + jc 110f
21694 + SET_RDI_INTO_CR0
21695 + or $2,%ebx
21696 +110:
21697 +#endif
21698 +
21699 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21700 + 661: jmp 111f
21701 + .pushsection .altinstr_replacement, "a"
21702 + 662: ASM_NOP2
21703 + .popsection
21704 + .pushsection .altinstructions, "a"
21705 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21706 + .popsection
21707 + GET_CR3_INTO_RDI
21708 + cmp $0,%dil
21709 + jz 111f
21710 + sub $4097,%rdi
21711 + or $4,%ebx
21712 + bts $63,%rdi
21713 + SET_RDI_INTO_CR3
21714 + mov $__UDEREF_KERNEL_DS,%edi
21715 + mov %edi,%ss
21716 +111:
21717 +#endif
21718 + .endm
21719 +
21720 + .macro pax_exit_kernel_nmi
21721 +#ifdef CONFIG_PAX_KERNEXEC
21722 + btr $1,%ebx
21723 + jnc 110f
21724 + GET_CR0_INTO_RDI
21725 + btr $16,%rdi
21726 + SET_RDI_INTO_CR0
21727 +110:
21728 +#endif
21729 +
21730 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21731 + btr $2,%ebx
21732 + jnc 111f
21733 + GET_CR3_INTO_RDI
21734 + add $4097,%rdi
21735 + bts $63,%rdi
21736 + SET_RDI_INTO_CR3
21737 + mov $__KERNEL_DS,%edi
21738 + mov %edi,%ss
21739 +111:
21740 +#endif
21741 + .endm
21742 +
21743 + .macro pax_erase_kstack
21744 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21745 + call pax_erase_kstack
21746 +#endif
21747 + .endm
21748 +
21749 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21750 +ENTRY(pax_erase_kstack)
21751 + pushq %rdi
21752 + pushq %rcx
21753 + pushq %rax
21754 + pushq %r11
21755 +
21756 + GET_THREAD_INFO(%r11)
21757 + mov TI_lowest_stack(%r11), %rdi
21758 + mov $-0xBEEF, %rax
21759 + std
21760 +
21761 +1: mov %edi, %ecx
21762 + and $THREAD_SIZE_asm - 1, %ecx
21763 + shr $3, %ecx
21764 + repne scasq
21765 + jecxz 2f
21766 +
21767 + cmp $2*8, %ecx
21768 + jc 2f
21769 +
21770 + mov $2*8, %ecx
21771 + repe scasq
21772 + jecxz 2f
21773 + jne 1b
21774 +
21775 +2: cld
21776 + mov %esp, %ecx
21777 + sub %edi, %ecx
21778 +
21779 + cmp $THREAD_SIZE_asm, %rcx
21780 + jb 3f
21781 + ud2
21782 +3:
21783 +
21784 + shr $3, %ecx
21785 + rep stosq
21786 +
21787 + mov TI_task_thread_sp0(%r11), %rdi
21788 + sub $256, %rdi
21789 + mov %rdi, TI_lowest_stack(%r11)
21790 +
21791 + popq %r11
21792 + popq %rax
21793 + popq %rcx
21794 + popq %rdi
21795 + pax_force_retaddr
21796 + ret
21797 +ENDPROC(pax_erase_kstack)
21798 +#endif
21799
21800 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21801 #ifdef CONFIG_TRACE_IRQFLAGS
21802 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21803 .endm
21804
21805 .macro UNFAKE_STACK_FRAME
21806 - addq $8*6, %rsp
21807 - CFI_ADJUST_CFA_OFFSET -(6*8)
21808 + addq $8*6 + ARG_SKIP, %rsp
21809 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21810 .endm
21811
21812 /*
21813 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21814 movq %rsp, %rsi
21815
21816 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21817 - testl $3, CS-RBP(%rsi)
21818 + testb $3, CS-RBP(%rsi)
21819 je 1f
21820 SWAPGS
21821 /*
21822 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21823 movq_cfi r15, R15+16
21824 movq %r11, 8(%rsp) /* return address */
21825 FIXUP_TOP_OF_STACK %r11, 16
21826 + pax_force_retaddr
21827 ret
21828 CFI_ENDPROC
21829 -END(save_rest)
21830 +ENDPROC(save_rest)
21831
21832 /* save complete stack frame */
21833 .pushsection .kprobes.text, "ax"
21834 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21835 js 1f /* negative -> in kernel */
21836 SWAPGS
21837 xorl %ebx,%ebx
21838 -1: ret
21839 +1: pax_force_retaddr_bts
21840 + ret
21841 CFI_ENDPROC
21842 -END(save_paranoid)
21843 +ENDPROC(save_paranoid)
21844 .popsection
21845
21846 /*
21847 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21848
21849 RESTORE_REST
21850
21851 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21852 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21853 jz 1f
21854
21855 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21856 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21857 RESTORE_REST
21858 jmp int_ret_from_sys_call
21859 CFI_ENDPROC
21860 -END(ret_from_fork)
21861 +ENDPROC(ret_from_fork)
21862
21863 /*
21864 * System call entry. Up to 6 arguments in registers are supported.
21865 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21866 ENTRY(system_call)
21867 CFI_STARTPROC simple
21868 CFI_SIGNAL_FRAME
21869 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21870 + CFI_DEF_CFA rsp,0
21871 CFI_REGISTER rip,rcx
21872 /*CFI_REGISTER rflags,r11*/
21873 SWAPGS_UNSAFE_STACK
21874 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21875
21876 movq %rsp,PER_CPU_VAR(old_rsp)
21877 movq PER_CPU_VAR(kernel_stack),%rsp
21878 + SAVE_ARGS 8*6,0
21879 + pax_enter_kernel_user
21880 +
21881 +#ifdef CONFIG_PAX_RANDKSTACK
21882 + pax_erase_kstack
21883 +#endif
21884 +
21885 /*
21886 * No need to follow this irqs off/on section - it's straight
21887 * and short:
21888 */
21889 ENABLE_INTERRUPTS(CLBR_NONE)
21890 - SAVE_ARGS 8,0
21891 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21892 movq %rcx,RIP-ARGOFFSET(%rsp)
21893 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21894 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21895 + GET_THREAD_INFO(%rcx)
21896 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21897 jnz tracesys
21898 system_call_fastpath:
21899 #if __SYSCALL_MASK == ~0
21900 @@ -640,7 +1082,7 @@ system_call_fastpath:
21901 cmpl $__NR_syscall_max,%eax
21902 #endif
21903 ja badsys
21904 - movq %r10,%rcx
21905 + movq R10-ARGOFFSET(%rsp),%rcx
21906 call *sys_call_table(,%rax,8) # XXX: rip relative
21907 movq %rax,RAX-ARGOFFSET(%rsp)
21908 /*
21909 @@ -654,10 +1096,13 @@ sysret_check:
21910 LOCKDEP_SYS_EXIT
21911 DISABLE_INTERRUPTS(CLBR_NONE)
21912 TRACE_IRQS_OFF
21913 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21914 + GET_THREAD_INFO(%rcx)
21915 + movl TI_flags(%rcx),%edx
21916 andl %edi,%edx
21917 jnz sysret_careful
21918 CFI_REMEMBER_STATE
21919 + pax_exit_kernel_user
21920 + pax_erase_kstack
21921 /*
21922 * sysretq will re-enable interrupts:
21923 */
21924 @@ -709,14 +1154,18 @@ badsys:
21925 * jump back to the normal fast path.
21926 */
21927 auditsys:
21928 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21929 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21930 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21931 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21932 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21933 movq %rax,%rsi /* 2nd arg: syscall number */
21934 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21935 call __audit_syscall_entry
21936 +
21937 + pax_erase_kstack
21938 +
21939 LOAD_ARGS 0 /* reload call-clobbered registers */
21940 + pax_set_fptr_mask
21941 jmp system_call_fastpath
21942
21943 /*
21944 @@ -737,7 +1186,7 @@ sysret_audit:
21945 /* Do syscall tracing */
21946 tracesys:
21947 #ifdef CONFIG_AUDITSYSCALL
21948 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21949 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21950 jz auditsys
21951 #endif
21952 SAVE_REST
21953 @@ -745,12 +1194,16 @@ tracesys:
21954 FIXUP_TOP_OF_STACK %rdi
21955 movq %rsp,%rdi
21956 call syscall_trace_enter
21957 +
21958 + pax_erase_kstack
21959 +
21960 /*
21961 * Reload arg registers from stack in case ptrace changed them.
21962 * We don't reload %rax because syscall_trace_enter() returned
21963 * the value it wants us to use in the table lookup.
21964 */
21965 LOAD_ARGS ARGOFFSET, 1
21966 + pax_set_fptr_mask
21967 RESTORE_REST
21968 #if __SYSCALL_MASK == ~0
21969 cmpq $__NR_syscall_max,%rax
21970 @@ -759,7 +1212,7 @@ tracesys:
21971 cmpl $__NR_syscall_max,%eax
21972 #endif
21973 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21974 - movq %r10,%rcx /* fixup for C */
21975 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21976 call *sys_call_table(,%rax,8)
21977 movq %rax,RAX-ARGOFFSET(%rsp)
21978 /* Use IRET because user could have changed frame */
21979 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21980 andl %edi,%edx
21981 jnz int_careful
21982 andl $~TS_COMPAT,TI_status(%rcx)
21983 - jmp retint_swapgs
21984 + pax_exit_kernel_user
21985 + pax_erase_kstack
21986 + jmp retint_swapgs_pax
21987
21988 /* Either reschedule or signal or syscall exit tracking needed. */
21989 /* First do a reschedule test. */
21990 @@ -826,7 +1281,7 @@ int_restore_rest:
21991 TRACE_IRQS_OFF
21992 jmp int_with_check
21993 CFI_ENDPROC
21994 -END(system_call)
21995 +ENDPROC(system_call)
21996
21997 .macro FORK_LIKE func
21998 ENTRY(stub_\func)
21999 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22000 DEFAULT_FRAME 0 8 /* offset 8: return address */
22001 call sys_\func
22002 RESTORE_TOP_OF_STACK %r11, 8
22003 + pax_force_retaddr
22004 ret $REST_SKIP /* pop extended registers */
22005 CFI_ENDPROC
22006 -END(stub_\func)
22007 +ENDPROC(stub_\func)
22008 .endm
22009
22010 .macro FIXED_FRAME label,func
22011 @@ -851,9 +1307,10 @@ ENTRY(\label)
22012 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22013 call \func
22014 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22015 + pax_force_retaddr
22016 ret
22017 CFI_ENDPROC
22018 -END(\label)
22019 +ENDPROC(\label)
22020 .endm
22021
22022 FORK_LIKE clone
22023 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22024 movq_cfi_restore R12+8, r12
22025 movq_cfi_restore RBP+8, rbp
22026 movq_cfi_restore RBX+8, rbx
22027 + pax_force_retaddr
22028 ret $REST_SKIP /* pop extended registers */
22029 CFI_ENDPROC
22030 -END(ptregscall_common)
22031 +ENDPROC(ptregscall_common)
22032
22033 ENTRY(stub_execve)
22034 CFI_STARTPROC
22035 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22036 RESTORE_REST
22037 jmp int_ret_from_sys_call
22038 CFI_ENDPROC
22039 -END(stub_execve)
22040 +ENDPROC(stub_execve)
22041
22042 /*
22043 * sigreturn is special because it needs to restore all registers on return.
22044 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22045 RESTORE_REST
22046 jmp int_ret_from_sys_call
22047 CFI_ENDPROC
22048 -END(stub_rt_sigreturn)
22049 +ENDPROC(stub_rt_sigreturn)
22050
22051 #ifdef CONFIG_X86_X32_ABI
22052 ENTRY(stub_x32_rt_sigreturn)
22053 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22054 RESTORE_REST
22055 jmp int_ret_from_sys_call
22056 CFI_ENDPROC
22057 -END(stub_x32_rt_sigreturn)
22058 +ENDPROC(stub_x32_rt_sigreturn)
22059
22060 ENTRY(stub_x32_execve)
22061 CFI_STARTPROC
22062 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22063 RESTORE_REST
22064 jmp int_ret_from_sys_call
22065 CFI_ENDPROC
22066 -END(stub_x32_execve)
22067 +ENDPROC(stub_x32_execve)
22068
22069 #endif
22070
22071 @@ -967,7 +1425,7 @@ vector=vector+1
22072 2: jmp common_interrupt
22073 .endr
22074 CFI_ENDPROC
22075 -END(irq_entries_start)
22076 +ENDPROC(irq_entries_start)
22077
22078 .previous
22079 END(interrupt)
22080 @@ -987,6 +1445,16 @@ END(interrupt)
22081 subq $ORIG_RAX-RBP, %rsp
22082 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22083 SAVE_ARGS_IRQ
22084 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22085 + testb $3, CS(%rdi)
22086 + jnz 1f
22087 + pax_enter_kernel
22088 + jmp 2f
22089 +1: pax_enter_kernel_user
22090 +2:
22091 +#else
22092 + pax_enter_kernel
22093 +#endif
22094 call \func
22095 .endm
22096
22097 @@ -1019,7 +1487,7 @@ ret_from_intr:
22098
22099 exit_intr:
22100 GET_THREAD_INFO(%rcx)
22101 - testl $3,CS-ARGOFFSET(%rsp)
22102 + testb $3,CS-ARGOFFSET(%rsp)
22103 je retint_kernel
22104
22105 /* Interrupt came from user space */
22106 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22107 * The iretq could re-enable interrupts:
22108 */
22109 DISABLE_INTERRUPTS(CLBR_ANY)
22110 + pax_exit_kernel_user
22111 +retint_swapgs_pax:
22112 TRACE_IRQS_IRETQ
22113 SWAPGS
22114 jmp restore_args
22115
22116 retint_restore_args: /* return to kernel space */
22117 DISABLE_INTERRUPTS(CLBR_ANY)
22118 + pax_exit_kernel
22119 + pax_force_retaddr (RIP-ARGOFFSET)
22120 /*
22121 * The iretq could re-enable interrupts:
22122 */
22123 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22124 #endif
22125
22126 CFI_ENDPROC
22127 -END(common_interrupt)
22128 +ENDPROC(common_interrupt)
22129 /*
22130 * End of kprobes section
22131 */
22132 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22133 interrupt \do_sym
22134 jmp ret_from_intr
22135 CFI_ENDPROC
22136 -END(\sym)
22137 +ENDPROC(\sym)
22138 .endm
22139
22140 #ifdef CONFIG_TRACING
22141 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22142 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22143 call error_entry
22144 DEFAULT_FRAME 0
22145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22146 + testb $3, CS(%rsp)
22147 + jnz 1f
22148 + pax_enter_kernel
22149 + jmp 2f
22150 +1: pax_enter_kernel_user
22151 +2:
22152 +#else
22153 + pax_enter_kernel
22154 +#endif
22155 movq %rsp,%rdi /* pt_regs pointer */
22156 xorl %esi,%esi /* no error code */
22157 call \do_sym
22158 jmp error_exit /* %ebx: no swapgs flag */
22159 CFI_ENDPROC
22160 -END(\sym)
22161 +ENDPROC(\sym)
22162 .endm
22163
22164 .macro paranoidzeroentry sym do_sym
22165 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22166 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22167 call save_paranoid
22168 TRACE_IRQS_OFF
22169 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22170 + testb $3, CS(%rsp)
22171 + jnz 1f
22172 + pax_enter_kernel
22173 + jmp 2f
22174 +1: pax_enter_kernel_user
22175 +2:
22176 +#else
22177 + pax_enter_kernel
22178 +#endif
22179 movq %rsp,%rdi /* pt_regs pointer */
22180 xorl %esi,%esi /* no error code */
22181 call \do_sym
22182 jmp paranoid_exit /* %ebx: no swapgs flag */
22183 CFI_ENDPROC
22184 -END(\sym)
22185 +ENDPROC(\sym)
22186 .endm
22187
22188 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22189 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22190 .macro paranoidzeroentry_ist sym do_sym ist
22191 ENTRY(\sym)
22192 INTR_FRAME
22193 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22194 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22195 call save_paranoid
22196 TRACE_IRQS_OFF_DEBUG
22197 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22198 + testb $3, CS(%rsp)
22199 + jnz 1f
22200 + pax_enter_kernel
22201 + jmp 2f
22202 +1: pax_enter_kernel_user
22203 +2:
22204 +#else
22205 + pax_enter_kernel
22206 +#endif
22207 movq %rsp,%rdi /* pt_regs pointer */
22208 xorl %esi,%esi /* no error code */
22209 +#ifdef CONFIG_SMP
22210 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22211 + lea init_tss(%r12), %r12
22212 +#else
22213 + lea init_tss(%rip), %r12
22214 +#endif
22215 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22216 call \do_sym
22217 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22218 jmp paranoid_exit /* %ebx: no swapgs flag */
22219 CFI_ENDPROC
22220 -END(\sym)
22221 +ENDPROC(\sym)
22222 .endm
22223
22224 .macro errorentry sym do_sym
22225 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22226 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22227 call error_entry
22228 DEFAULT_FRAME 0
22229 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22230 + testb $3, CS(%rsp)
22231 + jnz 1f
22232 + pax_enter_kernel
22233 + jmp 2f
22234 +1: pax_enter_kernel_user
22235 +2:
22236 +#else
22237 + pax_enter_kernel
22238 +#endif
22239 movq %rsp,%rdi /* pt_regs pointer */
22240 movq ORIG_RAX(%rsp),%rsi /* get error code */
22241 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22242 call \do_sym
22243 jmp error_exit /* %ebx: no swapgs flag */
22244 CFI_ENDPROC
22245 -END(\sym)
22246 +ENDPROC(\sym)
22247 .endm
22248
22249 /* error code is on the stack already */
22250 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22251 call save_paranoid
22252 DEFAULT_FRAME 0
22253 TRACE_IRQS_OFF
22254 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22255 + testb $3, CS(%rsp)
22256 + jnz 1f
22257 + pax_enter_kernel
22258 + jmp 2f
22259 +1: pax_enter_kernel_user
22260 +2:
22261 +#else
22262 + pax_enter_kernel
22263 +#endif
22264 movq %rsp,%rdi /* pt_regs pointer */
22265 movq ORIG_RAX(%rsp),%rsi /* get error code */
22266 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22267 call \do_sym
22268 jmp paranoid_exit /* %ebx: no swapgs flag */
22269 CFI_ENDPROC
22270 -END(\sym)
22271 +ENDPROC(\sym)
22272 .endm
22273
22274 zeroentry divide_error do_divide_error
22275 @@ -1342,9 +1870,10 @@ gs_change:
22276 2: mfence /* workaround */
22277 SWAPGS
22278 popfq_cfi
22279 + pax_force_retaddr
22280 ret
22281 CFI_ENDPROC
22282 -END(native_load_gs_index)
22283 +ENDPROC(native_load_gs_index)
22284
22285 _ASM_EXTABLE(gs_change,bad_gs)
22286 .section .fixup,"ax"
22287 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22288 CFI_DEF_CFA_REGISTER rsp
22289 CFI_ADJUST_CFA_OFFSET -8
22290 decl PER_CPU_VAR(irq_count)
22291 + pax_force_retaddr
22292 ret
22293 CFI_ENDPROC
22294 -END(call_softirq)
22295 +ENDPROC(call_softirq)
22296
22297 #ifdef CONFIG_XEN
22298 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22299 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22300 decl PER_CPU_VAR(irq_count)
22301 jmp error_exit
22302 CFI_ENDPROC
22303 -END(xen_do_hypervisor_callback)
22304 +ENDPROC(xen_do_hypervisor_callback)
22305
22306 /*
22307 * Hypervisor uses this for application faults while it executes.
22308 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22309 SAVE_ALL
22310 jmp error_exit
22311 CFI_ENDPROC
22312 -END(xen_failsafe_callback)
22313 +ENDPROC(xen_failsafe_callback)
22314
22315 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22316 xen_hvm_callback_vector xen_evtchn_do_upcall
22317 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22318 DEFAULT_FRAME
22319 DISABLE_INTERRUPTS(CLBR_NONE)
22320 TRACE_IRQS_OFF_DEBUG
22321 - testl %ebx,%ebx /* swapgs needed? */
22322 + testl $1,%ebx /* swapgs needed? */
22323 jnz paranoid_restore
22324 - testl $3,CS(%rsp)
22325 + testb $3,CS(%rsp)
22326 jnz paranoid_userspace
22327 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22328 + pax_exit_kernel
22329 + TRACE_IRQS_IRETQ 0
22330 + SWAPGS_UNSAFE_STACK
22331 + RESTORE_ALL 8
22332 + pax_force_retaddr_bts
22333 + jmp irq_return
22334 +#endif
22335 paranoid_swapgs:
22336 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22337 + pax_exit_kernel_user
22338 +#else
22339 + pax_exit_kernel
22340 +#endif
22341 TRACE_IRQS_IRETQ 0
22342 SWAPGS_UNSAFE_STACK
22343 RESTORE_ALL 8
22344 jmp irq_return
22345 paranoid_restore:
22346 + pax_exit_kernel
22347 TRACE_IRQS_IRETQ_DEBUG 0
22348 RESTORE_ALL 8
22349 + pax_force_retaddr_bts
22350 jmp irq_return
22351 paranoid_userspace:
22352 GET_THREAD_INFO(%rcx)
22353 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22354 TRACE_IRQS_OFF
22355 jmp paranoid_userspace
22356 CFI_ENDPROC
22357 -END(paranoid_exit)
22358 +ENDPROC(paranoid_exit)
22359
22360 /*
22361 * Exception entry point. This expects an error code/orig_rax on the stack.
22362 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22363 movq_cfi r14, R14+8
22364 movq_cfi r15, R15+8
22365 xorl %ebx,%ebx
22366 - testl $3,CS+8(%rsp)
22367 + testb $3,CS+8(%rsp)
22368 je error_kernelspace
22369 error_swapgs:
22370 SWAPGS
22371 error_sti:
22372 TRACE_IRQS_OFF
22373 + pax_force_retaddr_bts
22374 ret
22375
22376 /*
22377 @@ -1622,7 +2168,7 @@ bstep_iret:
22378 movq %rcx,RIP+8(%rsp)
22379 jmp error_swapgs
22380 CFI_ENDPROC
22381 -END(error_entry)
22382 +ENDPROC(error_entry)
22383
22384
22385 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22386 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22387 DISABLE_INTERRUPTS(CLBR_NONE)
22388 TRACE_IRQS_OFF
22389 GET_THREAD_INFO(%rcx)
22390 - testl %eax,%eax
22391 + testl $1,%eax
22392 jne retint_kernel
22393 LOCKDEP_SYS_EXIT_IRQ
22394 movl TI_flags(%rcx),%edx
22395 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22396 jnz retint_careful
22397 jmp retint_swapgs
22398 CFI_ENDPROC
22399 -END(error_exit)
22400 +ENDPROC(error_exit)
22401
22402 /*
22403 * Test if a given stack is an NMI stack or not.
22404 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22405 * If %cs was not the kernel segment, then the NMI triggered in user
22406 * space, which means it is definitely not nested.
22407 */
22408 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22409 + je 1f
22410 cmpl $__KERNEL_CS, 16(%rsp)
22411 jne first_nmi
22412 -
22413 +1:
22414 /*
22415 * Check the special variable on the stack to see if NMIs are
22416 * executing.
22417 @@ -1736,8 +2284,7 @@ nested_nmi:
22418
22419 1:
22420 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22421 - leaq -1*8(%rsp), %rdx
22422 - movq %rdx, %rsp
22423 + subq $8, %rsp
22424 CFI_ADJUST_CFA_OFFSET 1*8
22425 leaq -10*8(%rsp), %rdx
22426 pushq_cfi $__KERNEL_DS
22427 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22428 CFI_RESTORE rdx
22429
22430 /* No need to check faults here */
22431 +# pax_force_retaddr_bts
22432 INTERRUPT_RETURN
22433
22434 CFI_RESTORE_STATE
22435 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22436 */
22437 movq %cr2, %r12
22438
22439 + pax_enter_kernel_nmi
22440 +
22441 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22442 movq %rsp,%rdi
22443 movq $-1,%rsi
22444 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22445 movq %r12, %cr2
22446 1:
22447
22448 - testl %ebx,%ebx /* swapgs needed? */
22449 + testl $1,%ebx /* swapgs needed? */
22450 jnz nmi_restore
22451 nmi_swapgs:
22452 SWAPGS_UNSAFE_STACK
22453 nmi_restore:
22454 + pax_exit_kernel_nmi
22455 /* Pop the extra iret frame at once */
22456 RESTORE_ALL 6*8
22457 + testb $3, 8(%rsp)
22458 + jnz 1f
22459 + pax_force_retaddr_bts
22460 +1:
22461
22462 /* Clear the NMI executing stack variable */
22463 movq $0, 5*8(%rsp)
22464 jmp irq_return
22465 CFI_ENDPROC
22466 -END(nmi)
22467 +ENDPROC(nmi)
22468
22469 ENTRY(ignore_sysret)
22470 CFI_STARTPROC
22471 mov $-ENOSYS,%eax
22472 sysret
22473 CFI_ENDPROC
22474 -END(ignore_sysret)
22475 +ENDPROC(ignore_sysret)
22476
22477 /*
22478 * End of kprobes section
22479 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22480 index 42a392a..fbbd930 100644
22481 --- a/arch/x86/kernel/ftrace.c
22482 +++ b/arch/x86/kernel/ftrace.c
22483 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22484 {
22485 unsigned char replaced[MCOUNT_INSN_SIZE];
22486
22487 + ip = ktla_ktva(ip);
22488 +
22489 /*
22490 * Note: Due to modules and __init, code can
22491 * disappear and change, we need to protect against faulting
22492 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22493 unsigned char old[MCOUNT_INSN_SIZE], *new;
22494 int ret;
22495
22496 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22497 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22498 new = ftrace_call_replace(ip, (unsigned long)func);
22499
22500 /* See comment above by declaration of modifying_ftrace_code */
22501 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22502 /* Also update the regs callback function */
22503 if (!ret) {
22504 ip = (unsigned long)(&ftrace_regs_call);
22505 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22506 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22507 new = ftrace_call_replace(ip, (unsigned long)func);
22508 ret = ftrace_modify_code(ip, old, new);
22509 }
22510 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22511 * kernel identity mapping to modify code.
22512 */
22513 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22514 - ip = (unsigned long)__va(__pa_symbol(ip));
22515 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22516
22517 return probe_kernel_write((void *)ip, val, size);
22518 }
22519 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22520 unsigned char replaced[MCOUNT_INSN_SIZE];
22521 unsigned char brk = BREAKPOINT_INSTRUCTION;
22522
22523 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22524 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22525 return -EFAULT;
22526
22527 /* Make sure it is what we expect it to be */
22528 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22529 return ret;
22530
22531 fail_update:
22532 - probe_kernel_write((void *)ip, &old_code[0], 1);
22533 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22534 goto out;
22535 }
22536
22537 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22538 {
22539 unsigned char code[MCOUNT_INSN_SIZE];
22540
22541 + ip = ktla_ktva(ip);
22542 +
22543 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22544 return -EFAULT;
22545
22546 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22547 index 55b6761..a6456fc 100644
22548 --- a/arch/x86/kernel/head64.c
22549 +++ b/arch/x86/kernel/head64.c
22550 @@ -67,12 +67,12 @@ again:
22551 pgd = *pgd_p;
22552
22553 /*
22554 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22555 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22556 + * The use of __early_va rather than __va here is critical:
22557 + * __va would point us back into the dynamic
22558 * range and we might end up looping forever...
22559 */
22560 if (pgd)
22561 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22562 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22563 else {
22564 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22565 reset_early_page_tables();
22566 @@ -82,13 +82,13 @@ again:
22567 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22568 for (i = 0; i < PTRS_PER_PUD; i++)
22569 pud_p[i] = 0;
22570 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22571 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22572 }
22573 pud_p += pud_index(address);
22574 pud = *pud_p;
22575
22576 if (pud)
22577 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22578 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22579 else {
22580 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22581 reset_early_page_tables();
22582 @@ -98,7 +98,7 @@ again:
22583 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22584 for (i = 0; i < PTRS_PER_PMD; i++)
22585 pmd_p[i] = 0;
22586 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22587 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22588 }
22589 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22590 pmd_p[pmd_index(address)] = pmd;
22591 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22592 if (console_loglevel == 10)
22593 early_printk("Kernel alive\n");
22594
22595 - clear_page(init_level4_pgt);
22596 /* set init_level4_pgt kernel high mapping*/
22597 init_level4_pgt[511] = early_level4_pgt[511];
22598
22599 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22600 index 5dd87a8..d68b3f4 100644
22601 --- a/arch/x86/kernel/head_32.S
22602 +++ b/arch/x86/kernel/head_32.S
22603 @@ -26,6 +26,12 @@
22604 /* Physical address */
22605 #define pa(X) ((X) - __PAGE_OFFSET)
22606
22607 +#ifdef CONFIG_PAX_KERNEXEC
22608 +#define ta(X) (X)
22609 +#else
22610 +#define ta(X) ((X) - __PAGE_OFFSET)
22611 +#endif
22612 +
22613 /*
22614 * References to members of the new_cpu_data structure.
22615 */
22616 @@ -55,11 +61,7 @@
22617 * and small than max_low_pfn, otherwise will waste some page table entries
22618 */
22619
22620 -#if PTRS_PER_PMD > 1
22621 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22622 -#else
22623 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22624 -#endif
22625 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22626
22627 /* Number of possible pages in the lowmem region */
22628 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22629 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22630 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22631
22632 /*
22633 + * Real beginning of normal "text" segment
22634 + */
22635 +ENTRY(stext)
22636 +ENTRY(_stext)
22637 +
22638 +/*
22639 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22640 * %esi points to the real-mode code as a 32-bit pointer.
22641 * CS and DS must be 4 GB flat segments, but we don't depend on
22642 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22643 * can.
22644 */
22645 __HEAD
22646 +
22647 +#ifdef CONFIG_PAX_KERNEXEC
22648 + jmp startup_32
22649 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22650 +.fill PAGE_SIZE-5,1,0xcc
22651 +#endif
22652 +
22653 ENTRY(startup_32)
22654 movl pa(stack_start),%ecx
22655
22656 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22657 2:
22658 leal -__PAGE_OFFSET(%ecx),%esp
22659
22660 +#ifdef CONFIG_SMP
22661 + movl $pa(cpu_gdt_table),%edi
22662 + movl $__per_cpu_load,%eax
22663 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22664 + rorl $16,%eax
22665 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22666 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22667 + movl $__per_cpu_end - 1,%eax
22668 + subl $__per_cpu_start,%eax
22669 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22670 +#endif
22671 +
22672 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22673 + movl $NR_CPUS,%ecx
22674 + movl $pa(cpu_gdt_table),%edi
22675 +1:
22676 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22677 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22678 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22679 + addl $PAGE_SIZE_asm,%edi
22680 + loop 1b
22681 +#endif
22682 +
22683 +#ifdef CONFIG_PAX_KERNEXEC
22684 + movl $pa(boot_gdt),%edi
22685 + movl $__LOAD_PHYSICAL_ADDR,%eax
22686 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22687 + rorl $16,%eax
22688 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22689 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22690 + rorl $16,%eax
22691 +
22692 + ljmp $(__BOOT_CS),$1f
22693 +1:
22694 +
22695 + movl $NR_CPUS,%ecx
22696 + movl $pa(cpu_gdt_table),%edi
22697 + addl $__PAGE_OFFSET,%eax
22698 +1:
22699 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22700 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22701 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22702 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22703 + rorl $16,%eax
22704 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22705 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22706 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22707 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22708 + rorl $16,%eax
22709 + addl $PAGE_SIZE_asm,%edi
22710 + loop 1b
22711 +#endif
22712 +
22713 /*
22714 * Clear BSS first so that there are no surprises...
22715 */
22716 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22717 movl %eax, pa(max_pfn_mapped)
22718
22719 /* Do early initialization of the fixmap area */
22720 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22721 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22722 +#ifdef CONFIG_COMPAT_VDSO
22723 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22724 +#else
22725 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22726 +#endif
22727 #else /* Not PAE */
22728
22729 page_pde_offset = (__PAGE_OFFSET >> 20);
22730 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22731 movl %eax, pa(max_pfn_mapped)
22732
22733 /* Do early initialization of the fixmap area */
22734 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22735 - movl %eax,pa(initial_page_table+0xffc)
22736 +#ifdef CONFIG_COMPAT_VDSO
22737 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22738 +#else
22739 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22740 +#endif
22741 #endif
22742
22743 #ifdef CONFIG_PARAVIRT
22744 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22745 cmpl $num_subarch_entries, %eax
22746 jae bad_subarch
22747
22748 - movl pa(subarch_entries)(,%eax,4), %eax
22749 - subl $__PAGE_OFFSET, %eax
22750 - jmp *%eax
22751 + jmp *pa(subarch_entries)(,%eax,4)
22752
22753 bad_subarch:
22754 WEAK(lguest_entry)
22755 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22756 __INITDATA
22757
22758 subarch_entries:
22759 - .long default_entry /* normal x86/PC */
22760 - .long lguest_entry /* lguest hypervisor */
22761 - .long xen_entry /* Xen hypervisor */
22762 - .long default_entry /* Moorestown MID */
22763 + .long ta(default_entry) /* normal x86/PC */
22764 + .long ta(lguest_entry) /* lguest hypervisor */
22765 + .long ta(xen_entry) /* Xen hypervisor */
22766 + .long ta(default_entry) /* Moorestown MID */
22767 num_subarch_entries = (. - subarch_entries) / 4
22768 .previous
22769 #else
22770 @@ -354,6 +426,7 @@ default_entry:
22771 movl pa(mmu_cr4_features),%eax
22772 movl %eax,%cr4
22773
22774 +#ifdef CONFIG_X86_PAE
22775 testb $X86_CR4_PAE, %al # check if PAE is enabled
22776 jz enable_paging
22777
22778 @@ -382,6 +455,9 @@ default_entry:
22779 /* Make changes effective */
22780 wrmsr
22781
22782 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22783 +#endif
22784 +
22785 enable_paging:
22786
22787 /*
22788 @@ -449,14 +525,20 @@ is486:
22789 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22790 movl %eax,%ss # after changing gdt.
22791
22792 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22793 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22794 movl %eax,%ds
22795 movl %eax,%es
22796
22797 movl $(__KERNEL_PERCPU), %eax
22798 movl %eax,%fs # set this cpu's percpu
22799
22800 +#ifdef CONFIG_CC_STACKPROTECTOR
22801 movl $(__KERNEL_STACK_CANARY),%eax
22802 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22803 + movl $(__USER_DS),%eax
22804 +#else
22805 + xorl %eax,%eax
22806 +#endif
22807 movl %eax,%gs
22808
22809 xorl %eax,%eax # Clear LDT
22810 @@ -512,8 +594,11 @@ setup_once:
22811 * relocation. Manually set base address in stack canary
22812 * segment descriptor.
22813 */
22814 - movl $gdt_page,%eax
22815 + movl $cpu_gdt_table,%eax
22816 movl $stack_canary,%ecx
22817 +#ifdef CONFIG_SMP
22818 + addl $__per_cpu_load,%ecx
22819 +#endif
22820 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22821 shrl $16, %ecx
22822 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22823 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22824 /* This is global to keep gas from relaxing the jumps */
22825 ENTRY(early_idt_handler)
22826 cld
22827 - cmpl $2,%ss:early_recursion_flag
22828 + cmpl $1,%ss:early_recursion_flag
22829 je hlt_loop
22830 incl %ss:early_recursion_flag
22831
22832 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22833 pushl (20+6*4)(%esp) /* trapno */
22834 pushl $fault_msg
22835 call printk
22836 -#endif
22837 call dump_stack
22838 +#endif
22839 hlt_loop:
22840 hlt
22841 jmp hlt_loop
22842 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22843 /* This is the default interrupt "handler" :-) */
22844 ALIGN
22845 ignore_int:
22846 - cld
22847 #ifdef CONFIG_PRINTK
22848 + cmpl $2,%ss:early_recursion_flag
22849 + je hlt_loop
22850 + incl %ss:early_recursion_flag
22851 + cld
22852 pushl %eax
22853 pushl %ecx
22854 pushl %edx
22855 @@ -612,9 +700,6 @@ ignore_int:
22856 movl $(__KERNEL_DS),%eax
22857 movl %eax,%ds
22858 movl %eax,%es
22859 - cmpl $2,early_recursion_flag
22860 - je hlt_loop
22861 - incl early_recursion_flag
22862 pushl 16(%esp)
22863 pushl 24(%esp)
22864 pushl 32(%esp)
22865 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22866 /*
22867 * BSS section
22868 */
22869 -__PAGE_ALIGNED_BSS
22870 - .align PAGE_SIZE
22871 #ifdef CONFIG_X86_PAE
22872 +.section .initial_pg_pmd,"a",@progbits
22873 initial_pg_pmd:
22874 .fill 1024*KPMDS,4,0
22875 #else
22876 +.section .initial_page_table,"a",@progbits
22877 ENTRY(initial_page_table)
22878 .fill 1024,4,0
22879 #endif
22880 +.section .initial_pg_fixmap,"a",@progbits
22881 initial_pg_fixmap:
22882 .fill 1024,4,0
22883 +.section .empty_zero_page,"a",@progbits
22884 ENTRY(empty_zero_page)
22885 .fill 4096,1,0
22886 +.section .swapper_pg_dir,"a",@progbits
22887 ENTRY(swapper_pg_dir)
22888 +#ifdef CONFIG_X86_PAE
22889 + .fill 4,8,0
22890 +#else
22891 .fill 1024,4,0
22892 +#endif
22893
22894 /*
22895 * This starts the data section.
22896 */
22897 #ifdef CONFIG_X86_PAE
22898 -__PAGE_ALIGNED_DATA
22899 - /* Page-aligned for the benefit of paravirt? */
22900 - .align PAGE_SIZE
22901 +.section .initial_page_table,"a",@progbits
22902 ENTRY(initial_page_table)
22903 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22904 # if KPMDS == 3
22905 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22906 # error "Kernel PMDs should be 1, 2 or 3"
22907 # endif
22908 .align PAGE_SIZE /* needs to be page-sized too */
22909 +
22910 +#ifdef CONFIG_PAX_PER_CPU_PGD
22911 +ENTRY(cpu_pgd)
22912 + .rept 2*NR_CPUS
22913 + .fill 4,8,0
22914 + .endr
22915 +#endif
22916 +
22917 #endif
22918
22919 .data
22920 .balign 4
22921 ENTRY(stack_start)
22922 - .long init_thread_union+THREAD_SIZE
22923 + .long init_thread_union+THREAD_SIZE-8
22924
22925 __INITRODATA
22926 int_msg:
22927 @@ -722,7 +820,7 @@ fault_msg:
22928 * segment size, and 32-bit linear address value:
22929 */
22930
22931 - .data
22932 +.section .rodata,"a",@progbits
22933 .globl boot_gdt_descr
22934 .globl idt_descr
22935
22936 @@ -731,7 +829,7 @@ fault_msg:
22937 .word 0 # 32 bit align gdt_desc.address
22938 boot_gdt_descr:
22939 .word __BOOT_DS+7
22940 - .long boot_gdt - __PAGE_OFFSET
22941 + .long pa(boot_gdt)
22942
22943 .word 0 # 32-bit align idt_desc.address
22944 idt_descr:
22945 @@ -742,7 +840,7 @@ idt_descr:
22946 .word 0 # 32 bit align gdt_desc.address
22947 ENTRY(early_gdt_descr)
22948 .word GDT_ENTRIES*8-1
22949 - .long gdt_page /* Overwritten for secondary CPUs */
22950 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22951
22952 /*
22953 * The boot_gdt must mirror the equivalent in setup.S and is
22954 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22955 .align L1_CACHE_BYTES
22956 ENTRY(boot_gdt)
22957 .fill GDT_ENTRY_BOOT_CS,8,0
22958 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22959 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22960 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22961 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22962 +
22963 + .align PAGE_SIZE_asm
22964 +ENTRY(cpu_gdt_table)
22965 + .rept NR_CPUS
22966 + .quad 0x0000000000000000 /* NULL descriptor */
22967 + .quad 0x0000000000000000 /* 0x0b reserved */
22968 + .quad 0x0000000000000000 /* 0x13 reserved */
22969 + .quad 0x0000000000000000 /* 0x1b reserved */
22970 +
22971 +#ifdef CONFIG_PAX_KERNEXEC
22972 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22973 +#else
22974 + .quad 0x0000000000000000 /* 0x20 unused */
22975 +#endif
22976 +
22977 + .quad 0x0000000000000000 /* 0x28 unused */
22978 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22979 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22980 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22981 + .quad 0x0000000000000000 /* 0x4b reserved */
22982 + .quad 0x0000000000000000 /* 0x53 reserved */
22983 + .quad 0x0000000000000000 /* 0x5b reserved */
22984 +
22985 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22986 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22987 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22988 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22989 +
22990 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22991 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22992 +
22993 + /*
22994 + * Segments used for calling PnP BIOS have byte granularity.
22995 + * The code segments and data segments have fixed 64k limits,
22996 + * the transfer segment sizes are set at run time.
22997 + */
22998 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
22999 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23000 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23001 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23002 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23003 +
23004 + /*
23005 + * The APM segments have byte granularity and their bases
23006 + * are set at run time. All have 64k limits.
23007 + */
23008 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23009 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23010 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23011 +
23012 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23013 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23014 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23015 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23016 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23017 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23018 +
23019 + /* Be sure this is zeroed to avoid false validations in Xen */
23020 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23021 + .endr
23022 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23023 index e1aabdb..73dcad8 100644
23024 --- a/arch/x86/kernel/head_64.S
23025 +++ b/arch/x86/kernel/head_64.S
23026 @@ -20,6 +20,8 @@
23027 #include <asm/processor-flags.h>
23028 #include <asm/percpu.h>
23029 #include <asm/nops.h>
23030 +#include <asm/cpufeature.h>
23031 +#include <asm/alternative-asm.h>
23032
23033 #ifdef CONFIG_PARAVIRT
23034 #include <asm/asm-offsets.h>
23035 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23036 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23037 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23038 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23039 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23040 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23041 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23042 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23043 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23044 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23045
23046 .text
23047 __HEAD
23048 @@ -89,11 +97,23 @@ startup_64:
23049 * Fixup the physical addresses in the page table
23050 */
23051 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23052 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23053 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23054 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23055 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23056 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23057
23058 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23059 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23060 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23061 +#ifndef CONFIG_XEN
23062 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23063 +#endif
23064
23065 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23066 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23067 +
23068 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23069 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23070 +
23071 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23072
23073 /*
23074 * Set up the identity mapping for the switchover. These
23075 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23076 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23077 1:
23078
23079 - /* Enable PAE mode and PGE */
23080 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23081 + /* Enable PAE mode and PSE/PGE */
23082 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23083 movq %rcx, %cr4
23084
23085 /* Setup early boot stage 4 level pagetables. */
23086 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23087 movl $MSR_EFER, %ecx
23088 rdmsr
23089 btsl $_EFER_SCE, %eax /* Enable System Call */
23090 - btl $20,%edi /* No Execute supported? */
23091 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23092 jnc 1f
23093 btsl $_EFER_NX, %eax
23094 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23095 + leaq init_level4_pgt(%rip), %rdi
23096 +#ifndef CONFIG_EFI
23097 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23098 +#endif
23099 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23100 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23101 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23102 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23103 1: wrmsr /* Make changes effective */
23104
23105 /* Setup cr0 */
23106 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23107 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23108 * address given in m16:64.
23109 */
23110 + pax_set_fptr_mask
23111 movq initial_code(%rip),%rax
23112 pushq $0 # fake return address to stop unwinder
23113 pushq $__KERNEL_CS # set correct cs
23114 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23115 call dump_stack
23116 #ifdef CONFIG_KALLSYMS
23117 leaq early_idt_ripmsg(%rip),%rdi
23118 - movq 40(%rsp),%rsi # %rip again
23119 + movq 88(%rsp),%rsi # %rip again
23120 call __print_symbol
23121 #endif
23122 #endif /* EARLY_PRINTK */
23123 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23124 early_recursion_flag:
23125 .long 0
23126
23127 + .section .rodata,"a",@progbits
23128 #ifdef CONFIG_EARLY_PRINTK
23129 early_idt_msg:
23130 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23131 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23132 NEXT_PAGE(early_dynamic_pgts)
23133 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23134
23135 - .data
23136 + .section .rodata,"a",@progbits
23137
23138 -#ifndef CONFIG_XEN
23139 NEXT_PAGE(init_level4_pgt)
23140 - .fill 512,8,0
23141 -#else
23142 -NEXT_PAGE(init_level4_pgt)
23143 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23144 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23145 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23146 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23147 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23148 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23149 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23150 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23151 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23152 .org init_level4_pgt + L4_START_KERNEL*8, 0
23153 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23154 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23155
23156 +#ifdef CONFIG_PAX_PER_CPU_PGD
23157 +NEXT_PAGE(cpu_pgd)
23158 + .rept 2*NR_CPUS
23159 + .fill 512,8,0
23160 + .endr
23161 +#endif
23162 +
23163 NEXT_PAGE(level3_ident_pgt)
23164 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 +#ifdef CONFIG_XEN
23166 .fill 511, 8, 0
23167 +#else
23168 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23169 + .fill 510,8,0
23170 +#endif
23171 +
23172 +NEXT_PAGE(level3_vmalloc_start_pgt)
23173 + .fill 512,8,0
23174 +
23175 +NEXT_PAGE(level3_vmalloc_end_pgt)
23176 + .fill 512,8,0
23177 +
23178 +NEXT_PAGE(level3_vmemmap_pgt)
23179 + .fill L3_VMEMMAP_START,8,0
23180 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23181 +
23182 NEXT_PAGE(level2_ident_pgt)
23183 - /* Since I easily can, map the first 1G.
23184 + /* Since I easily can, map the first 2G.
23185 * Don't set NX because code runs from these pages.
23186 */
23187 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23188 -#endif
23189 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23190
23191 NEXT_PAGE(level3_kernel_pgt)
23192 .fill L3_START_KERNEL,8,0
23193 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23194 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23195 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23196
23197 +NEXT_PAGE(level2_vmemmap_pgt)
23198 + .fill 512,8,0
23199 +
23200 NEXT_PAGE(level2_kernel_pgt)
23201 /*
23202 * 512 MB kernel mapping. We spend a full page on this pagetable
23203 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23204 KERNEL_IMAGE_SIZE/PMD_SIZE)
23205
23206 NEXT_PAGE(level2_fixmap_pgt)
23207 - .fill 506,8,0
23208 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23209 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23210 - .fill 5,8,0
23211 + .fill 507,8,0
23212 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23213 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23214 + .fill 4,8,0
23215
23216 -NEXT_PAGE(level1_fixmap_pgt)
23217 +NEXT_PAGE(level1_vsyscall_pgt)
23218 .fill 512,8,0
23219
23220 #undef PMDS
23221
23222 - .data
23223 + .align PAGE_SIZE
23224 +ENTRY(cpu_gdt_table)
23225 + .rept NR_CPUS
23226 + .quad 0x0000000000000000 /* NULL descriptor */
23227 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23228 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23229 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23230 + .quad 0x00cffb000000ffff /* __USER32_CS */
23231 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23232 + .quad 0x00affb000000ffff /* __USER_CS */
23233 +
23234 +#ifdef CONFIG_PAX_KERNEXEC
23235 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23236 +#else
23237 + .quad 0x0 /* unused */
23238 +#endif
23239 +
23240 + .quad 0,0 /* TSS */
23241 + .quad 0,0 /* LDT */
23242 + .quad 0,0,0 /* three TLS descriptors */
23243 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23244 + /* asm/segment.h:GDT_ENTRIES must match this */
23245 +
23246 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23247 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23248 +#else
23249 + .quad 0x0 /* unused */
23250 +#endif
23251 +
23252 + /* zero the remaining page */
23253 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23254 + .endr
23255 +
23256 .align 16
23257 .globl early_gdt_descr
23258 early_gdt_descr:
23259 .word GDT_ENTRIES*8-1
23260 early_gdt_descr_base:
23261 - .quad INIT_PER_CPU_VAR(gdt_page)
23262 + .quad cpu_gdt_table
23263
23264 ENTRY(phys_base)
23265 /* This must match the first entry in level2_kernel_pgt */
23266 .quad 0x0000000000000000
23267
23268 #include "../../x86/xen/xen-head.S"
23269 -
23270 - __PAGE_ALIGNED_BSS
23271 +
23272 + .section .rodata,"a",@progbits
23273 NEXT_PAGE(empty_zero_page)
23274 .skip PAGE_SIZE
23275 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23276 index 0fa6912..b37438b 100644
23277 --- a/arch/x86/kernel/i386_ksyms_32.c
23278 +++ b/arch/x86/kernel/i386_ksyms_32.c
23279 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23280 EXPORT_SYMBOL(cmpxchg8b_emu);
23281 #endif
23282
23283 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23284 +
23285 /* Networking helper routines. */
23286 EXPORT_SYMBOL(csum_partial_copy_generic);
23287 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23288 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23289
23290 EXPORT_SYMBOL(__get_user_1);
23291 EXPORT_SYMBOL(__get_user_2);
23292 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23293
23294 EXPORT_SYMBOL(csum_partial);
23295 EXPORT_SYMBOL(empty_zero_page);
23296 +
23297 +#ifdef CONFIG_PAX_KERNEXEC
23298 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23299 +#endif
23300 +
23301 +#ifdef CONFIG_PAX_PER_CPU_PGD
23302 +EXPORT_SYMBOL(cpu_pgd);
23303 +#endif
23304 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23305 index 5d576ab..1403a03 100644
23306 --- a/arch/x86/kernel/i387.c
23307 +++ b/arch/x86/kernel/i387.c
23308 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23309 static inline bool interrupted_user_mode(void)
23310 {
23311 struct pt_regs *regs = get_irq_regs();
23312 - return regs && user_mode_vm(regs);
23313 + return regs && user_mode(regs);
23314 }
23315
23316 /*
23317 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23318 index 9a5c460..84868423 100644
23319 --- a/arch/x86/kernel/i8259.c
23320 +++ b/arch/x86/kernel/i8259.c
23321 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23322 static void make_8259A_irq(unsigned int irq)
23323 {
23324 disable_irq_nosync(irq);
23325 - io_apic_irqs &= ~(1<<irq);
23326 + io_apic_irqs &= ~(1UL<<irq);
23327 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23328 i8259A_chip.name);
23329 enable_irq(irq);
23330 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23331 "spurious 8259A interrupt: IRQ%d.\n", irq);
23332 spurious_irq_mask |= irqmask;
23333 }
23334 - atomic_inc(&irq_err_count);
23335 + atomic_inc_unchecked(&irq_err_count);
23336 /*
23337 * Theoretically we do not have to handle this IRQ,
23338 * but in Linux this does not cause problems and is
23339 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23340 /* (slave's support for AEOI in flat mode is to be investigated) */
23341 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23342
23343 + pax_open_kernel();
23344 if (auto_eoi)
23345 /*
23346 * In AEOI mode we just have to mask the interrupt
23347 * when acking.
23348 */
23349 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23350 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23351 else
23352 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23353 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23354 + pax_close_kernel();
23355
23356 udelay(100); /* wait for 8259A to initialize */
23357
23358 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23359 index a979b5b..1d6db75 100644
23360 --- a/arch/x86/kernel/io_delay.c
23361 +++ b/arch/x86/kernel/io_delay.c
23362 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23363 * Quirk table for systems that misbehave (lock up, etc.) if port
23364 * 0x80 is used:
23365 */
23366 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23367 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23368 {
23369 .callback = dmi_io_delay_0xed_port,
23370 .ident = "Compaq Presario V6000",
23371 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23372 index 4ddaf66..6292f4e 100644
23373 --- a/arch/x86/kernel/ioport.c
23374 +++ b/arch/x86/kernel/ioport.c
23375 @@ -6,6 +6,7 @@
23376 #include <linux/sched.h>
23377 #include <linux/kernel.h>
23378 #include <linux/capability.h>
23379 +#include <linux/security.h>
23380 #include <linux/errno.h>
23381 #include <linux/types.h>
23382 #include <linux/ioport.h>
23383 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23384
23385 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23386 return -EINVAL;
23387 +#ifdef CONFIG_GRKERNSEC_IO
23388 + if (turn_on && grsec_disable_privio) {
23389 + gr_handle_ioperm();
23390 + return -EPERM;
23391 + }
23392 +#endif
23393 if (turn_on && !capable(CAP_SYS_RAWIO))
23394 return -EPERM;
23395
23396 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23397 * because the ->io_bitmap_max value must match the bitmap
23398 * contents:
23399 */
23400 - tss = &per_cpu(init_tss, get_cpu());
23401 + tss = init_tss + get_cpu();
23402
23403 if (turn_on)
23404 bitmap_clear(t->io_bitmap_ptr, from, num);
23405 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23406 return -EINVAL;
23407 /* Trying to gain more privileges? */
23408 if (level > old) {
23409 +#ifdef CONFIG_GRKERNSEC_IO
23410 + if (grsec_disable_privio) {
23411 + gr_handle_iopl();
23412 + return -EPERM;
23413 + }
23414 +#endif
23415 if (!capable(CAP_SYS_RAWIO))
23416 return -EPERM;
23417 }
23418 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23419 index 3a8185c..3c042ee 100644
23420 --- a/arch/x86/kernel/irq.c
23421 +++ b/arch/x86/kernel/irq.c
23422 @@ -21,7 +21,7 @@
23423 #define CREATE_TRACE_POINTS
23424 #include <asm/trace/irq_vectors.h>
23425
23426 -atomic_t irq_err_count;
23427 +atomic_unchecked_t irq_err_count;
23428
23429 /* Function pointer for generic interrupt vector handling */
23430 void (*x86_platform_ipi_callback)(void) = NULL;
23431 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23432 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23433 seq_printf(p, " Machine check polls\n");
23434 #endif
23435 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23436 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23437 #if defined(CONFIG_X86_IO_APIC)
23438 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23439 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23440 #endif
23441 return 0;
23442 }
23443 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23444
23445 u64 arch_irq_stat(void)
23446 {
23447 - u64 sum = atomic_read(&irq_err_count);
23448 + u64 sum = atomic_read_unchecked(&irq_err_count);
23449 return sum;
23450 }
23451
23452 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23453 index 4186755..784efa0 100644
23454 --- a/arch/x86/kernel/irq_32.c
23455 +++ b/arch/x86/kernel/irq_32.c
23456 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23457 __asm__ __volatile__("andl %%esp,%0" :
23458 "=r" (sp) : "0" (THREAD_SIZE - 1));
23459
23460 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23461 + return sp < STACK_WARN;
23462 }
23463
23464 static void print_stack_overflow(void)
23465 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23466 * per-CPU IRQ handling contexts (thread information and stack)
23467 */
23468 union irq_ctx {
23469 - struct thread_info tinfo;
23470 - u32 stack[THREAD_SIZE/sizeof(u32)];
23471 + unsigned long previous_esp;
23472 + u32 stack[THREAD_SIZE/sizeof(u32)];
23473 } __attribute__((aligned(THREAD_SIZE)));
23474
23475 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23476 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23477 static inline int
23478 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23479 {
23480 - union irq_ctx *curctx, *irqctx;
23481 + union irq_ctx *irqctx;
23482 u32 *isp, arg1, arg2;
23483
23484 - curctx = (union irq_ctx *) current_thread_info();
23485 irqctx = __this_cpu_read(hardirq_ctx);
23486
23487 /*
23488 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23489 * handler) we can't do that and just have to keep using the
23490 * current stack (which is the irq stack already after all)
23491 */
23492 - if (unlikely(curctx == irqctx))
23493 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23494 return 0;
23495
23496 /* build the stack frame on the IRQ stack */
23497 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23498 - irqctx->tinfo.task = curctx->tinfo.task;
23499 - irqctx->tinfo.previous_esp = current_stack_pointer;
23500 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23501 + irqctx->previous_esp = current_stack_pointer;
23502
23503 - /* Copy the preempt_count so that the [soft]irq checks work. */
23504 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23506 + __set_fs(MAKE_MM_SEG(0));
23507 +#endif
23508
23509 if (unlikely(overflow))
23510 call_on_stack(print_stack_overflow, isp);
23511 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23512 : "0" (irq), "1" (desc), "2" (isp),
23513 "D" (desc->handle_irq)
23514 : "memory", "cc", "ecx");
23515 +
23516 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23517 + __set_fs(current_thread_info()->addr_limit);
23518 +#endif
23519 +
23520 return 1;
23521 }
23522
23523 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23524 */
23525 void irq_ctx_init(int cpu)
23526 {
23527 - union irq_ctx *irqctx;
23528 -
23529 if (per_cpu(hardirq_ctx, cpu))
23530 return;
23531
23532 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23533 - THREADINFO_GFP,
23534 - THREAD_SIZE_ORDER));
23535 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23536 - irqctx->tinfo.cpu = cpu;
23537 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23538 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23539 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23540 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23541
23542 - per_cpu(hardirq_ctx, cpu) = irqctx;
23543 -
23544 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23545 - THREADINFO_GFP,
23546 - THREAD_SIZE_ORDER));
23547 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23548 - irqctx->tinfo.cpu = cpu;
23549 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23550 -
23551 - per_cpu(softirq_ctx, cpu) = irqctx;
23552 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23553 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23554
23555 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23556 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23557 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23558 asmlinkage void do_softirq(void)
23559 {
23560 unsigned long flags;
23561 - struct thread_info *curctx;
23562 union irq_ctx *irqctx;
23563 u32 *isp;
23564
23565 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23566 local_irq_save(flags);
23567
23568 if (local_softirq_pending()) {
23569 - curctx = current_thread_info();
23570 irqctx = __this_cpu_read(softirq_ctx);
23571 - irqctx->tinfo.task = curctx->task;
23572 - irqctx->tinfo.previous_esp = current_stack_pointer;
23573 + irqctx->previous_esp = current_stack_pointer;
23574
23575 /* build the stack frame on the softirq stack */
23576 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23577 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23578 +
23579 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23580 + __set_fs(MAKE_MM_SEG(0));
23581 +#endif
23582
23583 call_on_stack(__do_softirq, isp);
23584 +
23585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23586 + __set_fs(current_thread_info()->addr_limit);
23587 +#endif
23588 +
23589 /*
23590 * Shouldn't happen, we returned above if in_interrupt():
23591 */
23592 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23593 if (unlikely(!desc))
23594 return false;
23595
23596 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23597 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23598 if (unlikely(overflow))
23599 print_stack_overflow();
23600 desc->handle_irq(irq, desc);
23601 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23602 index d04d3ec..ea4b374 100644
23603 --- a/arch/x86/kernel/irq_64.c
23604 +++ b/arch/x86/kernel/irq_64.c
23605 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23606 u64 estack_top, estack_bottom;
23607 u64 curbase = (u64)task_stack_page(current);
23608
23609 - if (user_mode_vm(regs))
23610 + if (user_mode(regs))
23611 return;
23612
23613 if (regs->sp >= curbase + sizeof(struct thread_info) +
23614 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23615 index dc1404b..bbc43e7 100644
23616 --- a/arch/x86/kernel/kdebugfs.c
23617 +++ b/arch/x86/kernel/kdebugfs.c
23618 @@ -27,7 +27,7 @@ struct setup_data_node {
23619 u32 len;
23620 };
23621
23622 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23623 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23624 size_t count, loff_t *ppos)
23625 {
23626 struct setup_data_node *node = file->private_data;
23627 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23628 index 836f832..a8bda67 100644
23629 --- a/arch/x86/kernel/kgdb.c
23630 +++ b/arch/x86/kernel/kgdb.c
23631 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23632 #ifdef CONFIG_X86_32
23633 switch (regno) {
23634 case GDB_SS:
23635 - if (!user_mode_vm(regs))
23636 + if (!user_mode(regs))
23637 *(unsigned long *)mem = __KERNEL_DS;
23638 break;
23639 case GDB_SP:
23640 - if (!user_mode_vm(regs))
23641 + if (!user_mode(regs))
23642 *(unsigned long *)mem = kernel_stack_pointer(regs);
23643 break;
23644 case GDB_GS:
23645 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23646 bp->attr.bp_addr = breakinfo[breakno].addr;
23647 bp->attr.bp_len = breakinfo[breakno].len;
23648 bp->attr.bp_type = breakinfo[breakno].type;
23649 - info->address = breakinfo[breakno].addr;
23650 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23651 + info->address = ktla_ktva(breakinfo[breakno].addr);
23652 + else
23653 + info->address = breakinfo[breakno].addr;
23654 info->len = breakinfo[breakno].len;
23655 info->type = breakinfo[breakno].type;
23656 val = arch_install_hw_breakpoint(bp);
23657 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23658 case 'k':
23659 /* clear the trace bit */
23660 linux_regs->flags &= ~X86_EFLAGS_TF;
23661 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23662 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23663
23664 /* set the trace bit if we're stepping */
23665 if (remcomInBuffer[0] == 's') {
23666 linux_regs->flags |= X86_EFLAGS_TF;
23667 - atomic_set(&kgdb_cpu_doing_single_step,
23668 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23669 raw_smp_processor_id());
23670 }
23671
23672 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23673
23674 switch (cmd) {
23675 case DIE_DEBUG:
23676 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23677 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23678 if (user_mode(regs))
23679 return single_step_cont(regs, args);
23680 break;
23681 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23682 #endif /* CONFIG_DEBUG_RODATA */
23683
23684 bpt->type = BP_BREAKPOINT;
23685 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23686 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23687 BREAK_INSTR_SIZE);
23688 if (err)
23689 return err;
23690 - err = probe_kernel_write((char *)bpt->bpt_addr,
23691 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23692 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23693 #ifdef CONFIG_DEBUG_RODATA
23694 if (!err)
23695 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23696 return -EBUSY;
23697 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23698 BREAK_INSTR_SIZE);
23699 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23700 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23701 if (err)
23702 return err;
23703 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23704 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23705 if (mutex_is_locked(&text_mutex))
23706 goto knl_write;
23707 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23708 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23709 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23710 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23711 goto knl_write;
23712 return err;
23713 knl_write:
23714 #endif /* CONFIG_DEBUG_RODATA */
23715 - return probe_kernel_write((char *)bpt->bpt_addr,
23716 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23717 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23718 }
23719
23720 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23721 index 211bce4..6e2580a 100644
23722 --- a/arch/x86/kernel/kprobes/core.c
23723 +++ b/arch/x86/kernel/kprobes/core.c
23724 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23725 s32 raddr;
23726 } __packed *insn;
23727
23728 - insn = (struct __arch_relative_insn *)from;
23729 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23730 +
23731 + pax_open_kernel();
23732 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23733 insn->op = op;
23734 + pax_close_kernel();
23735 }
23736
23737 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23738 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23739 kprobe_opcode_t opcode;
23740 kprobe_opcode_t *orig_opcodes = opcodes;
23741
23742 - if (search_exception_tables((unsigned long)opcodes))
23743 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23744 return 0; /* Page fault may occur on this address. */
23745
23746 retry:
23747 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23748 * for the first byte, we can recover the original instruction
23749 * from it and kp->opcode.
23750 */
23751 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23752 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23753 buf[0] = kp->opcode;
23754 - return (unsigned long)buf;
23755 + return ktva_ktla((unsigned long)buf);
23756 }
23757
23758 /*
23759 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23760 /* Another subsystem puts a breakpoint, failed to recover */
23761 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23762 return 0;
23763 + pax_open_kernel();
23764 memcpy(dest, insn.kaddr, insn.length);
23765 + pax_close_kernel();
23766
23767 #ifdef CONFIG_X86_64
23768 if (insn_rip_relative(&insn)) {
23769 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23770 return 0;
23771 }
23772 disp = (u8 *) dest + insn_offset_displacement(&insn);
23773 + pax_open_kernel();
23774 *(s32 *) disp = (s32) newdisp;
23775 + pax_close_kernel();
23776 }
23777 #endif
23778 return insn.length;
23779 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23780 * nor set current_kprobe, because it doesn't use single
23781 * stepping.
23782 */
23783 - regs->ip = (unsigned long)p->ainsn.insn;
23784 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23785 preempt_enable_no_resched();
23786 return;
23787 }
23788 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23789 regs->flags &= ~X86_EFLAGS_IF;
23790 /* single step inline if the instruction is an int3 */
23791 if (p->opcode == BREAKPOINT_INSTRUCTION)
23792 - regs->ip = (unsigned long)p->addr;
23793 + regs->ip = ktla_ktva((unsigned long)p->addr);
23794 else
23795 - regs->ip = (unsigned long)p->ainsn.insn;
23796 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23797 }
23798
23799 /*
23800 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23801 setup_singlestep(p, regs, kcb, 0);
23802 return 1;
23803 }
23804 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23805 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23806 /*
23807 * The breakpoint instruction was removed right
23808 * after we hit it. Another cpu has removed
23809 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23810 " movq %rax, 152(%rsp)\n"
23811 RESTORE_REGS_STRING
23812 " popfq\n"
23813 +#ifdef KERNEXEC_PLUGIN
23814 + " btsq $63,(%rsp)\n"
23815 +#endif
23816 #else
23817 " pushf\n"
23818 SAVE_REGS_STRING
23819 @@ -779,7 +789,7 @@ static void __kprobes
23820 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23821 {
23822 unsigned long *tos = stack_addr(regs);
23823 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23824 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23825 unsigned long orig_ip = (unsigned long)p->addr;
23826 kprobe_opcode_t *insn = p->ainsn.insn;
23827
23828 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23829 struct die_args *args = data;
23830 int ret = NOTIFY_DONE;
23831
23832 - if (args->regs && user_mode_vm(args->regs))
23833 + if (args->regs && user_mode(args->regs))
23834 return ret;
23835
23836 switch (val) {
23837 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23838 index 76dc6f0..66bdfc3 100644
23839 --- a/arch/x86/kernel/kprobes/opt.c
23840 +++ b/arch/x86/kernel/kprobes/opt.c
23841 @@ -79,6 +79,7 @@ found:
23842 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23843 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23844 {
23845 + pax_open_kernel();
23846 #ifdef CONFIG_X86_64
23847 *addr++ = 0x48;
23848 *addr++ = 0xbf;
23849 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23850 *addr++ = 0xb8;
23851 #endif
23852 *(unsigned long *)addr = val;
23853 + pax_close_kernel();
23854 }
23855
23856 static void __used __kprobes kprobes_optinsn_template_holder(void)
23857 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23858 * Verify if the address gap is in 2GB range, because this uses
23859 * a relative jump.
23860 */
23861 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23862 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23863 if (abs(rel) > 0x7fffffff)
23864 return -ERANGE;
23865
23866 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23867 op->optinsn.size = ret;
23868
23869 /* Copy arch-dep-instance from template */
23870 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23871 + pax_open_kernel();
23872 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23873 + pax_close_kernel();
23874
23875 /* Set probe information */
23876 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23877
23878 /* Set probe function call */
23879 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23880 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23881
23882 /* Set returning jmp instruction at the tail of out-of-line buffer */
23883 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23884 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23885 (u8 *)op->kp.addr + op->optinsn.size);
23886
23887 flush_icache_range((unsigned long) buf,
23888 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23889 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23890
23891 /* Backup instructions which will be replaced by jump address */
23892 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23893 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23894 RELATIVE_ADDR_SIZE);
23895
23896 insn_buf[0] = RELATIVEJUMP_OPCODE;
23897 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23898 /* This kprobe is really able to run optimized path. */
23899 op = container_of(p, struct optimized_kprobe, kp);
23900 /* Detour through copied instructions */
23901 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23902 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23903 if (!reenter)
23904 reset_current_kprobe();
23905 preempt_enable_no_resched();
23906 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23907 index ebc9873..1b9724b 100644
23908 --- a/arch/x86/kernel/ldt.c
23909 +++ b/arch/x86/kernel/ldt.c
23910 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23911 if (reload) {
23912 #ifdef CONFIG_SMP
23913 preempt_disable();
23914 - load_LDT(pc);
23915 + load_LDT_nolock(pc);
23916 if (!cpumask_equal(mm_cpumask(current->mm),
23917 cpumask_of(smp_processor_id())))
23918 smp_call_function(flush_ldt, current->mm, 1);
23919 preempt_enable();
23920 #else
23921 - load_LDT(pc);
23922 + load_LDT_nolock(pc);
23923 #endif
23924 }
23925 if (oldsize) {
23926 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23927 return err;
23928
23929 for (i = 0; i < old->size; i++)
23930 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23931 + write_ldt_entry(new->ldt, i, old->ldt + i);
23932 return 0;
23933 }
23934
23935 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23936 retval = copy_ldt(&mm->context, &old_mm->context);
23937 mutex_unlock(&old_mm->context.lock);
23938 }
23939 +
23940 + if (tsk == current) {
23941 + mm->context.vdso = 0;
23942 +
23943 +#ifdef CONFIG_X86_32
23944 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23945 + mm->context.user_cs_base = 0UL;
23946 + mm->context.user_cs_limit = ~0UL;
23947 +
23948 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23949 + cpus_clear(mm->context.cpu_user_cs_mask);
23950 +#endif
23951 +
23952 +#endif
23953 +#endif
23954 +
23955 + }
23956 +
23957 return retval;
23958 }
23959
23960 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23961 }
23962 }
23963
23964 +#ifdef CONFIG_PAX_SEGMEXEC
23965 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23966 + error = -EINVAL;
23967 + goto out_unlock;
23968 + }
23969 +#endif
23970 +
23971 fill_ldt(&ldt, &ldt_info);
23972 if (oldmode)
23973 ldt.avl = 0;
23974 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23975 index 5b19e4d..6476a76 100644
23976 --- a/arch/x86/kernel/machine_kexec_32.c
23977 +++ b/arch/x86/kernel/machine_kexec_32.c
23978 @@ -26,7 +26,7 @@
23979 #include <asm/cacheflush.h>
23980 #include <asm/debugreg.h>
23981
23982 -static void set_idt(void *newidt, __u16 limit)
23983 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23984 {
23985 struct desc_ptr curidt;
23986
23987 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23988 }
23989
23990
23991 -static void set_gdt(void *newgdt, __u16 limit)
23992 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23993 {
23994 struct desc_ptr curgdt;
23995
23996 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
23997 }
23998
23999 control_page = page_address(image->control_code_page);
24000 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24001 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24002
24003 relocate_kernel_ptr = control_page;
24004 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24005 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24006 index 15c9876..0a43909 100644
24007 --- a/arch/x86/kernel/microcode_core.c
24008 +++ b/arch/x86/kernel/microcode_core.c
24009 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24010 return NOTIFY_OK;
24011 }
24012
24013 -static struct notifier_block __refdata mc_cpu_notifier = {
24014 +static struct notifier_block mc_cpu_notifier = {
24015 .notifier_call = mc_cpu_callback,
24016 };
24017
24018 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24019 index 5fb2ceb..3ae90bb 100644
24020 --- a/arch/x86/kernel/microcode_intel.c
24021 +++ b/arch/x86/kernel/microcode_intel.c
24022 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24023
24024 static int get_ucode_user(void *to, const void *from, size_t n)
24025 {
24026 - return copy_from_user(to, from, n);
24027 + return copy_from_user(to, (const void __force_user *)from, n);
24028 }
24029
24030 static enum ucode_state
24031 request_microcode_user(int cpu, const void __user *buf, size_t size)
24032 {
24033 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24034 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24035 }
24036
24037 static void microcode_fini_cpu(int cpu)
24038 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24039 index 216a4d7..228255a 100644
24040 --- a/arch/x86/kernel/module.c
24041 +++ b/arch/x86/kernel/module.c
24042 @@ -43,15 +43,60 @@ do { \
24043 } while (0)
24044 #endif
24045
24046 -void *module_alloc(unsigned long size)
24047 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24048 {
24049 - if (PAGE_ALIGN(size) > MODULES_LEN)
24050 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24051 return NULL;
24052 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24053 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24054 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24055 -1, __builtin_return_address(0));
24056 }
24057
24058 +void *module_alloc(unsigned long size)
24059 +{
24060 +
24061 +#ifdef CONFIG_PAX_KERNEXEC
24062 + return __module_alloc(size, PAGE_KERNEL);
24063 +#else
24064 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24065 +#endif
24066 +
24067 +}
24068 +
24069 +#ifdef CONFIG_PAX_KERNEXEC
24070 +#ifdef CONFIG_X86_32
24071 +void *module_alloc_exec(unsigned long size)
24072 +{
24073 + struct vm_struct *area;
24074 +
24075 + if (size == 0)
24076 + return NULL;
24077 +
24078 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24079 + return area ? area->addr : NULL;
24080 +}
24081 +EXPORT_SYMBOL(module_alloc_exec);
24082 +
24083 +void module_free_exec(struct module *mod, void *module_region)
24084 +{
24085 + vunmap(module_region);
24086 +}
24087 +EXPORT_SYMBOL(module_free_exec);
24088 +#else
24089 +void module_free_exec(struct module *mod, void *module_region)
24090 +{
24091 + module_free(mod, module_region);
24092 +}
24093 +EXPORT_SYMBOL(module_free_exec);
24094 +
24095 +void *module_alloc_exec(unsigned long size)
24096 +{
24097 + return __module_alloc(size, PAGE_KERNEL_RX);
24098 +}
24099 +EXPORT_SYMBOL(module_alloc_exec);
24100 +#endif
24101 +#endif
24102 +
24103 #ifdef CONFIG_X86_32
24104 int apply_relocate(Elf32_Shdr *sechdrs,
24105 const char *strtab,
24106 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24107 unsigned int i;
24108 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24109 Elf32_Sym *sym;
24110 - uint32_t *location;
24111 + uint32_t *plocation, location;
24112
24113 DEBUGP("Applying relocate section %u to %u\n",
24114 relsec, sechdrs[relsec].sh_info);
24115 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24116 /* This is where to make the change */
24117 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24118 - + rel[i].r_offset;
24119 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24120 + location = (uint32_t)plocation;
24121 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24122 + plocation = ktla_ktva((void *)plocation);
24123 /* This is the symbol it is referring to. Note that all
24124 undefined symbols have been resolved. */
24125 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24126 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24127 switch (ELF32_R_TYPE(rel[i].r_info)) {
24128 case R_386_32:
24129 /* We add the value into the location given */
24130 - *location += sym->st_value;
24131 + pax_open_kernel();
24132 + *plocation += sym->st_value;
24133 + pax_close_kernel();
24134 break;
24135 case R_386_PC32:
24136 /* Add the value, subtract its position */
24137 - *location += sym->st_value - (uint32_t)location;
24138 + pax_open_kernel();
24139 + *plocation += sym->st_value - location;
24140 + pax_close_kernel();
24141 break;
24142 default:
24143 pr_err("%s: Unknown relocation: %u\n",
24144 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24145 case R_X86_64_NONE:
24146 break;
24147 case R_X86_64_64:
24148 + pax_open_kernel();
24149 *(u64 *)loc = val;
24150 + pax_close_kernel();
24151 break;
24152 case R_X86_64_32:
24153 + pax_open_kernel();
24154 *(u32 *)loc = val;
24155 + pax_close_kernel();
24156 if (val != *(u32 *)loc)
24157 goto overflow;
24158 break;
24159 case R_X86_64_32S:
24160 + pax_open_kernel();
24161 *(s32 *)loc = val;
24162 + pax_close_kernel();
24163 if ((s64)val != *(s32 *)loc)
24164 goto overflow;
24165 break;
24166 case R_X86_64_PC32:
24167 val -= (u64)loc;
24168 + pax_open_kernel();
24169 *(u32 *)loc = val;
24170 + pax_close_kernel();
24171 +
24172 #if 0
24173 if ((s64)val != *(s32 *)loc)
24174 goto overflow;
24175 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24176 index 88458fa..349f7a4 100644
24177 --- a/arch/x86/kernel/msr.c
24178 +++ b/arch/x86/kernel/msr.c
24179 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24180 return notifier_from_errno(err);
24181 }
24182
24183 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24184 +static struct notifier_block msr_class_cpu_notifier = {
24185 .notifier_call = msr_class_cpu_callback,
24186 };
24187
24188 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24189 index ba77ebc..65da999 100644
24190 --- a/arch/x86/kernel/nmi.c
24191 +++ b/arch/x86/kernel/nmi.c
24192 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24193 return handled;
24194 }
24195
24196 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24197 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24198 {
24199 struct nmi_desc *desc = nmi_to_desc(type);
24200 unsigned long flags;
24201 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24202 * event confuses some handlers (kdump uses this flag)
24203 */
24204 if (action->flags & NMI_FLAG_FIRST)
24205 - list_add_rcu(&action->list, &desc->head);
24206 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24207 else
24208 - list_add_tail_rcu(&action->list, &desc->head);
24209 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24210
24211 spin_unlock_irqrestore(&desc->lock, flags);
24212 return 0;
24213 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24214 if (!strcmp(n->name, name)) {
24215 WARN(in_nmi(),
24216 "Trying to free NMI (%s) from NMI context!\n", n->name);
24217 - list_del_rcu(&n->list);
24218 + pax_list_del_rcu((struct list_head *)&n->list);
24219 break;
24220 }
24221 }
24222 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24223 dotraplinkage notrace __kprobes void
24224 do_nmi(struct pt_regs *regs, long error_code)
24225 {
24226 +
24227 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24228 + if (!user_mode(regs)) {
24229 + unsigned long cs = regs->cs & 0xFFFF;
24230 + unsigned long ip = ktva_ktla(regs->ip);
24231 +
24232 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24233 + regs->ip = ip;
24234 + }
24235 +#endif
24236 +
24237 nmi_nesting_preprocess(regs);
24238
24239 nmi_enter();
24240 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24241 index 6d9582e..f746287 100644
24242 --- a/arch/x86/kernel/nmi_selftest.c
24243 +++ b/arch/x86/kernel/nmi_selftest.c
24244 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24245 {
24246 /* trap all the unknown NMIs we may generate */
24247 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24248 - __initdata);
24249 + __initconst);
24250 }
24251
24252 static void __init cleanup_nmi_testsuite(void)
24253 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24254 unsigned long timeout;
24255
24256 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24257 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24258 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24259 nmi_fail = FAILURE;
24260 return;
24261 }
24262 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24263 index 676b8c7..870ba04 100644
24264 --- a/arch/x86/kernel/paravirt-spinlocks.c
24265 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24266 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24267 arch_spin_lock(lock);
24268 }
24269
24270 -struct pv_lock_ops pv_lock_ops = {
24271 +struct pv_lock_ops pv_lock_ops __read_only = {
24272 #ifdef CONFIG_SMP
24273 .spin_is_locked = __ticket_spin_is_locked,
24274 .spin_is_contended = __ticket_spin_is_contended,
24275 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24276 index cd6de64..27c6af0 100644
24277 --- a/arch/x86/kernel/paravirt.c
24278 +++ b/arch/x86/kernel/paravirt.c
24279 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24280 {
24281 return x;
24282 }
24283 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24284 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24285 +#endif
24286
24287 void __init default_banner(void)
24288 {
24289 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24290 if (opfunc == NULL)
24291 /* If there's no function, patch it with a ud2a (BUG) */
24292 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24293 - else if (opfunc == _paravirt_nop)
24294 + else if (opfunc == (void *)_paravirt_nop)
24295 /* If the operation is a nop, then nop the callsite */
24296 ret = paravirt_patch_nop();
24297
24298 /* identity functions just return their single argument */
24299 - else if (opfunc == _paravirt_ident_32)
24300 + else if (opfunc == (void *)_paravirt_ident_32)
24301 ret = paravirt_patch_ident_32(insnbuf, len);
24302 - else if (opfunc == _paravirt_ident_64)
24303 + else if (opfunc == (void *)_paravirt_ident_64)
24304 ret = paravirt_patch_ident_64(insnbuf, len);
24305 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24306 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24307 + ret = paravirt_patch_ident_64(insnbuf, len);
24308 +#endif
24309
24310 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24311 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24312 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24313 if (insn_len > len || start == NULL)
24314 insn_len = len;
24315 else
24316 - memcpy(insnbuf, start, insn_len);
24317 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24318
24319 return insn_len;
24320 }
24321 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24322 return this_cpu_read(paravirt_lazy_mode);
24323 }
24324
24325 -struct pv_info pv_info = {
24326 +struct pv_info pv_info __read_only = {
24327 .name = "bare hardware",
24328 .paravirt_enabled = 0,
24329 .kernel_rpl = 0,
24330 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24331 #endif
24332 };
24333
24334 -struct pv_init_ops pv_init_ops = {
24335 +struct pv_init_ops pv_init_ops __read_only = {
24336 .patch = native_patch,
24337 };
24338
24339 -struct pv_time_ops pv_time_ops = {
24340 +struct pv_time_ops pv_time_ops __read_only = {
24341 .sched_clock = native_sched_clock,
24342 .steal_clock = native_steal_clock,
24343 };
24344
24345 -struct pv_irq_ops pv_irq_ops = {
24346 +struct pv_irq_ops pv_irq_ops __read_only = {
24347 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24348 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24349 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24350 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24351 #endif
24352 };
24353
24354 -struct pv_cpu_ops pv_cpu_ops = {
24355 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24356 .cpuid = native_cpuid,
24357 .get_debugreg = native_get_debugreg,
24358 .set_debugreg = native_set_debugreg,
24359 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24360 .end_context_switch = paravirt_nop,
24361 };
24362
24363 -struct pv_apic_ops pv_apic_ops = {
24364 +struct pv_apic_ops pv_apic_ops __read_only= {
24365 #ifdef CONFIG_X86_LOCAL_APIC
24366 .startup_ipi_hook = paravirt_nop,
24367 #endif
24368 };
24369
24370 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24371 +#ifdef CONFIG_X86_32
24372 +#ifdef CONFIG_X86_PAE
24373 +/* 64-bit pagetable entries */
24374 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24375 +#else
24376 /* 32-bit pagetable entries */
24377 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24378 +#endif
24379 #else
24380 /* 64-bit pagetable entries */
24381 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24382 #endif
24383
24384 -struct pv_mmu_ops pv_mmu_ops = {
24385 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24386
24387 .read_cr2 = native_read_cr2,
24388 .write_cr2 = native_write_cr2,
24389 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24390 .make_pud = PTE_IDENT,
24391
24392 .set_pgd = native_set_pgd,
24393 + .set_pgd_batched = native_set_pgd_batched,
24394 #endif
24395 #endif /* PAGETABLE_LEVELS >= 3 */
24396
24397 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24398 },
24399
24400 .set_fixmap = native_set_fixmap,
24401 +
24402 +#ifdef CONFIG_PAX_KERNEXEC
24403 + .pax_open_kernel = native_pax_open_kernel,
24404 + .pax_close_kernel = native_pax_close_kernel,
24405 +#endif
24406 +
24407 };
24408
24409 EXPORT_SYMBOL_GPL(pv_time_ops);
24410 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24411 index 299d493..2ccb0ee 100644
24412 --- a/arch/x86/kernel/pci-calgary_64.c
24413 +++ b/arch/x86/kernel/pci-calgary_64.c
24414 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24415 tce_space = be64_to_cpu(readq(target));
24416 tce_space = tce_space & TAR_SW_BITS;
24417
24418 - tce_space = tce_space & (~specified_table_size);
24419 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24420 info->tce_space = (u64 *)__va(tce_space);
24421 }
24422 }
24423 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24424 index 35ccf75..7a15747 100644
24425 --- a/arch/x86/kernel/pci-iommu_table.c
24426 +++ b/arch/x86/kernel/pci-iommu_table.c
24427 @@ -2,7 +2,7 @@
24428 #include <asm/iommu_table.h>
24429 #include <linux/string.h>
24430 #include <linux/kallsyms.h>
24431 -
24432 +#include <linux/sched.h>
24433
24434 #define DEBUG 1
24435
24436 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24437 index 6c483ba..d10ce2f 100644
24438 --- a/arch/x86/kernel/pci-swiotlb.c
24439 +++ b/arch/x86/kernel/pci-swiotlb.c
24440 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24441 void *vaddr, dma_addr_t dma_addr,
24442 struct dma_attrs *attrs)
24443 {
24444 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24445 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24446 }
24447
24448 static struct dma_map_ops swiotlb_dma_ops = {
24449 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24450 index 83369e5..52b93f0 100644
24451 --- a/arch/x86/kernel/process.c
24452 +++ b/arch/x86/kernel/process.c
24453 @@ -36,7 +36,8 @@
24454 * section. Since TSS's are completely CPU-local, we want them
24455 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24456 */
24457 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24458 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24459 +EXPORT_SYMBOL(init_tss);
24460
24461 #ifdef CONFIG_X86_64
24462 static DEFINE_PER_CPU(unsigned char, is_idle);
24463 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24464 task_xstate_cachep =
24465 kmem_cache_create("task_xstate", xstate_size,
24466 __alignof__(union thread_xstate),
24467 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24468 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24469 }
24470
24471 /*
24472 @@ -105,7 +106,7 @@ void exit_thread(void)
24473 unsigned long *bp = t->io_bitmap_ptr;
24474
24475 if (bp) {
24476 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24477 + struct tss_struct *tss = init_tss + get_cpu();
24478
24479 t->io_bitmap_ptr = NULL;
24480 clear_thread_flag(TIF_IO_BITMAP);
24481 @@ -125,6 +126,9 @@ void flush_thread(void)
24482 {
24483 struct task_struct *tsk = current;
24484
24485 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24486 + loadsegment(gs, 0);
24487 +#endif
24488 flush_ptrace_hw_breakpoint(tsk);
24489 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24490 drop_init_fpu(tsk);
24491 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24492 void exit_idle(void)
24493 {
24494 /* idle loop has pid 0 */
24495 - if (current->pid)
24496 + if (task_pid_nr(current))
24497 return;
24498 __exit_idle();
24499 }
24500 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24501 return ret;
24502 }
24503 #endif
24504 -void stop_this_cpu(void *dummy)
24505 +__noreturn void stop_this_cpu(void *dummy)
24506 {
24507 local_irq_disable();
24508 /*
24509 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24510 }
24511 early_param("idle", idle_setup);
24512
24513 -unsigned long arch_align_stack(unsigned long sp)
24514 +#ifdef CONFIG_PAX_RANDKSTACK
24515 +void pax_randomize_kstack(struct pt_regs *regs)
24516 {
24517 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24518 - sp -= get_random_int() % 8192;
24519 - return sp & ~0xf;
24520 -}
24521 + struct thread_struct *thread = &current->thread;
24522 + unsigned long time;
24523
24524 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24525 -{
24526 - unsigned long range_end = mm->brk + 0x02000000;
24527 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24528 -}
24529 + if (!randomize_va_space)
24530 + return;
24531 +
24532 + if (v8086_mode(regs))
24533 + return;
24534
24535 + rdtscl(time);
24536 +
24537 + /* P4 seems to return a 0 LSB, ignore it */
24538 +#ifdef CONFIG_MPENTIUM4
24539 + time &= 0x3EUL;
24540 + time <<= 2;
24541 +#elif defined(CONFIG_X86_64)
24542 + time &= 0xFUL;
24543 + time <<= 4;
24544 +#else
24545 + time &= 0x1FUL;
24546 + time <<= 3;
24547 +#endif
24548 +
24549 + thread->sp0 ^= time;
24550 + load_sp0(init_tss + smp_processor_id(), thread);
24551 +
24552 +#ifdef CONFIG_X86_64
24553 + this_cpu_write(kernel_stack, thread->sp0);
24554 +#endif
24555 +}
24556 +#endif
24557 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24558 index f8adefc..4bce3d6 100644
24559 --- a/arch/x86/kernel/process_32.c
24560 +++ b/arch/x86/kernel/process_32.c
24561 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24562 unsigned long thread_saved_pc(struct task_struct *tsk)
24563 {
24564 return ((unsigned long *)tsk->thread.sp)[3];
24565 +//XXX return tsk->thread.eip;
24566 }
24567
24568 void __show_regs(struct pt_regs *regs, int all)
24569 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24570 unsigned long sp;
24571 unsigned short ss, gs;
24572
24573 - if (user_mode_vm(regs)) {
24574 + if (user_mode(regs)) {
24575 sp = regs->sp;
24576 ss = regs->ss & 0xffff;
24577 - gs = get_user_gs(regs);
24578 } else {
24579 sp = kernel_stack_pointer(regs);
24580 savesegment(ss, ss);
24581 - savesegment(gs, gs);
24582 }
24583 + gs = get_user_gs(regs);
24584
24585 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24586 (u16)regs->cs, regs->ip, regs->flags,
24587 - smp_processor_id());
24588 + raw_smp_processor_id());
24589 print_symbol("EIP is at %s\n", regs->ip);
24590
24591 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24592 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24593 int copy_thread(unsigned long clone_flags, unsigned long sp,
24594 unsigned long arg, struct task_struct *p)
24595 {
24596 - struct pt_regs *childregs = task_pt_regs(p);
24597 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24598 struct task_struct *tsk;
24599 int err;
24600
24601 p->thread.sp = (unsigned long) childregs;
24602 p->thread.sp0 = (unsigned long) (childregs+1);
24603 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24604
24605 if (unlikely(p->flags & PF_KTHREAD)) {
24606 /* kernel thread */
24607 memset(childregs, 0, sizeof(struct pt_regs));
24608 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24609 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24610 - childregs->ds = __USER_DS;
24611 - childregs->es = __USER_DS;
24612 + savesegment(gs, childregs->gs);
24613 + childregs->ds = __KERNEL_DS;
24614 + childregs->es = __KERNEL_DS;
24615 childregs->fs = __KERNEL_PERCPU;
24616 childregs->bx = sp; /* function */
24617 childregs->bp = arg;
24618 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24619 struct thread_struct *prev = &prev_p->thread,
24620 *next = &next_p->thread;
24621 int cpu = smp_processor_id();
24622 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24623 + struct tss_struct *tss = init_tss + cpu;
24624 fpu_switch_t fpu;
24625
24626 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24627 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24628 */
24629 lazy_save_gs(prev->gs);
24630
24631 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24632 + __set_fs(task_thread_info(next_p)->addr_limit);
24633 +#endif
24634 +
24635 /*
24636 * Load the per-thread Thread-Local Storage descriptor.
24637 */
24638 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24639 */
24640 arch_end_context_switch(next_p);
24641
24642 + this_cpu_write(current_task, next_p);
24643 + this_cpu_write(current_tinfo, &next_p->tinfo);
24644 +
24645 /*
24646 * Restore %gs if needed (which is common)
24647 */
24648 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24649
24650 switch_fpu_finish(next_p, fpu);
24651
24652 - this_cpu_write(current_task, next_p);
24653 -
24654 return prev_p;
24655 }
24656
24657 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24658 } while (count++ < 16);
24659 return 0;
24660 }
24661 -
24662 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24663 index 05646ba..0c2906d 100644
24664 --- a/arch/x86/kernel/process_64.c
24665 +++ b/arch/x86/kernel/process_64.c
24666 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24667 struct pt_regs *childregs;
24668 struct task_struct *me = current;
24669
24670 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24671 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24672 childregs = task_pt_regs(p);
24673 p->thread.sp = (unsigned long) childregs;
24674 p->thread.usersp = me->thread.usersp;
24675 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24676 set_tsk_thread_flag(p, TIF_FORK);
24677 p->fpu_counter = 0;
24678 p->thread.io_bitmap_ptr = NULL;
24679 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24680 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24681 savesegment(es, p->thread.es);
24682 savesegment(ds, p->thread.ds);
24683 + savesegment(ss, p->thread.ss);
24684 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24685 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24686
24687 if (unlikely(p->flags & PF_KTHREAD)) {
24688 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24689 struct thread_struct *prev = &prev_p->thread;
24690 struct thread_struct *next = &next_p->thread;
24691 int cpu = smp_processor_id();
24692 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24693 + struct tss_struct *tss = init_tss + cpu;
24694 unsigned fsindex, gsindex;
24695 fpu_switch_t fpu;
24696
24697 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24698 if (unlikely(next->ds | prev->ds))
24699 loadsegment(ds, next->ds);
24700
24701 + savesegment(ss, prev->ss);
24702 + if (unlikely(next->ss != prev->ss))
24703 + loadsegment(ss, next->ss);
24704
24705 /* We must save %fs and %gs before load_TLS() because
24706 * %fs and %gs may be cleared by load_TLS().
24707 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24708 prev->usersp = this_cpu_read(old_rsp);
24709 this_cpu_write(old_rsp, next->usersp);
24710 this_cpu_write(current_task, next_p);
24711 + this_cpu_write(current_tinfo, &next_p->tinfo);
24712
24713 - this_cpu_write(kernel_stack,
24714 - (unsigned long)task_stack_page(next_p) +
24715 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24716 + this_cpu_write(kernel_stack, next->sp0);
24717
24718 /*
24719 * Now maybe reload the debug registers and handle I/O bitmaps
24720 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24721 if (!p || p == current || p->state == TASK_RUNNING)
24722 return 0;
24723 stack = (unsigned long)task_stack_page(p);
24724 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24725 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24726 return 0;
24727 fp = *(u64 *)(p->thread.sp);
24728 do {
24729 - if (fp < (unsigned long)stack ||
24730 - fp >= (unsigned long)stack+THREAD_SIZE)
24731 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24732 return 0;
24733 ip = *(u64 *)(fp+8);
24734 if (!in_sched_functions(ip))
24735 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24736 index 7461f50..1334029 100644
24737 --- a/arch/x86/kernel/ptrace.c
24738 +++ b/arch/x86/kernel/ptrace.c
24739 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24740 {
24741 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24742 unsigned long sp = (unsigned long)&regs->sp;
24743 - struct thread_info *tinfo;
24744
24745 - if (context == (sp & ~(THREAD_SIZE - 1)))
24746 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24747 return sp;
24748
24749 - tinfo = (struct thread_info *)context;
24750 - if (tinfo->previous_esp)
24751 - return tinfo->previous_esp;
24752 + sp = *(unsigned long *)context;
24753 + if (sp)
24754 + return sp;
24755
24756 return (unsigned long)regs;
24757 }
24758 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24759 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24760 {
24761 int i;
24762 - int dr7 = 0;
24763 + unsigned long dr7 = 0;
24764 struct arch_hw_breakpoint *info;
24765
24766 for (i = 0; i < HBP_NUM; i++) {
24767 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24768 unsigned long addr, unsigned long data)
24769 {
24770 int ret;
24771 - unsigned long __user *datap = (unsigned long __user *)data;
24772 + unsigned long __user *datap = (__force unsigned long __user *)data;
24773
24774 switch (request) {
24775 /* read the word at location addr in the USER area. */
24776 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24777 if ((int) addr < 0)
24778 return -EIO;
24779 ret = do_get_thread_area(child, addr,
24780 - (struct user_desc __user *)data);
24781 + (__force struct user_desc __user *) data);
24782 break;
24783
24784 case PTRACE_SET_THREAD_AREA:
24785 if ((int) addr < 0)
24786 return -EIO;
24787 ret = do_set_thread_area(child, addr,
24788 - (struct user_desc __user *)data, 0);
24789 + (__force struct user_desc __user *) data, 0);
24790 break;
24791 #endif
24792
24793 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24794
24795 #ifdef CONFIG_X86_64
24796
24797 -static struct user_regset x86_64_regsets[] __read_mostly = {
24798 +static user_regset_no_const x86_64_regsets[] __read_only = {
24799 [REGSET_GENERAL] = {
24800 .core_note_type = NT_PRSTATUS,
24801 .n = sizeof(struct user_regs_struct) / sizeof(long),
24802 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24803 #endif /* CONFIG_X86_64 */
24804
24805 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24806 -static struct user_regset x86_32_regsets[] __read_mostly = {
24807 +static user_regset_no_const x86_32_regsets[] __read_only = {
24808 [REGSET_GENERAL] = {
24809 .core_note_type = NT_PRSTATUS,
24810 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24811 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24812 */
24813 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24814
24815 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24816 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24817 {
24818 #ifdef CONFIG_X86_64
24819 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24820 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24821 memset(info, 0, sizeof(*info));
24822 info->si_signo = SIGTRAP;
24823 info->si_code = si_code;
24824 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24825 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24826 }
24827
24828 void user_single_step_siginfo(struct task_struct *tsk,
24829 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24830 # define IS_IA32 0
24831 #endif
24832
24833 +#ifdef CONFIG_GRKERNSEC_SETXID
24834 +extern void gr_delayed_cred_worker(void);
24835 +#endif
24836 +
24837 /*
24838 * We must return the syscall number to actually look up in the table.
24839 * This can be -1L to skip running any syscall at all.
24840 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24841
24842 user_exit();
24843
24844 +#ifdef CONFIG_GRKERNSEC_SETXID
24845 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24846 + gr_delayed_cred_worker();
24847 +#endif
24848 +
24849 /*
24850 * If we stepped into a sysenter/syscall insn, it trapped in
24851 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24852 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24853 */
24854 user_exit();
24855
24856 +#ifdef CONFIG_GRKERNSEC_SETXID
24857 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24858 + gr_delayed_cred_worker();
24859 +#endif
24860 +
24861 audit_syscall_exit(regs);
24862
24863 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24864 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24865 index 2cb9470..ff1fd80 100644
24866 --- a/arch/x86/kernel/pvclock.c
24867 +++ b/arch/x86/kernel/pvclock.c
24868 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24869 return pv_tsc_khz;
24870 }
24871
24872 -static atomic64_t last_value = ATOMIC64_INIT(0);
24873 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24874
24875 void pvclock_resume(void)
24876 {
24877 - atomic64_set(&last_value, 0);
24878 + atomic64_set_unchecked(&last_value, 0);
24879 }
24880
24881 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24882 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24883 * updating at the same time, and one of them could be slightly behind,
24884 * making the assumption that last_value always go forward fail to hold.
24885 */
24886 - last = atomic64_read(&last_value);
24887 + last = atomic64_read_unchecked(&last_value);
24888 do {
24889 if (ret < last)
24890 return last;
24891 - last = atomic64_cmpxchg(&last_value, last, ret);
24892 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24893 } while (unlikely(last != ret));
24894
24895 return ret;
24896 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24897 index 563ed91..b9c3313 100644
24898 --- a/arch/x86/kernel/reboot.c
24899 +++ b/arch/x86/kernel/reboot.c
24900 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24901
24902 void __noreturn machine_real_restart(unsigned int type)
24903 {
24904 +
24905 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24906 + struct desc_struct *gdt;
24907 +#endif
24908 +
24909 local_irq_disable();
24910
24911 /*
24912 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24913
24914 /* Jump to the identity-mapped low memory code */
24915 #ifdef CONFIG_X86_32
24916 - asm volatile("jmpl *%0" : :
24917 +
24918 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24919 + gdt = get_cpu_gdt_table(smp_processor_id());
24920 + pax_open_kernel();
24921 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24922 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24923 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24924 + loadsegment(ds, __KERNEL_DS);
24925 + loadsegment(es, __KERNEL_DS);
24926 + loadsegment(ss, __KERNEL_DS);
24927 +#endif
24928 +#ifdef CONFIG_PAX_KERNEXEC
24929 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24930 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24931 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24932 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24933 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24934 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24935 +#endif
24936 + pax_close_kernel();
24937 +#endif
24938 +
24939 + asm volatile("ljmpl *%0" : :
24940 "rm" (real_mode_header->machine_real_restart_asm),
24941 "a" (type));
24942 #else
24943 @@ -442,7 +469,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24944 * try to force a triple fault and then cycle between hitting the keyboard
24945 * controller and doing that
24946 */
24947 -static void native_machine_emergency_restart(void)
24948 +static void __noreturn native_machine_emergency_restart(void)
24949 {
24950 int i;
24951 int attempt = 0;
24952 @@ -551,13 +578,13 @@ void native_machine_shutdown(void)
24953 #endif
24954 }
24955
24956 -static void __machine_emergency_restart(int emergency)
24957 +static void __noreturn __machine_emergency_restart(int emergency)
24958 {
24959 reboot_emergency = emergency;
24960 machine_ops.emergency_restart();
24961 }
24962
24963 -static void native_machine_restart(char *__unused)
24964 +static void __noreturn native_machine_restart(char *__unused)
24965 {
24966 pr_notice("machine restart\n");
24967
24968 @@ -566,7 +593,7 @@ static void native_machine_restart(char *__unused)
24969 __machine_emergency_restart(0);
24970 }
24971
24972 -static void native_machine_halt(void)
24973 +static void __noreturn native_machine_halt(void)
24974 {
24975 /* Stop other cpus and apics */
24976 machine_shutdown();
24977 @@ -576,7 +603,7 @@ static void native_machine_halt(void)
24978 stop_this_cpu(NULL);
24979 }
24980
24981 -static void native_machine_power_off(void)
24982 +static void __noreturn native_machine_power_off(void)
24983 {
24984 if (pm_power_off) {
24985 if (!reboot_force)
24986 @@ -585,9 +612,10 @@ static void native_machine_power_off(void)
24987 }
24988 /* A fallback in case there is no PM info available */
24989 tboot_shutdown(TB_SHUTDOWN_HALT);
24990 + unreachable();
24991 }
24992
24993 -struct machine_ops machine_ops = {
24994 +struct machine_ops machine_ops __read_only = {
24995 .power_off = native_machine_power_off,
24996 .shutdown = native_machine_shutdown,
24997 .emergency_restart = native_machine_emergency_restart,
24998 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
24999 index c8e41e9..64049ef 100644
25000 --- a/arch/x86/kernel/reboot_fixups_32.c
25001 +++ b/arch/x86/kernel/reboot_fixups_32.c
25002 @@ -57,7 +57,7 @@ struct device_fixup {
25003 unsigned int vendor;
25004 unsigned int device;
25005 void (*reboot_fixup)(struct pci_dev *);
25006 -};
25007 +} __do_const;
25008
25009 /*
25010 * PCI ids solely used for fixups_table go here
25011 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25012 index 3fd2c69..16ef367 100644
25013 --- a/arch/x86/kernel/relocate_kernel_64.S
25014 +++ b/arch/x86/kernel/relocate_kernel_64.S
25015 @@ -11,6 +11,7 @@
25016 #include <asm/kexec.h>
25017 #include <asm/processor-flags.h>
25018 #include <asm/pgtable_types.h>
25019 +#include <asm/alternative-asm.h>
25020
25021 /*
25022 * Must be relocatable PIC code callable as a C function
25023 @@ -96,8 +97,7 @@ relocate_kernel:
25024
25025 /* jump to identity mapped page */
25026 addq $(identity_mapped - relocate_kernel), %r8
25027 - pushq %r8
25028 - ret
25029 + jmp *%r8
25030
25031 identity_mapped:
25032 /* set return address to 0 if not preserving context */
25033 @@ -167,6 +167,7 @@ identity_mapped:
25034 xorl %r14d, %r14d
25035 xorl %r15d, %r15d
25036
25037 + pax_force_retaddr 0, 1
25038 ret
25039
25040 1:
25041 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25042 index f8ec578..0cc110a 100644
25043 --- a/arch/x86/kernel/setup.c
25044 +++ b/arch/x86/kernel/setup.c
25045 @@ -110,6 +110,7 @@
25046 #include <asm/mce.h>
25047 #include <asm/alternative.h>
25048 #include <asm/prom.h>
25049 +#include <asm/boot.h>
25050
25051 /*
25052 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25053 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25054 #endif
25055
25056
25057 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25058 -unsigned long mmu_cr4_features;
25059 +#ifdef CONFIG_X86_64
25060 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25061 +#elif defined(CONFIG_X86_PAE)
25062 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25063 #else
25064 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25065 +unsigned long mmu_cr4_features __read_only;
25066 #endif
25067
25068 +void set_in_cr4(unsigned long mask)
25069 +{
25070 + unsigned long cr4 = read_cr4();
25071 +
25072 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25073 + return;
25074 +
25075 + pax_open_kernel();
25076 + mmu_cr4_features |= mask;
25077 + pax_close_kernel();
25078 +
25079 + if (trampoline_cr4_features)
25080 + *trampoline_cr4_features = mmu_cr4_features;
25081 + cr4 |= mask;
25082 + write_cr4(cr4);
25083 +}
25084 +EXPORT_SYMBOL(set_in_cr4);
25085 +
25086 +void clear_in_cr4(unsigned long mask)
25087 +{
25088 + unsigned long cr4 = read_cr4();
25089 +
25090 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25091 + return;
25092 +
25093 + pax_open_kernel();
25094 + mmu_cr4_features &= ~mask;
25095 + pax_close_kernel();
25096 +
25097 + if (trampoline_cr4_features)
25098 + *trampoline_cr4_features = mmu_cr4_features;
25099 + cr4 &= ~mask;
25100 + write_cr4(cr4);
25101 +}
25102 +EXPORT_SYMBOL(clear_in_cr4);
25103 +
25104 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25105 int bootloader_type, bootloader_version;
25106
25107 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
25108
25109 switch (data->type) {
25110 case SETUP_E820_EXT:
25111 - parse_e820_ext(data);
25112 + parse_e820_ext((struct setup_data __force_kernel *)data);
25113 break;
25114 case SETUP_DTB:
25115 add_dtb(pa_data);
25116 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
25117 * area (640->1Mb) as ram even though it is not.
25118 * take them out.
25119 */
25120 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25121 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25122
25123 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25124 }
25125 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
25126 /* called before trim_bios_range() to spare extra sanitize */
25127 static void __init e820_add_kernel_range(void)
25128 {
25129 - u64 start = __pa_symbol(_text);
25130 + u64 start = __pa_symbol(ktla_ktva(_text));
25131 u64 size = __pa_symbol(_end) - start;
25132
25133 /*
25134 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
25135
25136 void __init setup_arch(char **cmdline_p)
25137 {
25138 +#ifdef CONFIG_X86_32
25139 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25140 +#else
25141 memblock_reserve(__pa_symbol(_text),
25142 (unsigned long)__bss_stop - (unsigned long)_text);
25143 +#endif
25144
25145 early_reserve_initrd();
25146
25147 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
25148
25149 if (!boot_params.hdr.root_flags)
25150 root_mountflags &= ~MS_RDONLY;
25151 - init_mm.start_code = (unsigned long) _text;
25152 - init_mm.end_code = (unsigned long) _etext;
25153 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25154 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25155 init_mm.end_data = (unsigned long) _edata;
25156 init_mm.brk = _brk_end;
25157
25158 - code_resource.start = __pa_symbol(_text);
25159 - code_resource.end = __pa_symbol(_etext)-1;
25160 - data_resource.start = __pa_symbol(_etext);
25161 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25162 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25163 + data_resource.start = __pa_symbol(_sdata);
25164 data_resource.end = __pa_symbol(_edata)-1;
25165 bss_resource.start = __pa_symbol(__bss_start);
25166 bss_resource.end = __pa_symbol(__bss_stop)-1;
25167 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25168 index 5cdff03..80fa283 100644
25169 --- a/arch/x86/kernel/setup_percpu.c
25170 +++ b/arch/x86/kernel/setup_percpu.c
25171 @@ -21,19 +21,17 @@
25172 #include <asm/cpu.h>
25173 #include <asm/stackprotector.h>
25174
25175 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25176 +#ifdef CONFIG_SMP
25177 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25178 EXPORT_PER_CPU_SYMBOL(cpu_number);
25179 +#endif
25180
25181 -#ifdef CONFIG_X86_64
25182 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25183 -#else
25184 -#define BOOT_PERCPU_OFFSET 0
25185 -#endif
25186
25187 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25188 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25189
25190 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25191 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25192 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25193 };
25194 EXPORT_SYMBOL(__per_cpu_offset);
25195 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25196 {
25197 #ifdef CONFIG_NEED_MULTIPLE_NODES
25198 pg_data_t *last = NULL;
25199 - unsigned int cpu;
25200 + int cpu;
25201
25202 for_each_possible_cpu(cpu) {
25203 int node = early_cpu_to_node(cpu);
25204 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25205 {
25206 #ifdef CONFIG_X86_32
25207 struct desc_struct gdt;
25208 + unsigned long base = per_cpu_offset(cpu);
25209
25210 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25211 - 0x2 | DESCTYPE_S, 0x8);
25212 - gdt.s = 1;
25213 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25214 + 0x83 | DESCTYPE_S, 0xC);
25215 write_gdt_entry(get_cpu_gdt_table(cpu),
25216 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25217 #endif
25218 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25219 /* alrighty, percpu areas up and running */
25220 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25221 for_each_possible_cpu(cpu) {
25222 +#ifdef CONFIG_CC_STACKPROTECTOR
25223 +#ifdef CONFIG_X86_32
25224 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25225 +#endif
25226 +#endif
25227 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25228 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25229 per_cpu(cpu_number, cpu) = cpu;
25230 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25231 */
25232 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25233 #endif
25234 +#ifdef CONFIG_CC_STACKPROTECTOR
25235 +#ifdef CONFIG_X86_32
25236 + if (!cpu)
25237 + per_cpu(stack_canary.canary, cpu) = canary;
25238 +#endif
25239 +#endif
25240 /*
25241 * Up to this point, the boot CPU has been using .init.data
25242 * area. Reload any changed state for the boot CPU.
25243 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25244 index d859eea..44e17c4 100644
25245 --- a/arch/x86/kernel/signal.c
25246 +++ b/arch/x86/kernel/signal.c
25247 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25248 * Align the stack pointer according to the i386 ABI,
25249 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25250 */
25251 - sp = ((sp + 4) & -16ul) - 4;
25252 + sp = ((sp - 12) & -16ul) - 4;
25253 #else /* !CONFIG_X86_32 */
25254 sp = round_down(sp, 16) - 8;
25255 #endif
25256 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25257 }
25258
25259 if (current->mm->context.vdso)
25260 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25261 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25262 else
25263 - restorer = &frame->retcode;
25264 + restorer = (void __user *)&frame->retcode;
25265 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25266 restorer = ksig->ka.sa.sa_restorer;
25267
25268 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25269 * reasons and because gdb uses it as a signature to notice
25270 * signal handler stack frames.
25271 */
25272 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25273 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25274
25275 if (err)
25276 return -EFAULT;
25277 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25278 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25279
25280 /* Set up to return from userspace. */
25281 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25282 + if (current->mm->context.vdso)
25283 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25284 + else
25285 + restorer = (void __user *)&frame->retcode;
25286 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25287 restorer = ksig->ka.sa.sa_restorer;
25288 put_user_ex(restorer, &frame->pretcode);
25289 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25290 * reasons and because gdb uses it as a signature to notice
25291 * signal handler stack frames.
25292 */
25293 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25294 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25295 } put_user_catch(err);
25296
25297 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25298 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25299 {
25300 int usig = signr_convert(ksig->sig);
25301 sigset_t *set = sigmask_to_save();
25302 - compat_sigset_t *cset = (compat_sigset_t *) set;
25303 + sigset_t sigcopy;
25304 + compat_sigset_t *cset;
25305 +
25306 + sigcopy = *set;
25307 +
25308 + cset = (compat_sigset_t *) &sigcopy;
25309
25310 /* Set up the stack frame */
25311 if (is_ia32_frame()) {
25312 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25313 } else if (is_x32_frame()) {
25314 return x32_setup_rt_frame(ksig, cset, regs);
25315 } else {
25316 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25317 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25318 }
25319 }
25320
25321 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25322 index cdaa347..f5af55d 100644
25323 --- a/arch/x86/kernel/smp.c
25324 +++ b/arch/x86/kernel/smp.c
25325 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25326
25327 __setup("nonmi_ipi", nonmi_ipi_setup);
25328
25329 -struct smp_ops smp_ops = {
25330 +struct smp_ops smp_ops __read_only = {
25331 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25332 .smp_prepare_cpus = native_smp_prepare_cpus,
25333 .smp_cpus_done = native_smp_cpus_done,
25334 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25335 index aecc98a..0244a53 100644
25336 --- a/arch/x86/kernel/smpboot.c
25337 +++ b/arch/x86/kernel/smpboot.c
25338 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25339
25340 enable_start_cpu0 = 0;
25341
25342 -#ifdef CONFIG_X86_32
25343 - /* switch away from the initial page table */
25344 - load_cr3(swapper_pg_dir);
25345 - __flush_tlb_all();
25346 -#endif
25347 -
25348 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25349 barrier();
25350 +
25351 + /* switch away from the initial page table */
25352 +#ifdef CONFIG_PAX_PER_CPU_PGD
25353 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25354 + __flush_tlb_all();
25355 +#elif defined(CONFIG_X86_32)
25356 + load_cr3(swapper_pg_dir);
25357 + __flush_tlb_all();
25358 +#endif
25359 +
25360 /*
25361 * Check TSC synchronization with the BP:
25362 */
25363 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25364 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25365 (THREAD_SIZE + task_stack_page(idle))) - 1);
25366 per_cpu(current_task, cpu) = idle;
25367 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25368
25369 #ifdef CONFIG_X86_32
25370 /* Stack for startup_32 can be just as for start_secondary onwards */
25371 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25372 #else
25373 clear_tsk_thread_flag(idle, TIF_FORK);
25374 initial_gs = per_cpu_offset(cpu);
25375 - per_cpu(kernel_stack, cpu) =
25376 - (unsigned long)task_stack_page(idle) -
25377 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25378 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25379 #endif
25380 +
25381 + pax_open_kernel();
25382 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25383 + pax_close_kernel();
25384 +
25385 initial_code = (unsigned long)start_secondary;
25386 stack_start = idle->thread.sp;
25387
25388 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25389 /* the FPU context is blank, nobody can own it */
25390 __cpu_disable_lazy_restore(cpu);
25391
25392 +#ifdef CONFIG_PAX_PER_CPU_PGD
25393 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25394 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25395 + KERNEL_PGD_PTRS);
25396 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25397 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25398 + KERNEL_PGD_PTRS);
25399 +#endif
25400 +
25401 err = do_boot_cpu(apicid, cpu, tidle);
25402 if (err) {
25403 pr_debug("do_boot_cpu failed %d\n", err);
25404 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25405 index 9b4d51d..5d28b58 100644
25406 --- a/arch/x86/kernel/step.c
25407 +++ b/arch/x86/kernel/step.c
25408 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25409 struct desc_struct *desc;
25410 unsigned long base;
25411
25412 - seg &= ~7UL;
25413 + seg >>= 3;
25414
25415 mutex_lock(&child->mm->context.lock);
25416 - if (unlikely((seg >> 3) >= child->mm->context.size))
25417 + if (unlikely(seg >= child->mm->context.size))
25418 addr = -1L; /* bogus selector, access would fault */
25419 else {
25420 desc = child->mm->context.ldt + seg;
25421 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25422 addr += base;
25423 }
25424 mutex_unlock(&child->mm->context.lock);
25425 - }
25426 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25427 + addr = ktla_ktva(addr);
25428
25429 return addr;
25430 }
25431 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25432 unsigned char opcode[15];
25433 unsigned long addr = convert_ip_to_linear(child, regs);
25434
25435 + if (addr == -EINVAL)
25436 + return 0;
25437 +
25438 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25439 for (i = 0; i < copied; i++) {
25440 switch (opcode[i]) {
25441 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25442 new file mode 100644
25443 index 0000000..5877189
25444 --- /dev/null
25445 +++ b/arch/x86/kernel/sys_i386_32.c
25446 @@ -0,0 +1,189 @@
25447 +/*
25448 + * This file contains various random system calls that
25449 + * have a non-standard calling sequence on the Linux/i386
25450 + * platform.
25451 + */
25452 +
25453 +#include <linux/errno.h>
25454 +#include <linux/sched.h>
25455 +#include <linux/mm.h>
25456 +#include <linux/fs.h>
25457 +#include <linux/smp.h>
25458 +#include <linux/sem.h>
25459 +#include <linux/msg.h>
25460 +#include <linux/shm.h>
25461 +#include <linux/stat.h>
25462 +#include <linux/syscalls.h>
25463 +#include <linux/mman.h>
25464 +#include <linux/file.h>
25465 +#include <linux/utsname.h>
25466 +#include <linux/ipc.h>
25467 +#include <linux/elf.h>
25468 +
25469 +#include <linux/uaccess.h>
25470 +#include <linux/unistd.h>
25471 +
25472 +#include <asm/syscalls.h>
25473 +
25474 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25475 +{
25476 + unsigned long pax_task_size = TASK_SIZE;
25477 +
25478 +#ifdef CONFIG_PAX_SEGMEXEC
25479 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25480 + pax_task_size = SEGMEXEC_TASK_SIZE;
25481 +#endif
25482 +
25483 + if (flags & MAP_FIXED)
25484 + if (len > pax_task_size || addr > pax_task_size - len)
25485 + return -EINVAL;
25486 +
25487 + return 0;
25488 +}
25489 +
25490 +/*
25491 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25492 + */
25493 +static unsigned long get_align_mask(void)
25494 +{
25495 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25496 + return 0;
25497 +
25498 + if (!(current->flags & PF_RANDOMIZE))
25499 + return 0;
25500 +
25501 + return va_align.mask;
25502 +}
25503 +
25504 +unsigned long
25505 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25506 + unsigned long len, unsigned long pgoff, unsigned long flags)
25507 +{
25508 + struct mm_struct *mm = current->mm;
25509 + struct vm_area_struct *vma;
25510 + unsigned long pax_task_size = TASK_SIZE;
25511 + struct vm_unmapped_area_info info;
25512 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25513 +
25514 +#ifdef CONFIG_PAX_SEGMEXEC
25515 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25516 + pax_task_size = SEGMEXEC_TASK_SIZE;
25517 +#endif
25518 +
25519 + pax_task_size -= PAGE_SIZE;
25520 +
25521 + if (len > pax_task_size)
25522 + return -ENOMEM;
25523 +
25524 + if (flags & MAP_FIXED)
25525 + return addr;
25526 +
25527 +#ifdef CONFIG_PAX_RANDMMAP
25528 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25529 +#endif
25530 +
25531 + if (addr) {
25532 + addr = PAGE_ALIGN(addr);
25533 + if (pax_task_size - len >= addr) {
25534 + vma = find_vma(mm, addr);
25535 + if (check_heap_stack_gap(vma, addr, len, offset))
25536 + return addr;
25537 + }
25538 + }
25539 +
25540 + info.flags = 0;
25541 + info.length = len;
25542 + info.align_mask = filp ? get_align_mask() : 0;
25543 + info.align_offset = pgoff << PAGE_SHIFT;
25544 + info.threadstack_offset = offset;
25545 +
25546 +#ifdef CONFIG_PAX_PAGEEXEC
25547 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25548 + info.low_limit = 0x00110000UL;
25549 + info.high_limit = mm->start_code;
25550 +
25551 +#ifdef CONFIG_PAX_RANDMMAP
25552 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25553 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25554 +#endif
25555 +
25556 + if (info.low_limit < info.high_limit) {
25557 + addr = vm_unmapped_area(&info);
25558 + if (!IS_ERR_VALUE(addr))
25559 + return addr;
25560 + }
25561 + } else
25562 +#endif
25563 +
25564 + info.low_limit = mm->mmap_base;
25565 + info.high_limit = pax_task_size;
25566 +
25567 + return vm_unmapped_area(&info);
25568 +}
25569 +
25570 +unsigned long
25571 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25572 + const unsigned long len, const unsigned long pgoff,
25573 + const unsigned long flags)
25574 +{
25575 + struct vm_area_struct *vma;
25576 + struct mm_struct *mm = current->mm;
25577 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25578 + struct vm_unmapped_area_info info;
25579 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25580 +
25581 +#ifdef CONFIG_PAX_SEGMEXEC
25582 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25583 + pax_task_size = SEGMEXEC_TASK_SIZE;
25584 +#endif
25585 +
25586 + pax_task_size -= PAGE_SIZE;
25587 +
25588 + /* requested length too big for entire address space */
25589 + if (len > pax_task_size)
25590 + return -ENOMEM;
25591 +
25592 + if (flags & MAP_FIXED)
25593 + return addr;
25594 +
25595 +#ifdef CONFIG_PAX_PAGEEXEC
25596 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25597 + goto bottomup;
25598 +#endif
25599 +
25600 +#ifdef CONFIG_PAX_RANDMMAP
25601 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25602 +#endif
25603 +
25604 + /* requesting a specific address */
25605 + if (addr) {
25606 + addr = PAGE_ALIGN(addr);
25607 + if (pax_task_size - len >= addr) {
25608 + vma = find_vma(mm, addr);
25609 + if (check_heap_stack_gap(vma, addr, len, offset))
25610 + return addr;
25611 + }
25612 + }
25613 +
25614 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25615 + info.length = len;
25616 + info.low_limit = PAGE_SIZE;
25617 + info.high_limit = mm->mmap_base;
25618 + info.align_mask = filp ? get_align_mask() : 0;
25619 + info.align_offset = pgoff << PAGE_SHIFT;
25620 + info.threadstack_offset = offset;
25621 +
25622 + addr = vm_unmapped_area(&info);
25623 + if (!(addr & ~PAGE_MASK))
25624 + return addr;
25625 + VM_BUG_ON(addr != -ENOMEM);
25626 +
25627 +bottomup:
25628 + /*
25629 + * A failed mmap() very likely causes application failure,
25630 + * so fall back to the bottom-up function here. This scenario
25631 + * can happen with large stack limits and large mmap()
25632 + * allocations.
25633 + */
25634 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25635 +}
25636 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25637 index 30277e2..5664a29 100644
25638 --- a/arch/x86/kernel/sys_x86_64.c
25639 +++ b/arch/x86/kernel/sys_x86_64.c
25640 @@ -81,8 +81,8 @@ out:
25641 return error;
25642 }
25643
25644 -static void find_start_end(unsigned long flags, unsigned long *begin,
25645 - unsigned long *end)
25646 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25647 + unsigned long *begin, unsigned long *end)
25648 {
25649 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25650 unsigned long new_begin;
25651 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25652 *begin = new_begin;
25653 }
25654 } else {
25655 - *begin = current->mm->mmap_legacy_base;
25656 + *begin = mm->mmap_legacy_base;
25657 *end = TASK_SIZE;
25658 }
25659 }
25660 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25661 struct vm_area_struct *vma;
25662 struct vm_unmapped_area_info info;
25663 unsigned long begin, end;
25664 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25665
25666 if (flags & MAP_FIXED)
25667 return addr;
25668
25669 - find_start_end(flags, &begin, &end);
25670 + find_start_end(mm, flags, &begin, &end);
25671
25672 if (len > end)
25673 return -ENOMEM;
25674
25675 +#ifdef CONFIG_PAX_RANDMMAP
25676 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25677 +#endif
25678 +
25679 if (addr) {
25680 addr = PAGE_ALIGN(addr);
25681 vma = find_vma(mm, addr);
25682 - if (end - len >= addr &&
25683 - (!vma || addr + len <= vma->vm_start))
25684 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25685 return addr;
25686 }
25687
25688 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25689 info.high_limit = end;
25690 info.align_mask = filp ? get_align_mask() : 0;
25691 info.align_offset = pgoff << PAGE_SHIFT;
25692 + info.threadstack_offset = offset;
25693 return vm_unmapped_area(&info);
25694 }
25695
25696 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25697 struct mm_struct *mm = current->mm;
25698 unsigned long addr = addr0;
25699 struct vm_unmapped_area_info info;
25700 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25701
25702 /* requested length too big for entire address space */
25703 if (len > TASK_SIZE)
25704 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25705 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25706 goto bottomup;
25707
25708 +#ifdef CONFIG_PAX_RANDMMAP
25709 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25710 +#endif
25711 +
25712 /* requesting a specific address */
25713 if (addr) {
25714 addr = PAGE_ALIGN(addr);
25715 vma = find_vma(mm, addr);
25716 - if (TASK_SIZE - len >= addr &&
25717 - (!vma || addr + len <= vma->vm_start))
25718 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25719 return addr;
25720 }
25721
25722 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25723 info.high_limit = mm->mmap_base;
25724 info.align_mask = filp ? get_align_mask() : 0;
25725 info.align_offset = pgoff << PAGE_SHIFT;
25726 + info.threadstack_offset = offset;
25727 addr = vm_unmapped_area(&info);
25728 if (!(addr & ~PAGE_MASK))
25729 return addr;
25730 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25731 index addf7b5..f960685 100644
25732 --- a/arch/x86/kernel/tboot.c
25733 +++ b/arch/x86/kernel/tboot.c
25734 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25735
25736 void tboot_shutdown(u32 shutdown_type)
25737 {
25738 - void (*shutdown)(void);
25739 + void (* __noreturn shutdown)(void);
25740
25741 if (!tboot_enabled())
25742 return;
25743 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25744
25745 switch_to_tboot_pt();
25746
25747 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25748 + shutdown = (void *)tboot->shutdown_entry;
25749 shutdown();
25750
25751 /* should not reach here */
25752 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25753 return 0;
25754 }
25755
25756 -static atomic_t ap_wfs_count;
25757 +static atomic_unchecked_t ap_wfs_count;
25758
25759 static int tboot_wait_for_aps(int num_aps)
25760 {
25761 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25762 {
25763 switch (action) {
25764 case CPU_DYING:
25765 - atomic_inc(&ap_wfs_count);
25766 + atomic_inc_unchecked(&ap_wfs_count);
25767 if (num_online_cpus() == 1)
25768 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25769 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25770 return NOTIFY_BAD;
25771 break;
25772 }
25773 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25774
25775 tboot_create_trampoline();
25776
25777 - atomic_set(&ap_wfs_count, 0);
25778 + atomic_set_unchecked(&ap_wfs_count, 0);
25779 register_hotcpu_notifier(&tboot_cpu_notifier);
25780
25781 #ifdef CONFIG_DEBUG_FS
25782 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25783 index 24d3c91..d06b473 100644
25784 --- a/arch/x86/kernel/time.c
25785 +++ b/arch/x86/kernel/time.c
25786 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25787 {
25788 unsigned long pc = instruction_pointer(regs);
25789
25790 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25791 + if (!user_mode(regs) && in_lock_functions(pc)) {
25792 #ifdef CONFIG_FRAME_POINTER
25793 - return *(unsigned long *)(regs->bp + sizeof(long));
25794 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25795 #else
25796 unsigned long *sp =
25797 (unsigned long *)kernel_stack_pointer(regs);
25798 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25799 * or above a saved flags. Eflags has bits 22-31 zero,
25800 * kernel addresses don't.
25801 */
25802 +
25803 +#ifdef CONFIG_PAX_KERNEXEC
25804 + return ktla_ktva(sp[0]);
25805 +#else
25806 if (sp[0] >> 22)
25807 return sp[0];
25808 if (sp[1] >> 22)
25809 return sp[1];
25810 #endif
25811 +
25812 +#endif
25813 }
25814 return pc;
25815 }
25816 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25817 index f7fec09..9991981 100644
25818 --- a/arch/x86/kernel/tls.c
25819 +++ b/arch/x86/kernel/tls.c
25820 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25821 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25822 return -EINVAL;
25823
25824 +#ifdef CONFIG_PAX_SEGMEXEC
25825 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25826 + return -EINVAL;
25827 +#endif
25828 +
25829 set_tls_desc(p, idx, &info, 1);
25830
25831 return 0;
25832 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25833
25834 if (kbuf)
25835 info = kbuf;
25836 - else if (__copy_from_user(infobuf, ubuf, count))
25837 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25838 return -EFAULT;
25839 else
25840 info = infobuf;
25841 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25842 index 1c113db..287b42e 100644
25843 --- a/arch/x86/kernel/tracepoint.c
25844 +++ b/arch/x86/kernel/tracepoint.c
25845 @@ -9,11 +9,11 @@
25846 #include <linux/atomic.h>
25847
25848 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25849 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25850 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25851 (unsigned long) trace_idt_table };
25852
25853 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25854 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25855 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25856
25857 static int trace_irq_vector_refcount;
25858 static DEFINE_MUTEX(irq_vector_mutex);
25859 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25860 index 1b23a1c..910de0d 100644
25861 --- a/arch/x86/kernel/traps.c
25862 +++ b/arch/x86/kernel/traps.c
25863 @@ -65,7 +65,7 @@
25864 #include <asm/proto.h>
25865
25866 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25867 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25868 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25869 #else
25870 #include <asm/processor-flags.h>
25871 #include <asm/setup.h>
25872 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25873 #endif
25874
25875 /* Must be page-aligned because the real IDT is used in a fixmap. */
25876 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25877 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25878
25879 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25880 EXPORT_SYMBOL_GPL(used_vectors);
25881 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25882 }
25883
25884 static int __kprobes
25885 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25886 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25887 struct pt_regs *regs, long error_code)
25888 {
25889 #ifdef CONFIG_X86_32
25890 - if (regs->flags & X86_VM_MASK) {
25891 + if (v8086_mode(regs)) {
25892 /*
25893 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25894 * On nmi (interrupt 2), do_trap should not be called.
25895 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25896 return -1;
25897 }
25898 #endif
25899 - if (!user_mode(regs)) {
25900 + if (!user_mode_novm(regs)) {
25901 if (!fixup_exception(regs)) {
25902 tsk->thread.error_code = error_code;
25903 tsk->thread.trap_nr = trapnr;
25904 +
25905 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25906 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25907 + str = "PAX: suspicious stack segment fault";
25908 +#endif
25909 +
25910 die(str, regs, error_code);
25911 }
25912 +
25913 +#ifdef CONFIG_PAX_REFCOUNT
25914 + if (trapnr == 4)
25915 + pax_report_refcount_overflow(regs);
25916 +#endif
25917 +
25918 return 0;
25919 }
25920
25921 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25922 }
25923
25924 static void __kprobes
25925 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25926 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25927 long error_code, siginfo_t *info)
25928 {
25929 struct task_struct *tsk = current;
25930 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25931 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25932 printk_ratelimit()) {
25933 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25934 - tsk->comm, tsk->pid, str,
25935 + tsk->comm, task_pid_nr(tsk), str,
25936 regs->ip, regs->sp, error_code);
25937 print_vma_addr(" in ", regs->ip);
25938 pr_cont("\n");
25939 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25940 conditional_sti(regs);
25941
25942 #ifdef CONFIG_X86_32
25943 - if (regs->flags & X86_VM_MASK) {
25944 + if (v8086_mode(regs)) {
25945 local_irq_enable();
25946 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25947 goto exit;
25948 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25949 #endif
25950
25951 tsk = current;
25952 - if (!user_mode(regs)) {
25953 + if (!user_mode_novm(regs)) {
25954 if (fixup_exception(regs))
25955 goto exit;
25956
25957 tsk->thread.error_code = error_code;
25958 tsk->thread.trap_nr = X86_TRAP_GP;
25959 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25960 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25961 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25962 +
25963 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25964 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25965 + die("PAX: suspicious general protection fault", regs, error_code);
25966 + else
25967 +#endif
25968 +
25969 die("general protection fault", regs, error_code);
25970 + }
25971 goto exit;
25972 }
25973
25974 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25975 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25976 + struct mm_struct *mm = tsk->mm;
25977 + unsigned long limit;
25978 +
25979 + down_write(&mm->mmap_sem);
25980 + limit = mm->context.user_cs_limit;
25981 + if (limit < TASK_SIZE) {
25982 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25983 + up_write(&mm->mmap_sem);
25984 + return;
25985 + }
25986 + up_write(&mm->mmap_sem);
25987 + }
25988 +#endif
25989 +
25990 tsk->thread.error_code = error_code;
25991 tsk->thread.trap_nr = X86_TRAP_GP;
25992
25993 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25994 /* It's safe to allow irq's after DR6 has been saved */
25995 preempt_conditional_sti(regs);
25996
25997 - if (regs->flags & X86_VM_MASK) {
25998 + if (v8086_mode(regs)) {
25999 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26000 X86_TRAP_DB);
26001 preempt_conditional_cli(regs);
26002 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26003 * We already checked v86 mode above, so we can check for kernel mode
26004 * by just checking the CPL of CS.
26005 */
26006 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26007 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26008 tsk->thread.debugreg6 &= ~DR_STEP;
26009 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26010 regs->flags &= ~X86_EFLAGS_TF;
26011 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26012 return;
26013 conditional_sti(regs);
26014
26015 - if (!user_mode_vm(regs))
26016 + if (!user_mode(regs))
26017 {
26018 if (!fixup_exception(regs)) {
26019 task->thread.error_code = error_code;
26020 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26021 index 2ed8459..7cf329f 100644
26022 --- a/arch/x86/kernel/uprobes.c
26023 +++ b/arch/x86/kernel/uprobes.c
26024 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26025 int ret = NOTIFY_DONE;
26026
26027 /* We are only interested in userspace traps */
26028 - if (regs && !user_mode_vm(regs))
26029 + if (regs && !user_mode(regs))
26030 return NOTIFY_DONE;
26031
26032 switch (val) {
26033 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26034
26035 if (ncopied != rasize) {
26036 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26037 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26038 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26039
26040 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26041 }
26042 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26043 index b9242ba..50c5edd 100644
26044 --- a/arch/x86/kernel/verify_cpu.S
26045 +++ b/arch/x86/kernel/verify_cpu.S
26046 @@ -20,6 +20,7 @@
26047 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26048 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26049 * arch/x86/kernel/head_32.S: processor startup
26050 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26051 *
26052 * verify_cpu, returns the status of longmode and SSE in register %eax.
26053 * 0: Success 1: Failure
26054 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26055 index e8edcf5..27f9344 100644
26056 --- a/arch/x86/kernel/vm86_32.c
26057 +++ b/arch/x86/kernel/vm86_32.c
26058 @@ -44,6 +44,7 @@
26059 #include <linux/ptrace.h>
26060 #include <linux/audit.h>
26061 #include <linux/stddef.h>
26062 +#include <linux/grsecurity.h>
26063
26064 #include <asm/uaccess.h>
26065 #include <asm/io.h>
26066 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26067 do_exit(SIGSEGV);
26068 }
26069
26070 - tss = &per_cpu(init_tss, get_cpu());
26071 + tss = init_tss + get_cpu();
26072 current->thread.sp0 = current->thread.saved_sp0;
26073 current->thread.sysenter_cs = __KERNEL_CS;
26074 load_sp0(tss, &current->thread);
26075 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26076
26077 if (tsk->thread.saved_sp0)
26078 return -EPERM;
26079 +
26080 +#ifdef CONFIG_GRKERNSEC_VM86
26081 + if (!capable(CAP_SYS_RAWIO)) {
26082 + gr_handle_vm86();
26083 + return -EPERM;
26084 + }
26085 +#endif
26086 +
26087 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26088 offsetof(struct kernel_vm86_struct, vm86plus) -
26089 sizeof(info.regs));
26090 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26091 int tmp;
26092 struct vm86plus_struct __user *v86;
26093
26094 +#ifdef CONFIG_GRKERNSEC_VM86
26095 + if (!capable(CAP_SYS_RAWIO)) {
26096 + gr_handle_vm86();
26097 + return -EPERM;
26098 + }
26099 +#endif
26100 +
26101 tsk = current;
26102 switch (cmd) {
26103 case VM86_REQUEST_IRQ:
26104 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26105 tsk->thread.saved_fs = info->regs32->fs;
26106 tsk->thread.saved_gs = get_user_gs(info->regs32);
26107
26108 - tss = &per_cpu(init_tss, get_cpu());
26109 + tss = init_tss + get_cpu();
26110 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26111 if (cpu_has_sep)
26112 tsk->thread.sysenter_cs = 0;
26113 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26114 goto cannot_handle;
26115 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26116 goto cannot_handle;
26117 - intr_ptr = (unsigned long __user *) (i << 2);
26118 + intr_ptr = (__force unsigned long __user *) (i << 2);
26119 if (get_user(segoffs, intr_ptr))
26120 goto cannot_handle;
26121 if ((segoffs >> 16) == BIOSSEG)
26122 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26123 index 10c4f30..65408b9 100644
26124 --- a/arch/x86/kernel/vmlinux.lds.S
26125 +++ b/arch/x86/kernel/vmlinux.lds.S
26126 @@ -26,6 +26,13 @@
26127 #include <asm/page_types.h>
26128 #include <asm/cache.h>
26129 #include <asm/boot.h>
26130 +#include <asm/segment.h>
26131 +
26132 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26133 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26134 +#else
26135 +#define __KERNEL_TEXT_OFFSET 0
26136 +#endif
26137
26138 #undef i386 /* in case the preprocessor is a 32bit one */
26139
26140 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26141
26142 PHDRS {
26143 text PT_LOAD FLAGS(5); /* R_E */
26144 +#ifdef CONFIG_X86_32
26145 + module PT_LOAD FLAGS(5); /* R_E */
26146 +#endif
26147 +#ifdef CONFIG_XEN
26148 + rodata PT_LOAD FLAGS(5); /* R_E */
26149 +#else
26150 + rodata PT_LOAD FLAGS(4); /* R__ */
26151 +#endif
26152 data PT_LOAD FLAGS(6); /* RW_ */
26153 -#ifdef CONFIG_X86_64
26154 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26155 #ifdef CONFIG_SMP
26156 percpu PT_LOAD FLAGS(6); /* RW_ */
26157 #endif
26158 + text.init PT_LOAD FLAGS(5); /* R_E */
26159 + text.exit PT_LOAD FLAGS(5); /* R_E */
26160 init PT_LOAD FLAGS(7); /* RWE */
26161 -#endif
26162 note PT_NOTE FLAGS(0); /* ___ */
26163 }
26164
26165 SECTIONS
26166 {
26167 #ifdef CONFIG_X86_32
26168 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26169 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26170 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26171 #else
26172 - . = __START_KERNEL;
26173 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26174 + . = __START_KERNEL;
26175 #endif
26176
26177 /* Text and read-only data */
26178 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26179 - _text = .;
26180 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26181 /* bootstrapping code */
26182 +#ifdef CONFIG_X86_32
26183 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26184 +#else
26185 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26186 +#endif
26187 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26188 + _text = .;
26189 HEAD_TEXT
26190 . = ALIGN(8);
26191 _stext = .;
26192 @@ -104,13 +124,47 @@ SECTIONS
26193 IRQENTRY_TEXT
26194 *(.fixup)
26195 *(.gnu.warning)
26196 - /* End of text section */
26197 - _etext = .;
26198 } :text = 0x9090
26199
26200 - NOTES :text :note
26201 + . += __KERNEL_TEXT_OFFSET;
26202
26203 - EXCEPTION_TABLE(16) :text = 0x9090
26204 +#ifdef CONFIG_X86_32
26205 + . = ALIGN(PAGE_SIZE);
26206 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26207 +
26208 +#ifdef CONFIG_PAX_KERNEXEC
26209 + MODULES_EXEC_VADDR = .;
26210 + BYTE(0)
26211 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26212 + . = ALIGN(HPAGE_SIZE) - 1;
26213 + MODULES_EXEC_END = .;
26214 +#endif
26215 +
26216 + } :module
26217 +#endif
26218 +
26219 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26220 + /* End of text section */
26221 + BYTE(0)
26222 + _etext = . - __KERNEL_TEXT_OFFSET;
26223 + }
26224 +
26225 +#ifdef CONFIG_X86_32
26226 + . = ALIGN(PAGE_SIZE);
26227 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26228 + . = ALIGN(PAGE_SIZE);
26229 + *(.empty_zero_page)
26230 + *(.initial_pg_fixmap)
26231 + *(.initial_pg_pmd)
26232 + *(.initial_page_table)
26233 + *(.swapper_pg_dir)
26234 + } :rodata
26235 +#endif
26236 +
26237 + . = ALIGN(PAGE_SIZE);
26238 + NOTES :rodata :note
26239 +
26240 + EXCEPTION_TABLE(16) :rodata
26241
26242 #if defined(CONFIG_DEBUG_RODATA)
26243 /* .text should occupy whole number of pages */
26244 @@ -122,16 +176,20 @@ SECTIONS
26245
26246 /* Data */
26247 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26248 +
26249 +#ifdef CONFIG_PAX_KERNEXEC
26250 + . = ALIGN(HPAGE_SIZE);
26251 +#else
26252 + . = ALIGN(PAGE_SIZE);
26253 +#endif
26254 +
26255 /* Start of data section */
26256 _sdata = .;
26257
26258 /* init_task */
26259 INIT_TASK_DATA(THREAD_SIZE)
26260
26261 -#ifdef CONFIG_X86_32
26262 - /* 32 bit has nosave before _edata */
26263 NOSAVE_DATA
26264 -#endif
26265
26266 PAGE_ALIGNED_DATA(PAGE_SIZE)
26267
26268 @@ -172,12 +230,19 @@ SECTIONS
26269 #endif /* CONFIG_X86_64 */
26270
26271 /* Init code and data - will be freed after init */
26272 - . = ALIGN(PAGE_SIZE);
26273 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26274 + BYTE(0)
26275 +
26276 +#ifdef CONFIG_PAX_KERNEXEC
26277 + . = ALIGN(HPAGE_SIZE);
26278 +#else
26279 + . = ALIGN(PAGE_SIZE);
26280 +#endif
26281 +
26282 __init_begin = .; /* paired with __init_end */
26283 - }
26284 + } :init.begin
26285
26286 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26287 +#ifdef CONFIG_SMP
26288 /*
26289 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26290 * output PHDR, so the next output section - .init.text - should
26291 @@ -186,12 +251,27 @@ SECTIONS
26292 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26293 #endif
26294
26295 - INIT_TEXT_SECTION(PAGE_SIZE)
26296 -#ifdef CONFIG_X86_64
26297 - :init
26298 -#endif
26299 + . = ALIGN(PAGE_SIZE);
26300 + init_begin = .;
26301 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26302 + VMLINUX_SYMBOL(_sinittext) = .;
26303 + INIT_TEXT
26304 + VMLINUX_SYMBOL(_einittext) = .;
26305 + . = ALIGN(PAGE_SIZE);
26306 + } :text.init
26307
26308 - INIT_DATA_SECTION(16)
26309 + /*
26310 + * .exit.text is discard at runtime, not link time, to deal with
26311 + * references from .altinstructions and .eh_frame
26312 + */
26313 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26314 + EXIT_TEXT
26315 + . = ALIGN(16);
26316 + } :text.exit
26317 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26318 +
26319 + . = ALIGN(PAGE_SIZE);
26320 + INIT_DATA_SECTION(16) :init
26321
26322 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26323 __x86_cpu_dev_start = .;
26324 @@ -253,19 +333,12 @@ SECTIONS
26325 }
26326
26327 . = ALIGN(8);
26328 - /*
26329 - * .exit.text is discard at runtime, not link time, to deal with
26330 - * references from .altinstructions and .eh_frame
26331 - */
26332 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26333 - EXIT_TEXT
26334 - }
26335
26336 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26337 EXIT_DATA
26338 }
26339
26340 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26341 +#ifndef CONFIG_SMP
26342 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26343 #endif
26344
26345 @@ -284,16 +357,10 @@ SECTIONS
26346 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26347 __smp_locks = .;
26348 *(.smp_locks)
26349 - . = ALIGN(PAGE_SIZE);
26350 __smp_locks_end = .;
26351 + . = ALIGN(PAGE_SIZE);
26352 }
26353
26354 -#ifdef CONFIG_X86_64
26355 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26356 - NOSAVE_DATA
26357 - }
26358 -#endif
26359 -
26360 /* BSS */
26361 . = ALIGN(PAGE_SIZE);
26362 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26363 @@ -309,6 +376,7 @@ SECTIONS
26364 __brk_base = .;
26365 . += 64 * 1024; /* 64k alignment slop space */
26366 *(.brk_reservation) /* areas brk users have reserved */
26367 + . = ALIGN(HPAGE_SIZE);
26368 __brk_limit = .;
26369 }
26370
26371 @@ -335,13 +403,12 @@ SECTIONS
26372 * for the boot processor.
26373 */
26374 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26375 -INIT_PER_CPU(gdt_page);
26376 INIT_PER_CPU(irq_stack_union);
26377
26378 /*
26379 * Build-time check on the image size:
26380 */
26381 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26382 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26383 "kernel image bigger than KERNEL_IMAGE_SIZE");
26384
26385 #ifdef CONFIG_SMP
26386 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26387 index 1f96f93..d5c8f7a 100644
26388 --- a/arch/x86/kernel/vsyscall_64.c
26389 +++ b/arch/x86/kernel/vsyscall_64.c
26390 @@ -56,15 +56,13 @@
26391 DEFINE_VVAR(int, vgetcpu_mode);
26392 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26393
26394 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26395 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26396
26397 static int __init vsyscall_setup(char *str)
26398 {
26399 if (str) {
26400 if (!strcmp("emulate", str))
26401 vsyscall_mode = EMULATE;
26402 - else if (!strcmp("native", str))
26403 - vsyscall_mode = NATIVE;
26404 else if (!strcmp("none", str))
26405 vsyscall_mode = NONE;
26406 else
26407 @@ -323,8 +321,7 @@ do_ret:
26408 return true;
26409
26410 sigsegv:
26411 - force_sig(SIGSEGV, current);
26412 - return true;
26413 + do_group_exit(SIGKILL);
26414 }
26415
26416 /*
26417 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26418 extern char __vvar_page;
26419 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26420
26421 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26422 - vsyscall_mode == NATIVE
26423 - ? PAGE_KERNEL_VSYSCALL
26424 - : PAGE_KERNEL_VVAR);
26425 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26426 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26427 (unsigned long)VSYSCALL_START);
26428
26429 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26430 index b014d94..e775258 100644
26431 --- a/arch/x86/kernel/x8664_ksyms_64.c
26432 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26433 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26434 EXPORT_SYMBOL(copy_user_generic_unrolled);
26435 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26436 EXPORT_SYMBOL(__copy_user_nocache);
26437 -EXPORT_SYMBOL(_copy_from_user);
26438 -EXPORT_SYMBOL(_copy_to_user);
26439
26440 EXPORT_SYMBOL(copy_page);
26441 EXPORT_SYMBOL(clear_page);
26442 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26443 #ifndef CONFIG_PARAVIRT
26444 EXPORT_SYMBOL(native_load_gs_index);
26445 #endif
26446 +
26447 +#ifdef CONFIG_PAX_PER_CPU_PGD
26448 +EXPORT_SYMBOL(cpu_pgd);
26449 +#endif
26450 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26451 index 5f24c71..1dadf09 100644
26452 --- a/arch/x86/kernel/x86_init.c
26453 +++ b/arch/x86/kernel/x86_init.c
26454 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26455 static void default_nmi_init(void) { };
26456 static int default_i8042_detect(void) { return 1; };
26457
26458 -struct x86_platform_ops x86_platform = {
26459 +struct x86_platform_ops x86_platform __read_only = {
26460 .calibrate_tsc = native_calibrate_tsc,
26461 .get_wallclock = mach_get_cmos_time,
26462 .set_wallclock = mach_set_rtc_mmss,
26463 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26464 };
26465
26466 EXPORT_SYMBOL_GPL(x86_platform);
26467 -struct x86_msi_ops x86_msi = {
26468 +struct x86_msi_ops x86_msi __read_only = {
26469 .setup_msi_irqs = native_setup_msi_irqs,
26470 .compose_msi_msg = native_compose_msi_msg,
26471 .teardown_msi_irq = native_teardown_msi_irq,
26472 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26473 .setup_hpet_msi = default_setup_hpet_msi,
26474 };
26475
26476 -struct x86_io_apic_ops x86_io_apic_ops = {
26477 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26478 .init = native_io_apic_init_mappings,
26479 .read = native_io_apic_read,
26480 .write = native_io_apic_write,
26481 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26482 index 422fd82..c3687ca 100644
26483 --- a/arch/x86/kernel/xsave.c
26484 +++ b/arch/x86/kernel/xsave.c
26485 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26486 {
26487 int err;
26488
26489 + buf = (struct xsave_struct __user *)____m(buf);
26490 if (use_xsave())
26491 err = xsave_user(buf);
26492 else if (use_fxsr())
26493 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26494 */
26495 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26496 {
26497 + buf = (void __user *)____m(buf);
26498 if (use_xsave()) {
26499 if ((unsigned long)buf % 64 || fx_only) {
26500 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26501 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26502 index a20ecb5..d0e2194 100644
26503 --- a/arch/x86/kvm/cpuid.c
26504 +++ b/arch/x86/kvm/cpuid.c
26505 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26506 struct kvm_cpuid2 *cpuid,
26507 struct kvm_cpuid_entry2 __user *entries)
26508 {
26509 - int r;
26510 + int r, i;
26511
26512 r = -E2BIG;
26513 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26514 goto out;
26515 r = -EFAULT;
26516 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26517 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26518 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26519 goto out;
26520 + for (i = 0; i < cpuid->nent; ++i) {
26521 + struct kvm_cpuid_entry2 cpuid_entry;
26522 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26523 + goto out;
26524 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26525 + }
26526 vcpu->arch.cpuid_nent = cpuid->nent;
26527 kvm_apic_set_version(vcpu);
26528 kvm_x86_ops->cpuid_update(vcpu);
26529 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26530 struct kvm_cpuid2 *cpuid,
26531 struct kvm_cpuid_entry2 __user *entries)
26532 {
26533 - int r;
26534 + int r, i;
26535
26536 r = -E2BIG;
26537 if (cpuid->nent < vcpu->arch.cpuid_nent)
26538 goto out;
26539 r = -EFAULT;
26540 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26541 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26542 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26543 goto out;
26544 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26545 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26546 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26547 + goto out;
26548 + }
26549 return 0;
26550
26551 out:
26552 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26553 index afc1124..3e431f2 100644
26554 --- a/arch/x86/kvm/lapic.c
26555 +++ b/arch/x86/kvm/lapic.c
26556 @@ -55,7 +55,7 @@
26557 #define APIC_BUS_CYCLE_NS 1
26558
26559 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26560 -#define apic_debug(fmt, arg...)
26561 +#define apic_debug(fmt, arg...) do {} while (0)
26562
26563 #define APIC_LVT_NUM 6
26564 /* 14 is the version for Xeon and Pentium 8.4.8*/
26565 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26566 index 7769699..c8aca4a7f 100644
26567 --- a/arch/x86/kvm/paging_tmpl.h
26568 +++ b/arch/x86/kvm/paging_tmpl.h
26569 @@ -208,7 +208,7 @@ retry_walk:
26570 if (unlikely(kvm_is_error_hva(host_addr)))
26571 goto error;
26572
26573 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26574 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26575 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26576 goto error;
26577 walker->ptep_user[walker->level - 1] = ptep_user;
26578 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26579 index c0bc803..6837a50 100644
26580 --- a/arch/x86/kvm/svm.c
26581 +++ b/arch/x86/kvm/svm.c
26582 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26583 int cpu = raw_smp_processor_id();
26584
26585 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26586 +
26587 + pax_open_kernel();
26588 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26589 + pax_close_kernel();
26590 +
26591 load_TR_desc();
26592 }
26593
26594 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26595 #endif
26596 #endif
26597
26598 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26599 + __set_fs(current_thread_info()->addr_limit);
26600 +#endif
26601 +
26602 reload_tss(vcpu);
26603
26604 local_irq_disable();
26605 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26606 index 064d0be..f5f758e 100644
26607 --- a/arch/x86/kvm/vmx.c
26608 +++ b/arch/x86/kvm/vmx.c
26609 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26610 #endif
26611 }
26612
26613 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26614 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26615 {
26616 vmcs_writel(field, vmcs_readl(field) & ~mask);
26617 }
26618
26619 -static void vmcs_set_bits(unsigned long field, u32 mask)
26620 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26621 {
26622 vmcs_writel(field, vmcs_readl(field) | mask);
26623 }
26624 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26625 struct desc_struct *descs;
26626
26627 descs = (void *)gdt->address;
26628 +
26629 + pax_open_kernel();
26630 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26631 + pax_close_kernel();
26632 +
26633 load_TR_desc();
26634 }
26635
26636 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26637 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26638 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26639
26640 +#ifdef CONFIG_PAX_PER_CPU_PGD
26641 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26642 +#endif
26643 +
26644 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26645 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26646 vmx->loaded_vmcs->cpu = cpu;
26647 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26648 if (!cpu_has_vmx_flexpriority())
26649 flexpriority_enabled = 0;
26650
26651 - if (!cpu_has_vmx_tpr_shadow())
26652 - kvm_x86_ops->update_cr8_intercept = NULL;
26653 + if (!cpu_has_vmx_tpr_shadow()) {
26654 + pax_open_kernel();
26655 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26656 + pax_close_kernel();
26657 + }
26658
26659 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26660 kvm_disable_largepages();
26661 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26662 if (!cpu_has_vmx_apicv())
26663 enable_apicv = 0;
26664
26665 + pax_open_kernel();
26666 if (enable_apicv)
26667 - kvm_x86_ops->update_cr8_intercept = NULL;
26668 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26669 else {
26670 - kvm_x86_ops->hwapic_irr_update = NULL;
26671 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26672 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26673 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26674 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26675 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26676 }
26677 + pax_close_kernel();
26678
26679 if (nested)
26680 nested_vmx_setup_ctls_msrs();
26681 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26682
26683 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26684 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26685 +
26686 +#ifndef CONFIG_PAX_PER_CPU_PGD
26687 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26688 +#endif
26689
26690 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26691 #ifdef CONFIG_X86_64
26692 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26693 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26694 vmx->host_idt_base = dt.address;
26695
26696 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26697 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26698
26699 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26700 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26701 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26702 "jmp 2f \n\t"
26703 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26704 "2: "
26705 +
26706 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26707 + "ljmp %[cs],$3f\n\t"
26708 + "3: "
26709 +#endif
26710 +
26711 /* Save guest registers, load host registers, keep flags */
26712 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26713 "pop %0 \n\t"
26714 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26715 #endif
26716 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26717 [wordsize]"i"(sizeof(ulong))
26718 +
26719 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26720 + ,[cs]"i"(__KERNEL_CS)
26721 +#endif
26722 +
26723 : "cc", "memory"
26724 #ifdef CONFIG_X86_64
26725 , "rax", "rbx", "rdi", "rsi"
26726 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26727 if (debugctlmsr)
26728 update_debugctlmsr(debugctlmsr);
26729
26730 -#ifndef CONFIG_X86_64
26731 +#ifdef CONFIG_X86_32
26732 /*
26733 * The sysexit path does not restore ds/es, so we must set them to
26734 * a reasonable value ourselves.
26735 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26736 * may be executed in interrupt context, which saves and restore segments
26737 * around it, nullifying its effect.
26738 */
26739 - loadsegment(ds, __USER_DS);
26740 - loadsegment(es, __USER_DS);
26741 + loadsegment(ds, __KERNEL_DS);
26742 + loadsegment(es, __KERNEL_DS);
26743 + loadsegment(ss, __KERNEL_DS);
26744 +
26745 +#ifdef CONFIG_PAX_KERNEXEC
26746 + loadsegment(fs, __KERNEL_PERCPU);
26747 +#endif
26748 +
26749 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26750 + __set_fs(current_thread_info()->addr_limit);
26751 +#endif
26752 +
26753 #endif
26754
26755 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26756 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26757 index d21bce5..fdae9f1 100644
26758 --- a/arch/x86/kvm/x86.c
26759 +++ b/arch/x86/kvm/x86.c
26760 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26761 {
26762 struct kvm *kvm = vcpu->kvm;
26763 int lm = is_long_mode(vcpu);
26764 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26765 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26766 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26767 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26768 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26769 : kvm->arch.xen_hvm_config.blob_size_32;
26770 u32 page_num = data & ~PAGE_MASK;
26771 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26772 if (n < msr_list.nmsrs)
26773 goto out;
26774 r = -EFAULT;
26775 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26776 + goto out;
26777 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26778 num_msrs_to_save * sizeof(u32)))
26779 goto out;
26780 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26781 };
26782 #endif
26783
26784 -int kvm_arch_init(void *opaque)
26785 +int kvm_arch_init(const void *opaque)
26786 {
26787 int r;
26788 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26789 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26790 index 6a22c19..1763f04 100644
26791 --- a/arch/x86/lguest/boot.c
26792 +++ b/arch/x86/lguest/boot.c
26793 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26794 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26795 * Launcher to reboot us.
26796 */
26797 -static void lguest_restart(char *reason)
26798 +static __noreturn void lguest_restart(char *reason)
26799 {
26800 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26801 + BUG();
26802 }
26803
26804 /*G:050
26805 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26806 index 00933d5..3a64af9 100644
26807 --- a/arch/x86/lib/atomic64_386_32.S
26808 +++ b/arch/x86/lib/atomic64_386_32.S
26809 @@ -48,6 +48,10 @@ BEGIN(read)
26810 movl (v), %eax
26811 movl 4(v), %edx
26812 RET_ENDP
26813 +BEGIN(read_unchecked)
26814 + movl (v), %eax
26815 + movl 4(v), %edx
26816 +RET_ENDP
26817 #undef v
26818
26819 #define v %esi
26820 @@ -55,6 +59,10 @@ BEGIN(set)
26821 movl %ebx, (v)
26822 movl %ecx, 4(v)
26823 RET_ENDP
26824 +BEGIN(set_unchecked)
26825 + movl %ebx, (v)
26826 + movl %ecx, 4(v)
26827 +RET_ENDP
26828 #undef v
26829
26830 #define v %esi
26831 @@ -70,6 +78,20 @@ RET_ENDP
26832 BEGIN(add)
26833 addl %eax, (v)
26834 adcl %edx, 4(v)
26835 +
26836 +#ifdef CONFIG_PAX_REFCOUNT
26837 + jno 0f
26838 + subl %eax, (v)
26839 + sbbl %edx, 4(v)
26840 + int $4
26841 +0:
26842 + _ASM_EXTABLE(0b, 0b)
26843 +#endif
26844 +
26845 +RET_ENDP
26846 +BEGIN(add_unchecked)
26847 + addl %eax, (v)
26848 + adcl %edx, 4(v)
26849 RET_ENDP
26850 #undef v
26851
26852 @@ -77,6 +99,24 @@ RET_ENDP
26853 BEGIN(add_return)
26854 addl (v), %eax
26855 adcl 4(v), %edx
26856 +
26857 +#ifdef CONFIG_PAX_REFCOUNT
26858 + into
26859 +1234:
26860 + _ASM_EXTABLE(1234b, 2f)
26861 +#endif
26862 +
26863 + movl %eax, (v)
26864 + movl %edx, 4(v)
26865 +
26866 +#ifdef CONFIG_PAX_REFCOUNT
26867 +2:
26868 +#endif
26869 +
26870 +RET_ENDP
26871 +BEGIN(add_return_unchecked)
26872 + addl (v), %eax
26873 + adcl 4(v), %edx
26874 movl %eax, (v)
26875 movl %edx, 4(v)
26876 RET_ENDP
26877 @@ -86,6 +126,20 @@ RET_ENDP
26878 BEGIN(sub)
26879 subl %eax, (v)
26880 sbbl %edx, 4(v)
26881 +
26882 +#ifdef CONFIG_PAX_REFCOUNT
26883 + jno 0f
26884 + addl %eax, (v)
26885 + adcl %edx, 4(v)
26886 + int $4
26887 +0:
26888 + _ASM_EXTABLE(0b, 0b)
26889 +#endif
26890 +
26891 +RET_ENDP
26892 +BEGIN(sub_unchecked)
26893 + subl %eax, (v)
26894 + sbbl %edx, 4(v)
26895 RET_ENDP
26896 #undef v
26897
26898 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26899 sbbl $0, %edx
26900 addl (v), %eax
26901 adcl 4(v), %edx
26902 +
26903 +#ifdef CONFIG_PAX_REFCOUNT
26904 + into
26905 +1234:
26906 + _ASM_EXTABLE(1234b, 2f)
26907 +#endif
26908 +
26909 + movl %eax, (v)
26910 + movl %edx, 4(v)
26911 +
26912 +#ifdef CONFIG_PAX_REFCOUNT
26913 +2:
26914 +#endif
26915 +
26916 +RET_ENDP
26917 +BEGIN(sub_return_unchecked)
26918 + negl %edx
26919 + negl %eax
26920 + sbbl $0, %edx
26921 + addl (v), %eax
26922 + adcl 4(v), %edx
26923 movl %eax, (v)
26924 movl %edx, 4(v)
26925 RET_ENDP
26926 @@ -105,6 +180,20 @@ RET_ENDP
26927 BEGIN(inc)
26928 addl $1, (v)
26929 adcl $0, 4(v)
26930 +
26931 +#ifdef CONFIG_PAX_REFCOUNT
26932 + jno 0f
26933 + subl $1, (v)
26934 + sbbl $0, 4(v)
26935 + int $4
26936 +0:
26937 + _ASM_EXTABLE(0b, 0b)
26938 +#endif
26939 +
26940 +RET_ENDP
26941 +BEGIN(inc_unchecked)
26942 + addl $1, (v)
26943 + adcl $0, 4(v)
26944 RET_ENDP
26945 #undef v
26946
26947 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26948 movl 4(v), %edx
26949 addl $1, %eax
26950 adcl $0, %edx
26951 +
26952 +#ifdef CONFIG_PAX_REFCOUNT
26953 + into
26954 +1234:
26955 + _ASM_EXTABLE(1234b, 2f)
26956 +#endif
26957 +
26958 + movl %eax, (v)
26959 + movl %edx, 4(v)
26960 +
26961 +#ifdef CONFIG_PAX_REFCOUNT
26962 +2:
26963 +#endif
26964 +
26965 +RET_ENDP
26966 +BEGIN(inc_return_unchecked)
26967 + movl (v), %eax
26968 + movl 4(v), %edx
26969 + addl $1, %eax
26970 + adcl $0, %edx
26971 movl %eax, (v)
26972 movl %edx, 4(v)
26973 RET_ENDP
26974 @@ -123,6 +232,20 @@ RET_ENDP
26975 BEGIN(dec)
26976 subl $1, (v)
26977 sbbl $0, 4(v)
26978 +
26979 +#ifdef CONFIG_PAX_REFCOUNT
26980 + jno 0f
26981 + addl $1, (v)
26982 + adcl $0, 4(v)
26983 + int $4
26984 +0:
26985 + _ASM_EXTABLE(0b, 0b)
26986 +#endif
26987 +
26988 +RET_ENDP
26989 +BEGIN(dec_unchecked)
26990 + subl $1, (v)
26991 + sbbl $0, 4(v)
26992 RET_ENDP
26993 #undef v
26994
26995 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26996 movl 4(v), %edx
26997 subl $1, %eax
26998 sbbl $0, %edx
26999 +
27000 +#ifdef CONFIG_PAX_REFCOUNT
27001 + into
27002 +1234:
27003 + _ASM_EXTABLE(1234b, 2f)
27004 +#endif
27005 +
27006 + movl %eax, (v)
27007 + movl %edx, 4(v)
27008 +
27009 +#ifdef CONFIG_PAX_REFCOUNT
27010 +2:
27011 +#endif
27012 +
27013 +RET_ENDP
27014 +BEGIN(dec_return_unchecked)
27015 + movl (v), %eax
27016 + movl 4(v), %edx
27017 + subl $1, %eax
27018 + sbbl $0, %edx
27019 movl %eax, (v)
27020 movl %edx, 4(v)
27021 RET_ENDP
27022 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27023 adcl %edx, %edi
27024 addl (v), %eax
27025 adcl 4(v), %edx
27026 +
27027 +#ifdef CONFIG_PAX_REFCOUNT
27028 + into
27029 +1234:
27030 + _ASM_EXTABLE(1234b, 2f)
27031 +#endif
27032 +
27033 cmpl %eax, %ecx
27034 je 3f
27035 1:
27036 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27037 1:
27038 addl $1, %eax
27039 adcl $0, %edx
27040 +
27041 +#ifdef CONFIG_PAX_REFCOUNT
27042 + into
27043 +1234:
27044 + _ASM_EXTABLE(1234b, 2f)
27045 +#endif
27046 +
27047 movl %eax, (v)
27048 movl %edx, 4(v)
27049 movl $1, %eax
27050 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27051 movl 4(v), %edx
27052 subl $1, %eax
27053 sbbl $0, %edx
27054 +
27055 +#ifdef CONFIG_PAX_REFCOUNT
27056 + into
27057 +1234:
27058 + _ASM_EXTABLE(1234b, 1f)
27059 +#endif
27060 +
27061 js 1f
27062 movl %eax, (v)
27063 movl %edx, 4(v)
27064 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27065 index f5cc9eb..51fa319 100644
27066 --- a/arch/x86/lib/atomic64_cx8_32.S
27067 +++ b/arch/x86/lib/atomic64_cx8_32.S
27068 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27069 CFI_STARTPROC
27070
27071 read64 %ecx
27072 + pax_force_retaddr
27073 ret
27074 CFI_ENDPROC
27075 ENDPROC(atomic64_read_cx8)
27076
27077 +ENTRY(atomic64_read_unchecked_cx8)
27078 + CFI_STARTPROC
27079 +
27080 + read64 %ecx
27081 + pax_force_retaddr
27082 + ret
27083 + CFI_ENDPROC
27084 +ENDPROC(atomic64_read_unchecked_cx8)
27085 +
27086 ENTRY(atomic64_set_cx8)
27087 CFI_STARTPROC
27088
27089 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27090 cmpxchg8b (%esi)
27091 jne 1b
27092
27093 + pax_force_retaddr
27094 ret
27095 CFI_ENDPROC
27096 ENDPROC(atomic64_set_cx8)
27097
27098 +ENTRY(atomic64_set_unchecked_cx8)
27099 + CFI_STARTPROC
27100 +
27101 +1:
27102 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27103 + * are atomic on 586 and newer */
27104 + cmpxchg8b (%esi)
27105 + jne 1b
27106 +
27107 + pax_force_retaddr
27108 + ret
27109 + CFI_ENDPROC
27110 +ENDPROC(atomic64_set_unchecked_cx8)
27111 +
27112 ENTRY(atomic64_xchg_cx8)
27113 CFI_STARTPROC
27114
27115 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27116 cmpxchg8b (%esi)
27117 jne 1b
27118
27119 + pax_force_retaddr
27120 ret
27121 CFI_ENDPROC
27122 ENDPROC(atomic64_xchg_cx8)
27123
27124 -.macro addsub_return func ins insc
27125 -ENTRY(atomic64_\func\()_return_cx8)
27126 +.macro addsub_return func ins insc unchecked=""
27127 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27128 CFI_STARTPROC
27129 SAVE ebp
27130 SAVE ebx
27131 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27132 movl %edx, %ecx
27133 \ins\()l %esi, %ebx
27134 \insc\()l %edi, %ecx
27135 +
27136 +.ifb \unchecked
27137 +#ifdef CONFIG_PAX_REFCOUNT
27138 + into
27139 +2:
27140 + _ASM_EXTABLE(2b, 3f)
27141 +#endif
27142 +.endif
27143 +
27144 LOCK_PREFIX
27145 cmpxchg8b (%ebp)
27146 jne 1b
27147 -
27148 -10:
27149 movl %ebx, %eax
27150 movl %ecx, %edx
27151 +
27152 +.ifb \unchecked
27153 +#ifdef CONFIG_PAX_REFCOUNT
27154 +3:
27155 +#endif
27156 +.endif
27157 +
27158 RESTORE edi
27159 RESTORE esi
27160 RESTORE ebx
27161 RESTORE ebp
27162 + pax_force_retaddr
27163 ret
27164 CFI_ENDPROC
27165 -ENDPROC(atomic64_\func\()_return_cx8)
27166 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27167 .endm
27168
27169 addsub_return add add adc
27170 addsub_return sub sub sbb
27171 +addsub_return add add adc _unchecked
27172 +addsub_return sub sub sbb _unchecked
27173
27174 -.macro incdec_return func ins insc
27175 -ENTRY(atomic64_\func\()_return_cx8)
27176 +.macro incdec_return func ins insc unchecked=""
27177 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27178 CFI_STARTPROC
27179 SAVE ebx
27180
27181 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27182 movl %edx, %ecx
27183 \ins\()l $1, %ebx
27184 \insc\()l $0, %ecx
27185 +
27186 +.ifb \unchecked
27187 +#ifdef CONFIG_PAX_REFCOUNT
27188 + into
27189 +2:
27190 + _ASM_EXTABLE(2b, 3f)
27191 +#endif
27192 +.endif
27193 +
27194 LOCK_PREFIX
27195 cmpxchg8b (%esi)
27196 jne 1b
27197
27198 -10:
27199 movl %ebx, %eax
27200 movl %ecx, %edx
27201 +
27202 +.ifb \unchecked
27203 +#ifdef CONFIG_PAX_REFCOUNT
27204 +3:
27205 +#endif
27206 +.endif
27207 +
27208 RESTORE ebx
27209 + pax_force_retaddr
27210 ret
27211 CFI_ENDPROC
27212 -ENDPROC(atomic64_\func\()_return_cx8)
27213 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27214 .endm
27215
27216 incdec_return inc add adc
27217 incdec_return dec sub sbb
27218 +incdec_return inc add adc _unchecked
27219 +incdec_return dec sub sbb _unchecked
27220
27221 ENTRY(atomic64_dec_if_positive_cx8)
27222 CFI_STARTPROC
27223 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27224 movl %edx, %ecx
27225 subl $1, %ebx
27226 sbb $0, %ecx
27227 +
27228 +#ifdef CONFIG_PAX_REFCOUNT
27229 + into
27230 +1234:
27231 + _ASM_EXTABLE(1234b, 2f)
27232 +#endif
27233 +
27234 js 2f
27235 LOCK_PREFIX
27236 cmpxchg8b (%esi)
27237 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27238 movl %ebx, %eax
27239 movl %ecx, %edx
27240 RESTORE ebx
27241 + pax_force_retaddr
27242 ret
27243 CFI_ENDPROC
27244 ENDPROC(atomic64_dec_if_positive_cx8)
27245 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27246 movl %edx, %ecx
27247 addl %ebp, %ebx
27248 adcl %edi, %ecx
27249 +
27250 +#ifdef CONFIG_PAX_REFCOUNT
27251 + into
27252 +1234:
27253 + _ASM_EXTABLE(1234b, 3f)
27254 +#endif
27255 +
27256 LOCK_PREFIX
27257 cmpxchg8b (%esi)
27258 jne 1b
27259 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27260 CFI_ADJUST_CFA_OFFSET -8
27261 RESTORE ebx
27262 RESTORE ebp
27263 + pax_force_retaddr
27264 ret
27265 4:
27266 cmpl %edx, 4(%esp)
27267 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27268 xorl %ecx, %ecx
27269 addl $1, %ebx
27270 adcl %edx, %ecx
27271 +
27272 +#ifdef CONFIG_PAX_REFCOUNT
27273 + into
27274 +1234:
27275 + _ASM_EXTABLE(1234b, 3f)
27276 +#endif
27277 +
27278 LOCK_PREFIX
27279 cmpxchg8b (%esi)
27280 jne 1b
27281 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27282 movl $1, %eax
27283 3:
27284 RESTORE ebx
27285 + pax_force_retaddr
27286 ret
27287 CFI_ENDPROC
27288 ENDPROC(atomic64_inc_not_zero_cx8)
27289 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27290 index e78b8ee..7e173a8 100644
27291 --- a/arch/x86/lib/checksum_32.S
27292 +++ b/arch/x86/lib/checksum_32.S
27293 @@ -29,7 +29,8 @@
27294 #include <asm/dwarf2.h>
27295 #include <asm/errno.h>
27296 #include <asm/asm.h>
27297 -
27298 +#include <asm/segment.h>
27299 +
27300 /*
27301 * computes a partial checksum, e.g. for TCP/UDP fragments
27302 */
27303 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27304
27305 #define ARGBASE 16
27306 #define FP 12
27307 -
27308 -ENTRY(csum_partial_copy_generic)
27309 +
27310 +ENTRY(csum_partial_copy_generic_to_user)
27311 CFI_STARTPROC
27312 +
27313 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27314 + pushl_cfi %gs
27315 + popl_cfi %es
27316 + jmp csum_partial_copy_generic
27317 +#endif
27318 +
27319 +ENTRY(csum_partial_copy_generic_from_user)
27320 +
27321 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27322 + pushl_cfi %gs
27323 + popl_cfi %ds
27324 +#endif
27325 +
27326 +ENTRY(csum_partial_copy_generic)
27327 subl $4,%esp
27328 CFI_ADJUST_CFA_OFFSET 4
27329 pushl_cfi %edi
27330 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27331 jmp 4f
27332 SRC(1: movw (%esi), %bx )
27333 addl $2, %esi
27334 -DST( movw %bx, (%edi) )
27335 +DST( movw %bx, %es:(%edi) )
27336 addl $2, %edi
27337 addw %bx, %ax
27338 adcl $0, %eax
27339 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27340 SRC(1: movl (%esi), %ebx )
27341 SRC( movl 4(%esi), %edx )
27342 adcl %ebx, %eax
27343 -DST( movl %ebx, (%edi) )
27344 +DST( movl %ebx, %es:(%edi) )
27345 adcl %edx, %eax
27346 -DST( movl %edx, 4(%edi) )
27347 +DST( movl %edx, %es:4(%edi) )
27348
27349 SRC( movl 8(%esi), %ebx )
27350 SRC( movl 12(%esi), %edx )
27351 adcl %ebx, %eax
27352 -DST( movl %ebx, 8(%edi) )
27353 +DST( movl %ebx, %es:8(%edi) )
27354 adcl %edx, %eax
27355 -DST( movl %edx, 12(%edi) )
27356 +DST( movl %edx, %es:12(%edi) )
27357
27358 SRC( movl 16(%esi), %ebx )
27359 SRC( movl 20(%esi), %edx )
27360 adcl %ebx, %eax
27361 -DST( movl %ebx, 16(%edi) )
27362 +DST( movl %ebx, %es:16(%edi) )
27363 adcl %edx, %eax
27364 -DST( movl %edx, 20(%edi) )
27365 +DST( movl %edx, %es:20(%edi) )
27366
27367 SRC( movl 24(%esi), %ebx )
27368 SRC( movl 28(%esi), %edx )
27369 adcl %ebx, %eax
27370 -DST( movl %ebx, 24(%edi) )
27371 +DST( movl %ebx, %es:24(%edi) )
27372 adcl %edx, %eax
27373 -DST( movl %edx, 28(%edi) )
27374 +DST( movl %edx, %es:28(%edi) )
27375
27376 lea 32(%esi), %esi
27377 lea 32(%edi), %edi
27378 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27379 shrl $2, %edx # This clears CF
27380 SRC(3: movl (%esi), %ebx )
27381 adcl %ebx, %eax
27382 -DST( movl %ebx, (%edi) )
27383 +DST( movl %ebx, %es:(%edi) )
27384 lea 4(%esi), %esi
27385 lea 4(%edi), %edi
27386 dec %edx
27387 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27388 jb 5f
27389 SRC( movw (%esi), %cx )
27390 leal 2(%esi), %esi
27391 -DST( movw %cx, (%edi) )
27392 +DST( movw %cx, %es:(%edi) )
27393 leal 2(%edi), %edi
27394 je 6f
27395 shll $16,%ecx
27396 SRC(5: movb (%esi), %cl )
27397 -DST( movb %cl, (%edi) )
27398 +DST( movb %cl, %es:(%edi) )
27399 6: addl %ecx, %eax
27400 adcl $0, %eax
27401 7:
27402 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27403
27404 6001:
27405 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27406 - movl $-EFAULT, (%ebx)
27407 + movl $-EFAULT, %ss:(%ebx)
27408
27409 # zero the complete destination - computing the rest
27410 # is too much work
27411 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27412
27413 6002:
27414 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27415 - movl $-EFAULT,(%ebx)
27416 + movl $-EFAULT,%ss:(%ebx)
27417 jmp 5000b
27418
27419 .previous
27420
27421 + pushl_cfi %ss
27422 + popl_cfi %ds
27423 + pushl_cfi %ss
27424 + popl_cfi %es
27425 popl_cfi %ebx
27426 CFI_RESTORE ebx
27427 popl_cfi %esi
27428 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27429 popl_cfi %ecx # equivalent to addl $4,%esp
27430 ret
27431 CFI_ENDPROC
27432 -ENDPROC(csum_partial_copy_generic)
27433 +ENDPROC(csum_partial_copy_generic_to_user)
27434
27435 #else
27436
27437 /* Version for PentiumII/PPro */
27438
27439 #define ROUND1(x) \
27440 + nop; nop; nop; \
27441 SRC(movl x(%esi), %ebx ) ; \
27442 addl %ebx, %eax ; \
27443 - DST(movl %ebx, x(%edi) ) ;
27444 + DST(movl %ebx, %es:x(%edi)) ;
27445
27446 #define ROUND(x) \
27447 + nop; nop; nop; \
27448 SRC(movl x(%esi), %ebx ) ; \
27449 adcl %ebx, %eax ; \
27450 - DST(movl %ebx, x(%edi) ) ;
27451 + DST(movl %ebx, %es:x(%edi)) ;
27452
27453 #define ARGBASE 12
27454 -
27455 -ENTRY(csum_partial_copy_generic)
27456 +
27457 +ENTRY(csum_partial_copy_generic_to_user)
27458 CFI_STARTPROC
27459 +
27460 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27461 + pushl_cfi %gs
27462 + popl_cfi %es
27463 + jmp csum_partial_copy_generic
27464 +#endif
27465 +
27466 +ENTRY(csum_partial_copy_generic_from_user)
27467 +
27468 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27469 + pushl_cfi %gs
27470 + popl_cfi %ds
27471 +#endif
27472 +
27473 +ENTRY(csum_partial_copy_generic)
27474 pushl_cfi %ebx
27475 CFI_REL_OFFSET ebx, 0
27476 pushl_cfi %edi
27477 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27478 subl %ebx, %edi
27479 lea -1(%esi),%edx
27480 andl $-32,%edx
27481 - lea 3f(%ebx,%ebx), %ebx
27482 + lea 3f(%ebx,%ebx,2), %ebx
27483 testl %esi, %esi
27484 jmp *%ebx
27485 1: addl $64,%esi
27486 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27487 jb 5f
27488 SRC( movw (%esi), %dx )
27489 leal 2(%esi), %esi
27490 -DST( movw %dx, (%edi) )
27491 +DST( movw %dx, %es:(%edi) )
27492 leal 2(%edi), %edi
27493 je 6f
27494 shll $16,%edx
27495 5:
27496 SRC( movb (%esi), %dl )
27497 -DST( movb %dl, (%edi) )
27498 +DST( movb %dl, %es:(%edi) )
27499 6: addl %edx, %eax
27500 adcl $0, %eax
27501 7:
27502 .section .fixup, "ax"
27503 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27504 - movl $-EFAULT, (%ebx)
27505 + movl $-EFAULT, %ss:(%ebx)
27506 # zero the complete destination (computing the rest is too much work)
27507 movl ARGBASE+8(%esp),%edi # dst
27508 movl ARGBASE+12(%esp),%ecx # len
27509 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27510 rep; stosb
27511 jmp 7b
27512 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27513 - movl $-EFAULT, (%ebx)
27514 + movl $-EFAULT, %ss:(%ebx)
27515 jmp 7b
27516 .previous
27517
27518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27519 + pushl_cfi %ss
27520 + popl_cfi %ds
27521 + pushl_cfi %ss
27522 + popl_cfi %es
27523 +#endif
27524 +
27525 popl_cfi %esi
27526 CFI_RESTORE esi
27527 popl_cfi %edi
27528 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27529 CFI_RESTORE ebx
27530 ret
27531 CFI_ENDPROC
27532 -ENDPROC(csum_partial_copy_generic)
27533 +ENDPROC(csum_partial_copy_generic_to_user)
27534
27535 #undef ROUND
27536 #undef ROUND1
27537 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27538 index f2145cf..cea889d 100644
27539 --- a/arch/x86/lib/clear_page_64.S
27540 +++ b/arch/x86/lib/clear_page_64.S
27541 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27542 movl $4096/8,%ecx
27543 xorl %eax,%eax
27544 rep stosq
27545 + pax_force_retaddr
27546 ret
27547 CFI_ENDPROC
27548 ENDPROC(clear_page_c)
27549 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27550 movl $4096,%ecx
27551 xorl %eax,%eax
27552 rep stosb
27553 + pax_force_retaddr
27554 ret
27555 CFI_ENDPROC
27556 ENDPROC(clear_page_c_e)
27557 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27558 leaq 64(%rdi),%rdi
27559 jnz .Lloop
27560 nop
27561 + pax_force_retaddr
27562 ret
27563 CFI_ENDPROC
27564 .Lclear_page_end:
27565 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27566
27567 #include <asm/cpufeature.h>
27568
27569 - .section .altinstr_replacement,"ax"
27570 + .section .altinstr_replacement,"a"
27571 1: .byte 0xeb /* jmp <disp8> */
27572 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27573 2: .byte 0xeb /* jmp <disp8> */
27574 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27575 index 1e572c5..2a162cd 100644
27576 --- a/arch/x86/lib/cmpxchg16b_emu.S
27577 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27578 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27579
27580 popf
27581 mov $1, %al
27582 + pax_force_retaddr
27583 ret
27584
27585 not_same:
27586 popf
27587 xor %al,%al
27588 + pax_force_retaddr
27589 ret
27590
27591 CFI_ENDPROC
27592 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27593 index 176cca6..1166c50 100644
27594 --- a/arch/x86/lib/copy_page_64.S
27595 +++ b/arch/x86/lib/copy_page_64.S
27596 @@ -9,6 +9,7 @@ copy_page_rep:
27597 CFI_STARTPROC
27598 movl $4096/8, %ecx
27599 rep movsq
27600 + pax_force_retaddr
27601 ret
27602 CFI_ENDPROC
27603 ENDPROC(copy_page_rep)
27604 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27605
27606 ENTRY(copy_page)
27607 CFI_STARTPROC
27608 - subq $2*8, %rsp
27609 - CFI_ADJUST_CFA_OFFSET 2*8
27610 + subq $3*8, %rsp
27611 + CFI_ADJUST_CFA_OFFSET 3*8
27612 movq %rbx, (%rsp)
27613 CFI_REL_OFFSET rbx, 0
27614 movq %r12, 1*8(%rsp)
27615 CFI_REL_OFFSET r12, 1*8
27616 + movq %r13, 2*8(%rsp)
27617 + CFI_REL_OFFSET r13, 2*8
27618
27619 movl $(4096/64)-5, %ecx
27620 .p2align 4
27621 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27622 movq 0x8*2(%rsi), %rdx
27623 movq 0x8*3(%rsi), %r8
27624 movq 0x8*4(%rsi), %r9
27625 - movq 0x8*5(%rsi), %r10
27626 + movq 0x8*5(%rsi), %r13
27627 movq 0x8*6(%rsi), %r11
27628 movq 0x8*7(%rsi), %r12
27629
27630 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27631 movq %rdx, 0x8*2(%rdi)
27632 movq %r8, 0x8*3(%rdi)
27633 movq %r9, 0x8*4(%rdi)
27634 - movq %r10, 0x8*5(%rdi)
27635 + movq %r13, 0x8*5(%rdi)
27636 movq %r11, 0x8*6(%rdi)
27637 movq %r12, 0x8*7(%rdi)
27638
27639 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27640 movq 0x8*2(%rsi), %rdx
27641 movq 0x8*3(%rsi), %r8
27642 movq 0x8*4(%rsi), %r9
27643 - movq 0x8*5(%rsi), %r10
27644 + movq 0x8*5(%rsi), %r13
27645 movq 0x8*6(%rsi), %r11
27646 movq 0x8*7(%rsi), %r12
27647
27648 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27649 movq %rdx, 0x8*2(%rdi)
27650 movq %r8, 0x8*3(%rdi)
27651 movq %r9, 0x8*4(%rdi)
27652 - movq %r10, 0x8*5(%rdi)
27653 + movq %r13, 0x8*5(%rdi)
27654 movq %r11, 0x8*6(%rdi)
27655 movq %r12, 0x8*7(%rdi)
27656
27657 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27658 CFI_RESTORE rbx
27659 movq 1*8(%rsp), %r12
27660 CFI_RESTORE r12
27661 - addq $2*8, %rsp
27662 - CFI_ADJUST_CFA_OFFSET -2*8
27663 + movq 2*8(%rsp), %r13
27664 + CFI_RESTORE r13
27665 + addq $3*8, %rsp
27666 + CFI_ADJUST_CFA_OFFSET -3*8
27667 + pax_force_retaddr
27668 ret
27669 .Lcopy_page_end:
27670 CFI_ENDPROC
27671 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27672
27673 #include <asm/cpufeature.h>
27674
27675 - .section .altinstr_replacement,"ax"
27676 + .section .altinstr_replacement,"a"
27677 1: .byte 0xeb /* jmp <disp8> */
27678 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27679 2:
27680 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27681 index a30ca15..6b3f4e1 100644
27682 --- a/arch/x86/lib/copy_user_64.S
27683 +++ b/arch/x86/lib/copy_user_64.S
27684 @@ -18,31 +18,7 @@
27685 #include <asm/alternative-asm.h>
27686 #include <asm/asm.h>
27687 #include <asm/smap.h>
27688 -
27689 -/*
27690 - * By placing feature2 after feature1 in altinstructions section, we logically
27691 - * implement:
27692 - * If CPU has feature2, jmp to alt2 is used
27693 - * else if CPU has feature1, jmp to alt1 is used
27694 - * else jmp to orig is used.
27695 - */
27696 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27697 -0:
27698 - .byte 0xe9 /* 32bit jump */
27699 - .long \orig-1f /* by default jump to orig */
27700 -1:
27701 - .section .altinstr_replacement,"ax"
27702 -2: .byte 0xe9 /* near jump with 32bit immediate */
27703 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27704 -3: .byte 0xe9 /* near jump with 32bit immediate */
27705 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27706 - .previous
27707 -
27708 - .section .altinstructions,"a"
27709 - altinstruction_entry 0b,2b,\feature1,5,5
27710 - altinstruction_entry 0b,3b,\feature2,5,5
27711 - .previous
27712 - .endm
27713 +#include <asm/pgtable.h>
27714
27715 .macro ALIGN_DESTINATION
27716 #ifdef FIX_ALIGNMENT
27717 @@ -70,52 +46,6 @@
27718 #endif
27719 .endm
27720
27721 -/* Standard copy_to_user with segment limit checking */
27722 -ENTRY(_copy_to_user)
27723 - CFI_STARTPROC
27724 - GET_THREAD_INFO(%rax)
27725 - movq %rdi,%rcx
27726 - addq %rdx,%rcx
27727 - jc bad_to_user
27728 - cmpq TI_addr_limit(%rax),%rcx
27729 - ja bad_to_user
27730 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27731 - copy_user_generic_unrolled,copy_user_generic_string, \
27732 - copy_user_enhanced_fast_string
27733 - CFI_ENDPROC
27734 -ENDPROC(_copy_to_user)
27735 -
27736 -/* Standard copy_from_user with segment limit checking */
27737 -ENTRY(_copy_from_user)
27738 - CFI_STARTPROC
27739 - GET_THREAD_INFO(%rax)
27740 - movq %rsi,%rcx
27741 - addq %rdx,%rcx
27742 - jc bad_from_user
27743 - cmpq TI_addr_limit(%rax),%rcx
27744 - ja bad_from_user
27745 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27746 - copy_user_generic_unrolled,copy_user_generic_string, \
27747 - copy_user_enhanced_fast_string
27748 - CFI_ENDPROC
27749 -ENDPROC(_copy_from_user)
27750 -
27751 - .section .fixup,"ax"
27752 - /* must zero dest */
27753 -ENTRY(bad_from_user)
27754 -bad_from_user:
27755 - CFI_STARTPROC
27756 - movl %edx,%ecx
27757 - xorl %eax,%eax
27758 - rep
27759 - stosb
27760 -bad_to_user:
27761 - movl %edx,%eax
27762 - ret
27763 - CFI_ENDPROC
27764 -ENDPROC(bad_from_user)
27765 - .previous
27766 -
27767 /*
27768 * copy_user_generic_unrolled - memory copy with exception handling.
27769 * This version is for CPUs like P4 that don't have efficient micro
27770 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27771 */
27772 ENTRY(copy_user_generic_unrolled)
27773 CFI_STARTPROC
27774 + ASM_PAX_OPEN_USERLAND
27775 ASM_STAC
27776 cmpl $8,%edx
27777 jb 20f /* less then 8 bytes, go to byte copy loop */
27778 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27779 jz 17f
27780 1: movq (%rsi),%r8
27781 2: movq 1*8(%rsi),%r9
27782 -3: movq 2*8(%rsi),%r10
27783 +3: movq 2*8(%rsi),%rax
27784 4: movq 3*8(%rsi),%r11
27785 5: movq %r8,(%rdi)
27786 6: movq %r9,1*8(%rdi)
27787 -7: movq %r10,2*8(%rdi)
27788 +7: movq %rax,2*8(%rdi)
27789 8: movq %r11,3*8(%rdi)
27790 9: movq 4*8(%rsi),%r8
27791 10: movq 5*8(%rsi),%r9
27792 -11: movq 6*8(%rsi),%r10
27793 +11: movq 6*8(%rsi),%rax
27794 12: movq 7*8(%rsi),%r11
27795 13: movq %r8,4*8(%rdi)
27796 14: movq %r9,5*8(%rdi)
27797 -15: movq %r10,6*8(%rdi)
27798 +15: movq %rax,6*8(%rdi)
27799 16: movq %r11,7*8(%rdi)
27800 leaq 64(%rsi),%rsi
27801 leaq 64(%rdi),%rdi
27802 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27803 jnz 21b
27804 23: xor %eax,%eax
27805 ASM_CLAC
27806 + ASM_PAX_CLOSE_USERLAND
27807 + pax_force_retaddr
27808 ret
27809
27810 .section .fixup,"ax"
27811 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27812 */
27813 ENTRY(copy_user_generic_string)
27814 CFI_STARTPROC
27815 + ASM_PAX_OPEN_USERLAND
27816 ASM_STAC
27817 andl %edx,%edx
27818 jz 4f
27819 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27820 movsb
27821 4: xorl %eax,%eax
27822 ASM_CLAC
27823 + ASM_PAX_CLOSE_USERLAND
27824 + pax_force_retaddr
27825 ret
27826
27827 .section .fixup,"ax"
27828 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27829 */
27830 ENTRY(copy_user_enhanced_fast_string)
27831 CFI_STARTPROC
27832 + ASM_PAX_OPEN_USERLAND
27833 ASM_STAC
27834 andl %edx,%edx
27835 jz 2f
27836 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27837 movsb
27838 2: xorl %eax,%eax
27839 ASM_CLAC
27840 + ASM_PAX_CLOSE_USERLAND
27841 + pax_force_retaddr
27842 ret
27843
27844 .section .fixup,"ax"
27845 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27846 index 6a4f43c..55d26f2 100644
27847 --- a/arch/x86/lib/copy_user_nocache_64.S
27848 +++ b/arch/x86/lib/copy_user_nocache_64.S
27849 @@ -8,6 +8,7 @@
27850
27851 #include <linux/linkage.h>
27852 #include <asm/dwarf2.h>
27853 +#include <asm/alternative-asm.h>
27854
27855 #define FIX_ALIGNMENT 1
27856
27857 @@ -16,6 +17,7 @@
27858 #include <asm/thread_info.h>
27859 #include <asm/asm.h>
27860 #include <asm/smap.h>
27861 +#include <asm/pgtable.h>
27862
27863 .macro ALIGN_DESTINATION
27864 #ifdef FIX_ALIGNMENT
27865 @@ -49,6 +51,16 @@
27866 */
27867 ENTRY(__copy_user_nocache)
27868 CFI_STARTPROC
27869 +
27870 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27871 + mov pax_user_shadow_base,%rcx
27872 + cmp %rcx,%rsi
27873 + jae 1f
27874 + add %rcx,%rsi
27875 +1:
27876 +#endif
27877 +
27878 + ASM_PAX_OPEN_USERLAND
27879 ASM_STAC
27880 cmpl $8,%edx
27881 jb 20f /* less then 8 bytes, go to byte copy loop */
27882 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27883 jz 17f
27884 1: movq (%rsi),%r8
27885 2: movq 1*8(%rsi),%r9
27886 -3: movq 2*8(%rsi),%r10
27887 +3: movq 2*8(%rsi),%rax
27888 4: movq 3*8(%rsi),%r11
27889 5: movnti %r8,(%rdi)
27890 6: movnti %r9,1*8(%rdi)
27891 -7: movnti %r10,2*8(%rdi)
27892 +7: movnti %rax,2*8(%rdi)
27893 8: movnti %r11,3*8(%rdi)
27894 9: movq 4*8(%rsi),%r8
27895 10: movq 5*8(%rsi),%r9
27896 -11: movq 6*8(%rsi),%r10
27897 +11: movq 6*8(%rsi),%rax
27898 12: movq 7*8(%rsi),%r11
27899 13: movnti %r8,4*8(%rdi)
27900 14: movnti %r9,5*8(%rdi)
27901 -15: movnti %r10,6*8(%rdi)
27902 +15: movnti %rax,6*8(%rdi)
27903 16: movnti %r11,7*8(%rdi)
27904 leaq 64(%rsi),%rsi
27905 leaq 64(%rdi),%rdi
27906 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27907 jnz 21b
27908 23: xorl %eax,%eax
27909 ASM_CLAC
27910 + ASM_PAX_CLOSE_USERLAND
27911 sfence
27912 + pax_force_retaddr
27913 ret
27914
27915 .section .fixup,"ax"
27916 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27917 index 2419d5f..953ee51 100644
27918 --- a/arch/x86/lib/csum-copy_64.S
27919 +++ b/arch/x86/lib/csum-copy_64.S
27920 @@ -9,6 +9,7 @@
27921 #include <asm/dwarf2.h>
27922 #include <asm/errno.h>
27923 #include <asm/asm.h>
27924 +#include <asm/alternative-asm.h>
27925
27926 /*
27927 * Checksum copy with exception handling.
27928 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27929 CFI_RESTORE rbp
27930 addq $7*8, %rsp
27931 CFI_ADJUST_CFA_OFFSET -7*8
27932 + pax_force_retaddr 0, 1
27933 ret
27934 CFI_RESTORE_STATE
27935
27936 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27937 index 7609e0e..b449b98 100644
27938 --- a/arch/x86/lib/csum-wrappers_64.c
27939 +++ b/arch/x86/lib/csum-wrappers_64.c
27940 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27941 len -= 2;
27942 }
27943 }
27944 + pax_open_userland();
27945 stac();
27946 - isum = csum_partial_copy_generic((__force const void *)src,
27947 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27948 dst, len, isum, errp, NULL);
27949 clac();
27950 + pax_close_userland();
27951 if (unlikely(*errp))
27952 goto out_err;
27953
27954 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27955 }
27956
27957 *errp = 0;
27958 + pax_open_userland();
27959 stac();
27960 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27961 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27962 len, isum, NULL, errp);
27963 clac();
27964 + pax_close_userland();
27965 return ret;
27966 }
27967 EXPORT_SYMBOL(csum_partial_copy_to_user);
27968 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27969 index a451235..1daa956 100644
27970 --- a/arch/x86/lib/getuser.S
27971 +++ b/arch/x86/lib/getuser.S
27972 @@ -33,17 +33,40 @@
27973 #include <asm/thread_info.h>
27974 #include <asm/asm.h>
27975 #include <asm/smap.h>
27976 +#include <asm/segment.h>
27977 +#include <asm/pgtable.h>
27978 +#include <asm/alternative-asm.h>
27979 +
27980 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27981 +#define __copyuser_seg gs;
27982 +#else
27983 +#define __copyuser_seg
27984 +#endif
27985
27986 .text
27987 ENTRY(__get_user_1)
27988 CFI_STARTPROC
27989 +
27990 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27991 GET_THREAD_INFO(%_ASM_DX)
27992 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27993 jae bad_get_user
27994 ASM_STAC
27995 -1: movzbl (%_ASM_AX),%edx
27996 +
27997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27998 + mov pax_user_shadow_base,%_ASM_DX
27999 + cmp %_ASM_DX,%_ASM_AX
28000 + jae 1234f
28001 + add %_ASM_DX,%_ASM_AX
28002 +1234:
28003 +#endif
28004 +
28005 +#endif
28006 +
28007 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28008 xor %eax,%eax
28009 ASM_CLAC
28010 + pax_force_retaddr
28011 ret
28012 CFI_ENDPROC
28013 ENDPROC(__get_user_1)
28014 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28015 ENTRY(__get_user_2)
28016 CFI_STARTPROC
28017 add $1,%_ASM_AX
28018 +
28019 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28020 jc bad_get_user
28021 GET_THREAD_INFO(%_ASM_DX)
28022 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28023 jae bad_get_user
28024 ASM_STAC
28025 -2: movzwl -1(%_ASM_AX),%edx
28026 +
28027 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28028 + mov pax_user_shadow_base,%_ASM_DX
28029 + cmp %_ASM_DX,%_ASM_AX
28030 + jae 1234f
28031 + add %_ASM_DX,%_ASM_AX
28032 +1234:
28033 +#endif
28034 +
28035 +#endif
28036 +
28037 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28038 xor %eax,%eax
28039 ASM_CLAC
28040 + pax_force_retaddr
28041 ret
28042 CFI_ENDPROC
28043 ENDPROC(__get_user_2)
28044 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28045 ENTRY(__get_user_4)
28046 CFI_STARTPROC
28047 add $3,%_ASM_AX
28048 +
28049 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28050 jc bad_get_user
28051 GET_THREAD_INFO(%_ASM_DX)
28052 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28053 jae bad_get_user
28054 ASM_STAC
28055 -3: movl -3(%_ASM_AX),%edx
28056 +
28057 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28058 + mov pax_user_shadow_base,%_ASM_DX
28059 + cmp %_ASM_DX,%_ASM_AX
28060 + jae 1234f
28061 + add %_ASM_DX,%_ASM_AX
28062 +1234:
28063 +#endif
28064 +
28065 +#endif
28066 +
28067 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28068 xor %eax,%eax
28069 ASM_CLAC
28070 + pax_force_retaddr
28071 ret
28072 CFI_ENDPROC
28073 ENDPROC(__get_user_4)
28074 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28075 GET_THREAD_INFO(%_ASM_DX)
28076 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28077 jae bad_get_user
28078 +
28079 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28080 + mov pax_user_shadow_base,%_ASM_DX
28081 + cmp %_ASM_DX,%_ASM_AX
28082 + jae 1234f
28083 + add %_ASM_DX,%_ASM_AX
28084 +1234:
28085 +#endif
28086 +
28087 ASM_STAC
28088 4: movq -7(%_ASM_AX),%rdx
28089 xor %eax,%eax
28090 ASM_CLAC
28091 + pax_force_retaddr
28092 ret
28093 #else
28094 add $7,%_ASM_AX
28095 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28096 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28097 jae bad_get_user_8
28098 ASM_STAC
28099 -4: movl -7(%_ASM_AX),%edx
28100 -5: movl -3(%_ASM_AX),%ecx
28101 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28102 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28103 xor %eax,%eax
28104 ASM_CLAC
28105 + pax_force_retaddr
28106 ret
28107 #endif
28108 CFI_ENDPROC
28109 @@ -113,6 +175,7 @@ bad_get_user:
28110 xor %edx,%edx
28111 mov $(-EFAULT),%_ASM_AX
28112 ASM_CLAC
28113 + pax_force_retaddr
28114 ret
28115 CFI_ENDPROC
28116 END(bad_get_user)
28117 @@ -124,6 +187,7 @@ bad_get_user_8:
28118 xor %ecx,%ecx
28119 mov $(-EFAULT),%_ASM_AX
28120 ASM_CLAC
28121 + pax_force_retaddr
28122 ret
28123 CFI_ENDPROC
28124 END(bad_get_user_8)
28125 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28126 index 54fcffe..7be149e 100644
28127 --- a/arch/x86/lib/insn.c
28128 +++ b/arch/x86/lib/insn.c
28129 @@ -20,8 +20,10 @@
28130
28131 #ifdef __KERNEL__
28132 #include <linux/string.h>
28133 +#include <asm/pgtable_types.h>
28134 #else
28135 #include <string.h>
28136 +#define ktla_ktva(addr) addr
28137 #endif
28138 #include <asm/inat.h>
28139 #include <asm/insn.h>
28140 @@ -53,8 +55,8 @@
28141 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28142 {
28143 memset(insn, 0, sizeof(*insn));
28144 - insn->kaddr = kaddr;
28145 - insn->next_byte = kaddr;
28146 + insn->kaddr = ktla_ktva(kaddr);
28147 + insn->next_byte = ktla_ktva(kaddr);
28148 insn->x86_64 = x86_64 ? 1 : 0;
28149 insn->opnd_bytes = 4;
28150 if (x86_64)
28151 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28152 index 05a95e7..326f2fa 100644
28153 --- a/arch/x86/lib/iomap_copy_64.S
28154 +++ b/arch/x86/lib/iomap_copy_64.S
28155 @@ -17,6 +17,7 @@
28156
28157 #include <linux/linkage.h>
28158 #include <asm/dwarf2.h>
28159 +#include <asm/alternative-asm.h>
28160
28161 /*
28162 * override generic version in lib/iomap_copy.c
28163 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28164 CFI_STARTPROC
28165 movl %edx,%ecx
28166 rep movsd
28167 + pax_force_retaddr
28168 ret
28169 CFI_ENDPROC
28170 ENDPROC(__iowrite32_copy)
28171 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28172 index 56313a3..9b59269 100644
28173 --- a/arch/x86/lib/memcpy_64.S
28174 +++ b/arch/x86/lib/memcpy_64.S
28175 @@ -24,7 +24,7 @@
28176 * This gets patched over the unrolled variant (below) via the
28177 * alternative instructions framework:
28178 */
28179 - .section .altinstr_replacement, "ax", @progbits
28180 + .section .altinstr_replacement, "a", @progbits
28181 .Lmemcpy_c:
28182 movq %rdi, %rax
28183 movq %rdx, %rcx
28184 @@ -33,6 +33,7 @@
28185 rep movsq
28186 movl %edx, %ecx
28187 rep movsb
28188 + pax_force_retaddr
28189 ret
28190 .Lmemcpy_e:
28191 .previous
28192 @@ -44,11 +45,12 @@
28193 * This gets patched over the unrolled variant (below) via the
28194 * alternative instructions framework:
28195 */
28196 - .section .altinstr_replacement, "ax", @progbits
28197 + .section .altinstr_replacement, "a", @progbits
28198 .Lmemcpy_c_e:
28199 movq %rdi, %rax
28200 movq %rdx, %rcx
28201 rep movsb
28202 + pax_force_retaddr
28203 ret
28204 .Lmemcpy_e_e:
28205 .previous
28206 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28207 */
28208 movq 0*8(%rsi), %r8
28209 movq 1*8(%rsi), %r9
28210 - movq 2*8(%rsi), %r10
28211 + movq 2*8(%rsi), %rcx
28212 movq 3*8(%rsi), %r11
28213 leaq 4*8(%rsi), %rsi
28214
28215 movq %r8, 0*8(%rdi)
28216 movq %r9, 1*8(%rdi)
28217 - movq %r10, 2*8(%rdi)
28218 + movq %rcx, 2*8(%rdi)
28219 movq %r11, 3*8(%rdi)
28220 leaq 4*8(%rdi), %rdi
28221 jae .Lcopy_forward_loop
28222 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28223 subq $0x20, %rdx
28224 movq -1*8(%rsi), %r8
28225 movq -2*8(%rsi), %r9
28226 - movq -3*8(%rsi), %r10
28227 + movq -3*8(%rsi), %rcx
28228 movq -4*8(%rsi), %r11
28229 leaq -4*8(%rsi), %rsi
28230 movq %r8, -1*8(%rdi)
28231 movq %r9, -2*8(%rdi)
28232 - movq %r10, -3*8(%rdi)
28233 + movq %rcx, -3*8(%rdi)
28234 movq %r11, -4*8(%rdi)
28235 leaq -4*8(%rdi), %rdi
28236 jae .Lcopy_backward_loop
28237 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28238 */
28239 movq 0*8(%rsi), %r8
28240 movq 1*8(%rsi), %r9
28241 - movq -2*8(%rsi, %rdx), %r10
28242 + movq -2*8(%rsi, %rdx), %rcx
28243 movq -1*8(%rsi, %rdx), %r11
28244 movq %r8, 0*8(%rdi)
28245 movq %r9, 1*8(%rdi)
28246 - movq %r10, -2*8(%rdi, %rdx)
28247 + movq %rcx, -2*8(%rdi, %rdx)
28248 movq %r11, -1*8(%rdi, %rdx)
28249 + pax_force_retaddr
28250 retq
28251 .p2align 4
28252 .Lless_16bytes:
28253 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28254 movq -1*8(%rsi, %rdx), %r9
28255 movq %r8, 0*8(%rdi)
28256 movq %r9, -1*8(%rdi, %rdx)
28257 + pax_force_retaddr
28258 retq
28259 .p2align 4
28260 .Lless_8bytes:
28261 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28262 movl -4(%rsi, %rdx), %r8d
28263 movl %ecx, (%rdi)
28264 movl %r8d, -4(%rdi, %rdx)
28265 + pax_force_retaddr
28266 retq
28267 .p2align 4
28268 .Lless_3bytes:
28269 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28270 movb %cl, (%rdi)
28271
28272 .Lend:
28273 + pax_force_retaddr
28274 retq
28275 CFI_ENDPROC
28276 ENDPROC(memcpy)
28277 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28278 index 65268a6..5aa7815 100644
28279 --- a/arch/x86/lib/memmove_64.S
28280 +++ b/arch/x86/lib/memmove_64.S
28281 @@ -61,13 +61,13 @@ ENTRY(memmove)
28282 5:
28283 sub $0x20, %rdx
28284 movq 0*8(%rsi), %r11
28285 - movq 1*8(%rsi), %r10
28286 + movq 1*8(%rsi), %rcx
28287 movq 2*8(%rsi), %r9
28288 movq 3*8(%rsi), %r8
28289 leaq 4*8(%rsi), %rsi
28290
28291 movq %r11, 0*8(%rdi)
28292 - movq %r10, 1*8(%rdi)
28293 + movq %rcx, 1*8(%rdi)
28294 movq %r9, 2*8(%rdi)
28295 movq %r8, 3*8(%rdi)
28296 leaq 4*8(%rdi), %rdi
28297 @@ -81,10 +81,10 @@ ENTRY(memmove)
28298 4:
28299 movq %rdx, %rcx
28300 movq -8(%rsi, %rdx), %r11
28301 - lea -8(%rdi, %rdx), %r10
28302 + lea -8(%rdi, %rdx), %r9
28303 shrq $3, %rcx
28304 rep movsq
28305 - movq %r11, (%r10)
28306 + movq %r11, (%r9)
28307 jmp 13f
28308 .Lmemmove_end_forward:
28309
28310 @@ -95,14 +95,14 @@ ENTRY(memmove)
28311 7:
28312 movq %rdx, %rcx
28313 movq (%rsi), %r11
28314 - movq %rdi, %r10
28315 + movq %rdi, %r9
28316 leaq -8(%rsi, %rdx), %rsi
28317 leaq -8(%rdi, %rdx), %rdi
28318 shrq $3, %rcx
28319 std
28320 rep movsq
28321 cld
28322 - movq %r11, (%r10)
28323 + movq %r11, (%r9)
28324 jmp 13f
28325
28326 /*
28327 @@ -127,13 +127,13 @@ ENTRY(memmove)
28328 8:
28329 subq $0x20, %rdx
28330 movq -1*8(%rsi), %r11
28331 - movq -2*8(%rsi), %r10
28332 + movq -2*8(%rsi), %rcx
28333 movq -3*8(%rsi), %r9
28334 movq -4*8(%rsi), %r8
28335 leaq -4*8(%rsi), %rsi
28336
28337 movq %r11, -1*8(%rdi)
28338 - movq %r10, -2*8(%rdi)
28339 + movq %rcx, -2*8(%rdi)
28340 movq %r9, -3*8(%rdi)
28341 movq %r8, -4*8(%rdi)
28342 leaq -4*8(%rdi), %rdi
28343 @@ -151,11 +151,11 @@ ENTRY(memmove)
28344 * Move data from 16 bytes to 31 bytes.
28345 */
28346 movq 0*8(%rsi), %r11
28347 - movq 1*8(%rsi), %r10
28348 + movq 1*8(%rsi), %rcx
28349 movq -2*8(%rsi, %rdx), %r9
28350 movq -1*8(%rsi, %rdx), %r8
28351 movq %r11, 0*8(%rdi)
28352 - movq %r10, 1*8(%rdi)
28353 + movq %rcx, 1*8(%rdi)
28354 movq %r9, -2*8(%rdi, %rdx)
28355 movq %r8, -1*8(%rdi, %rdx)
28356 jmp 13f
28357 @@ -167,9 +167,9 @@ ENTRY(memmove)
28358 * Move data from 8 bytes to 15 bytes.
28359 */
28360 movq 0*8(%rsi), %r11
28361 - movq -1*8(%rsi, %rdx), %r10
28362 + movq -1*8(%rsi, %rdx), %r9
28363 movq %r11, 0*8(%rdi)
28364 - movq %r10, -1*8(%rdi, %rdx)
28365 + movq %r9, -1*8(%rdi, %rdx)
28366 jmp 13f
28367 10:
28368 cmpq $4, %rdx
28369 @@ -178,9 +178,9 @@ ENTRY(memmove)
28370 * Move data from 4 bytes to 7 bytes.
28371 */
28372 movl (%rsi), %r11d
28373 - movl -4(%rsi, %rdx), %r10d
28374 + movl -4(%rsi, %rdx), %r9d
28375 movl %r11d, (%rdi)
28376 - movl %r10d, -4(%rdi, %rdx)
28377 + movl %r9d, -4(%rdi, %rdx)
28378 jmp 13f
28379 11:
28380 cmp $2, %rdx
28381 @@ -189,9 +189,9 @@ ENTRY(memmove)
28382 * Move data from 2 bytes to 3 bytes.
28383 */
28384 movw (%rsi), %r11w
28385 - movw -2(%rsi, %rdx), %r10w
28386 + movw -2(%rsi, %rdx), %r9w
28387 movw %r11w, (%rdi)
28388 - movw %r10w, -2(%rdi, %rdx)
28389 + movw %r9w, -2(%rdi, %rdx)
28390 jmp 13f
28391 12:
28392 cmp $1, %rdx
28393 @@ -202,14 +202,16 @@ ENTRY(memmove)
28394 movb (%rsi), %r11b
28395 movb %r11b, (%rdi)
28396 13:
28397 + pax_force_retaddr
28398 retq
28399 CFI_ENDPROC
28400
28401 - .section .altinstr_replacement,"ax"
28402 + .section .altinstr_replacement,"a"
28403 .Lmemmove_begin_forward_efs:
28404 /* Forward moving data. */
28405 movq %rdx, %rcx
28406 rep movsb
28407 + pax_force_retaddr
28408 retq
28409 .Lmemmove_end_forward_efs:
28410 .previous
28411 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28412 index 2dcb380..50a78bc 100644
28413 --- a/arch/x86/lib/memset_64.S
28414 +++ b/arch/x86/lib/memset_64.S
28415 @@ -16,7 +16,7 @@
28416 *
28417 * rax original destination
28418 */
28419 - .section .altinstr_replacement, "ax", @progbits
28420 + .section .altinstr_replacement, "a", @progbits
28421 .Lmemset_c:
28422 movq %rdi,%r9
28423 movq %rdx,%rcx
28424 @@ -30,6 +30,7 @@
28425 movl %edx,%ecx
28426 rep stosb
28427 movq %r9,%rax
28428 + pax_force_retaddr
28429 ret
28430 .Lmemset_e:
28431 .previous
28432 @@ -45,13 +46,14 @@
28433 *
28434 * rax original destination
28435 */
28436 - .section .altinstr_replacement, "ax", @progbits
28437 + .section .altinstr_replacement, "a", @progbits
28438 .Lmemset_c_e:
28439 movq %rdi,%r9
28440 movb %sil,%al
28441 movq %rdx,%rcx
28442 rep stosb
28443 movq %r9,%rax
28444 + pax_force_retaddr
28445 ret
28446 .Lmemset_e_e:
28447 .previous
28448 @@ -59,7 +61,7 @@
28449 ENTRY(memset)
28450 ENTRY(__memset)
28451 CFI_STARTPROC
28452 - movq %rdi,%r10
28453 + movq %rdi,%r11
28454
28455 /* expand byte value */
28456 movzbl %sil,%ecx
28457 @@ -117,7 +119,8 @@ ENTRY(__memset)
28458 jnz .Lloop_1
28459
28460 .Lende:
28461 - movq %r10,%rax
28462 + movq %r11,%rax
28463 + pax_force_retaddr
28464 ret
28465
28466 CFI_RESTORE_STATE
28467 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28468 index c9f2d9b..e7fd2c0 100644
28469 --- a/arch/x86/lib/mmx_32.c
28470 +++ b/arch/x86/lib/mmx_32.c
28471 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28472 {
28473 void *p;
28474 int i;
28475 + unsigned long cr0;
28476
28477 if (unlikely(in_interrupt()))
28478 return __memcpy(to, from, len);
28479 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28480 kernel_fpu_begin();
28481
28482 __asm__ __volatile__ (
28483 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28484 - " prefetch 64(%0)\n"
28485 - " prefetch 128(%0)\n"
28486 - " prefetch 192(%0)\n"
28487 - " prefetch 256(%0)\n"
28488 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28489 + " prefetch 64(%1)\n"
28490 + " prefetch 128(%1)\n"
28491 + " prefetch 192(%1)\n"
28492 + " prefetch 256(%1)\n"
28493 "2: \n"
28494 ".section .fixup, \"ax\"\n"
28495 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28496 + "3: \n"
28497 +
28498 +#ifdef CONFIG_PAX_KERNEXEC
28499 + " movl %%cr0, %0\n"
28500 + " movl %0, %%eax\n"
28501 + " andl $0xFFFEFFFF, %%eax\n"
28502 + " movl %%eax, %%cr0\n"
28503 +#endif
28504 +
28505 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28506 +
28507 +#ifdef CONFIG_PAX_KERNEXEC
28508 + " movl %0, %%cr0\n"
28509 +#endif
28510 +
28511 " jmp 2b\n"
28512 ".previous\n"
28513 _ASM_EXTABLE(1b, 3b)
28514 - : : "r" (from));
28515 + : "=&r" (cr0) : "r" (from) : "ax");
28516
28517 for ( ; i > 5; i--) {
28518 __asm__ __volatile__ (
28519 - "1: prefetch 320(%0)\n"
28520 - "2: movq (%0), %%mm0\n"
28521 - " movq 8(%0), %%mm1\n"
28522 - " movq 16(%0), %%mm2\n"
28523 - " movq 24(%0), %%mm3\n"
28524 - " movq %%mm0, (%1)\n"
28525 - " movq %%mm1, 8(%1)\n"
28526 - " movq %%mm2, 16(%1)\n"
28527 - " movq %%mm3, 24(%1)\n"
28528 - " movq 32(%0), %%mm0\n"
28529 - " movq 40(%0), %%mm1\n"
28530 - " movq 48(%0), %%mm2\n"
28531 - " movq 56(%0), %%mm3\n"
28532 - " movq %%mm0, 32(%1)\n"
28533 - " movq %%mm1, 40(%1)\n"
28534 - " movq %%mm2, 48(%1)\n"
28535 - " movq %%mm3, 56(%1)\n"
28536 + "1: prefetch 320(%1)\n"
28537 + "2: movq (%1), %%mm0\n"
28538 + " movq 8(%1), %%mm1\n"
28539 + " movq 16(%1), %%mm2\n"
28540 + " movq 24(%1), %%mm3\n"
28541 + " movq %%mm0, (%2)\n"
28542 + " movq %%mm1, 8(%2)\n"
28543 + " movq %%mm2, 16(%2)\n"
28544 + " movq %%mm3, 24(%2)\n"
28545 + " movq 32(%1), %%mm0\n"
28546 + " movq 40(%1), %%mm1\n"
28547 + " movq 48(%1), %%mm2\n"
28548 + " movq 56(%1), %%mm3\n"
28549 + " movq %%mm0, 32(%2)\n"
28550 + " movq %%mm1, 40(%2)\n"
28551 + " movq %%mm2, 48(%2)\n"
28552 + " movq %%mm3, 56(%2)\n"
28553 ".section .fixup, \"ax\"\n"
28554 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28555 + "3:\n"
28556 +
28557 +#ifdef CONFIG_PAX_KERNEXEC
28558 + " movl %%cr0, %0\n"
28559 + " movl %0, %%eax\n"
28560 + " andl $0xFFFEFFFF, %%eax\n"
28561 + " movl %%eax, %%cr0\n"
28562 +#endif
28563 +
28564 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28565 +
28566 +#ifdef CONFIG_PAX_KERNEXEC
28567 + " movl %0, %%cr0\n"
28568 +#endif
28569 +
28570 " jmp 2b\n"
28571 ".previous\n"
28572 _ASM_EXTABLE(1b, 3b)
28573 - : : "r" (from), "r" (to) : "memory");
28574 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28575
28576 from += 64;
28577 to += 64;
28578 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28579 static void fast_copy_page(void *to, void *from)
28580 {
28581 int i;
28582 + unsigned long cr0;
28583
28584 kernel_fpu_begin();
28585
28586 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28587 * but that is for later. -AV
28588 */
28589 __asm__ __volatile__(
28590 - "1: prefetch (%0)\n"
28591 - " prefetch 64(%0)\n"
28592 - " prefetch 128(%0)\n"
28593 - " prefetch 192(%0)\n"
28594 - " prefetch 256(%0)\n"
28595 + "1: prefetch (%1)\n"
28596 + " prefetch 64(%1)\n"
28597 + " prefetch 128(%1)\n"
28598 + " prefetch 192(%1)\n"
28599 + " prefetch 256(%1)\n"
28600 "2: \n"
28601 ".section .fixup, \"ax\"\n"
28602 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28603 + "3: \n"
28604 +
28605 +#ifdef CONFIG_PAX_KERNEXEC
28606 + " movl %%cr0, %0\n"
28607 + " movl %0, %%eax\n"
28608 + " andl $0xFFFEFFFF, %%eax\n"
28609 + " movl %%eax, %%cr0\n"
28610 +#endif
28611 +
28612 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28613 +
28614 +#ifdef CONFIG_PAX_KERNEXEC
28615 + " movl %0, %%cr0\n"
28616 +#endif
28617 +
28618 " jmp 2b\n"
28619 ".previous\n"
28620 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28621 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28622
28623 for (i = 0; i < (4096-320)/64; i++) {
28624 __asm__ __volatile__ (
28625 - "1: prefetch 320(%0)\n"
28626 - "2: movq (%0), %%mm0\n"
28627 - " movntq %%mm0, (%1)\n"
28628 - " movq 8(%0), %%mm1\n"
28629 - " movntq %%mm1, 8(%1)\n"
28630 - " movq 16(%0), %%mm2\n"
28631 - " movntq %%mm2, 16(%1)\n"
28632 - " movq 24(%0), %%mm3\n"
28633 - " movntq %%mm3, 24(%1)\n"
28634 - " movq 32(%0), %%mm4\n"
28635 - " movntq %%mm4, 32(%1)\n"
28636 - " movq 40(%0), %%mm5\n"
28637 - " movntq %%mm5, 40(%1)\n"
28638 - " movq 48(%0), %%mm6\n"
28639 - " movntq %%mm6, 48(%1)\n"
28640 - " movq 56(%0), %%mm7\n"
28641 - " movntq %%mm7, 56(%1)\n"
28642 + "1: prefetch 320(%1)\n"
28643 + "2: movq (%1), %%mm0\n"
28644 + " movntq %%mm0, (%2)\n"
28645 + " movq 8(%1), %%mm1\n"
28646 + " movntq %%mm1, 8(%2)\n"
28647 + " movq 16(%1), %%mm2\n"
28648 + " movntq %%mm2, 16(%2)\n"
28649 + " movq 24(%1), %%mm3\n"
28650 + " movntq %%mm3, 24(%2)\n"
28651 + " movq 32(%1), %%mm4\n"
28652 + " movntq %%mm4, 32(%2)\n"
28653 + " movq 40(%1), %%mm5\n"
28654 + " movntq %%mm5, 40(%2)\n"
28655 + " movq 48(%1), %%mm6\n"
28656 + " movntq %%mm6, 48(%2)\n"
28657 + " movq 56(%1), %%mm7\n"
28658 + " movntq %%mm7, 56(%2)\n"
28659 ".section .fixup, \"ax\"\n"
28660 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28661 + "3:\n"
28662 +
28663 +#ifdef CONFIG_PAX_KERNEXEC
28664 + " movl %%cr0, %0\n"
28665 + " movl %0, %%eax\n"
28666 + " andl $0xFFFEFFFF, %%eax\n"
28667 + " movl %%eax, %%cr0\n"
28668 +#endif
28669 +
28670 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28671 +
28672 +#ifdef CONFIG_PAX_KERNEXEC
28673 + " movl %0, %%cr0\n"
28674 +#endif
28675 +
28676 " jmp 2b\n"
28677 ".previous\n"
28678 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28679 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28680
28681 from += 64;
28682 to += 64;
28683 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28684 static void fast_copy_page(void *to, void *from)
28685 {
28686 int i;
28687 + unsigned long cr0;
28688
28689 kernel_fpu_begin();
28690
28691 __asm__ __volatile__ (
28692 - "1: prefetch (%0)\n"
28693 - " prefetch 64(%0)\n"
28694 - " prefetch 128(%0)\n"
28695 - " prefetch 192(%0)\n"
28696 - " prefetch 256(%0)\n"
28697 + "1: prefetch (%1)\n"
28698 + " prefetch 64(%1)\n"
28699 + " prefetch 128(%1)\n"
28700 + " prefetch 192(%1)\n"
28701 + " prefetch 256(%1)\n"
28702 "2: \n"
28703 ".section .fixup, \"ax\"\n"
28704 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28705 + "3: \n"
28706 +
28707 +#ifdef CONFIG_PAX_KERNEXEC
28708 + " movl %%cr0, %0\n"
28709 + " movl %0, %%eax\n"
28710 + " andl $0xFFFEFFFF, %%eax\n"
28711 + " movl %%eax, %%cr0\n"
28712 +#endif
28713 +
28714 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28715 +
28716 +#ifdef CONFIG_PAX_KERNEXEC
28717 + " movl %0, %%cr0\n"
28718 +#endif
28719 +
28720 " jmp 2b\n"
28721 ".previous\n"
28722 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28723 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28724
28725 for (i = 0; i < 4096/64; i++) {
28726 __asm__ __volatile__ (
28727 - "1: prefetch 320(%0)\n"
28728 - "2: movq (%0), %%mm0\n"
28729 - " movq 8(%0), %%mm1\n"
28730 - " movq 16(%0), %%mm2\n"
28731 - " movq 24(%0), %%mm3\n"
28732 - " movq %%mm0, (%1)\n"
28733 - " movq %%mm1, 8(%1)\n"
28734 - " movq %%mm2, 16(%1)\n"
28735 - " movq %%mm3, 24(%1)\n"
28736 - " movq 32(%0), %%mm0\n"
28737 - " movq 40(%0), %%mm1\n"
28738 - " movq 48(%0), %%mm2\n"
28739 - " movq 56(%0), %%mm3\n"
28740 - " movq %%mm0, 32(%1)\n"
28741 - " movq %%mm1, 40(%1)\n"
28742 - " movq %%mm2, 48(%1)\n"
28743 - " movq %%mm3, 56(%1)\n"
28744 + "1: prefetch 320(%1)\n"
28745 + "2: movq (%1), %%mm0\n"
28746 + " movq 8(%1), %%mm1\n"
28747 + " movq 16(%1), %%mm2\n"
28748 + " movq 24(%1), %%mm3\n"
28749 + " movq %%mm0, (%2)\n"
28750 + " movq %%mm1, 8(%2)\n"
28751 + " movq %%mm2, 16(%2)\n"
28752 + " movq %%mm3, 24(%2)\n"
28753 + " movq 32(%1), %%mm0\n"
28754 + " movq 40(%1), %%mm1\n"
28755 + " movq 48(%1), %%mm2\n"
28756 + " movq 56(%1), %%mm3\n"
28757 + " movq %%mm0, 32(%2)\n"
28758 + " movq %%mm1, 40(%2)\n"
28759 + " movq %%mm2, 48(%2)\n"
28760 + " movq %%mm3, 56(%2)\n"
28761 ".section .fixup, \"ax\"\n"
28762 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28763 + "3:\n"
28764 +
28765 +#ifdef CONFIG_PAX_KERNEXEC
28766 + " movl %%cr0, %0\n"
28767 + " movl %0, %%eax\n"
28768 + " andl $0xFFFEFFFF, %%eax\n"
28769 + " movl %%eax, %%cr0\n"
28770 +#endif
28771 +
28772 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28773 +
28774 +#ifdef CONFIG_PAX_KERNEXEC
28775 + " movl %0, %%cr0\n"
28776 +#endif
28777 +
28778 " jmp 2b\n"
28779 ".previous\n"
28780 _ASM_EXTABLE(1b, 3b)
28781 - : : "r" (from), "r" (to) : "memory");
28782 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28783
28784 from += 64;
28785 to += 64;
28786 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28787 index f6d13ee..aca5f0b 100644
28788 --- a/arch/x86/lib/msr-reg.S
28789 +++ b/arch/x86/lib/msr-reg.S
28790 @@ -3,6 +3,7 @@
28791 #include <asm/dwarf2.h>
28792 #include <asm/asm.h>
28793 #include <asm/msr.h>
28794 +#include <asm/alternative-asm.h>
28795
28796 #ifdef CONFIG_X86_64
28797 /*
28798 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28799 CFI_STARTPROC
28800 pushq_cfi %rbx
28801 pushq_cfi %rbp
28802 - movq %rdi, %r10 /* Save pointer */
28803 + movq %rdi, %r9 /* Save pointer */
28804 xorl %r11d, %r11d /* Return value */
28805 movl (%rdi), %eax
28806 movl 4(%rdi), %ecx
28807 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28808 movl 28(%rdi), %edi
28809 CFI_REMEMBER_STATE
28810 1: \op
28811 -2: movl %eax, (%r10)
28812 +2: movl %eax, (%r9)
28813 movl %r11d, %eax /* Return value */
28814 - movl %ecx, 4(%r10)
28815 - movl %edx, 8(%r10)
28816 - movl %ebx, 12(%r10)
28817 - movl %ebp, 20(%r10)
28818 - movl %esi, 24(%r10)
28819 - movl %edi, 28(%r10)
28820 + movl %ecx, 4(%r9)
28821 + movl %edx, 8(%r9)
28822 + movl %ebx, 12(%r9)
28823 + movl %ebp, 20(%r9)
28824 + movl %esi, 24(%r9)
28825 + movl %edi, 28(%r9)
28826 popq_cfi %rbp
28827 popq_cfi %rbx
28828 + pax_force_retaddr
28829 ret
28830 3:
28831 CFI_RESTORE_STATE
28832 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28833 index fc6ba17..d4d989d 100644
28834 --- a/arch/x86/lib/putuser.S
28835 +++ b/arch/x86/lib/putuser.S
28836 @@ -16,7 +16,9 @@
28837 #include <asm/errno.h>
28838 #include <asm/asm.h>
28839 #include <asm/smap.h>
28840 -
28841 +#include <asm/segment.h>
28842 +#include <asm/pgtable.h>
28843 +#include <asm/alternative-asm.h>
28844
28845 /*
28846 * __put_user_X
28847 @@ -30,57 +32,125 @@
28848 * as they get called from within inline assembly.
28849 */
28850
28851 -#define ENTER CFI_STARTPROC ; \
28852 - GET_THREAD_INFO(%_ASM_BX)
28853 -#define EXIT ASM_CLAC ; \
28854 - ret ; \
28855 +#define ENTER CFI_STARTPROC
28856 +#define EXIT ASM_CLAC ; \
28857 + pax_force_retaddr ; \
28858 + ret ; \
28859 CFI_ENDPROC
28860
28861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28862 +#define _DEST %_ASM_CX,%_ASM_BX
28863 +#else
28864 +#define _DEST %_ASM_CX
28865 +#endif
28866 +
28867 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28868 +#define __copyuser_seg gs;
28869 +#else
28870 +#define __copyuser_seg
28871 +#endif
28872 +
28873 .text
28874 ENTRY(__put_user_1)
28875 ENTER
28876 +
28877 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28878 + GET_THREAD_INFO(%_ASM_BX)
28879 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28880 jae bad_put_user
28881 ASM_STAC
28882 -1: movb %al,(%_ASM_CX)
28883 +
28884 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28885 + mov pax_user_shadow_base,%_ASM_BX
28886 + cmp %_ASM_BX,%_ASM_CX
28887 + jb 1234f
28888 + xor %ebx,%ebx
28889 +1234:
28890 +#endif
28891 +
28892 +#endif
28893 +
28894 +1: __copyuser_seg movb %al,(_DEST)
28895 xor %eax,%eax
28896 EXIT
28897 ENDPROC(__put_user_1)
28898
28899 ENTRY(__put_user_2)
28900 ENTER
28901 +
28902 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28903 + GET_THREAD_INFO(%_ASM_BX)
28904 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28905 sub $1,%_ASM_BX
28906 cmp %_ASM_BX,%_ASM_CX
28907 jae bad_put_user
28908 ASM_STAC
28909 -2: movw %ax,(%_ASM_CX)
28910 +
28911 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28912 + mov pax_user_shadow_base,%_ASM_BX
28913 + cmp %_ASM_BX,%_ASM_CX
28914 + jb 1234f
28915 + xor %ebx,%ebx
28916 +1234:
28917 +#endif
28918 +
28919 +#endif
28920 +
28921 +2: __copyuser_seg movw %ax,(_DEST)
28922 xor %eax,%eax
28923 EXIT
28924 ENDPROC(__put_user_2)
28925
28926 ENTRY(__put_user_4)
28927 ENTER
28928 +
28929 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28930 + GET_THREAD_INFO(%_ASM_BX)
28931 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28932 sub $3,%_ASM_BX
28933 cmp %_ASM_BX,%_ASM_CX
28934 jae bad_put_user
28935 ASM_STAC
28936 -3: movl %eax,(%_ASM_CX)
28937 +
28938 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28939 + mov pax_user_shadow_base,%_ASM_BX
28940 + cmp %_ASM_BX,%_ASM_CX
28941 + jb 1234f
28942 + xor %ebx,%ebx
28943 +1234:
28944 +#endif
28945 +
28946 +#endif
28947 +
28948 +3: __copyuser_seg movl %eax,(_DEST)
28949 xor %eax,%eax
28950 EXIT
28951 ENDPROC(__put_user_4)
28952
28953 ENTRY(__put_user_8)
28954 ENTER
28955 +
28956 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28957 + GET_THREAD_INFO(%_ASM_BX)
28958 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28959 sub $7,%_ASM_BX
28960 cmp %_ASM_BX,%_ASM_CX
28961 jae bad_put_user
28962 ASM_STAC
28963 -4: mov %_ASM_AX,(%_ASM_CX)
28964 +
28965 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28966 + mov pax_user_shadow_base,%_ASM_BX
28967 + cmp %_ASM_BX,%_ASM_CX
28968 + jb 1234f
28969 + xor %ebx,%ebx
28970 +1234:
28971 +#endif
28972 +
28973 +#endif
28974 +
28975 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28976 #ifdef CONFIG_X86_32
28977 -5: movl %edx,4(%_ASM_CX)
28978 +5: __copyuser_seg movl %edx,4(_DEST)
28979 #endif
28980 xor %eax,%eax
28981 EXIT
28982 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28983 index 1cad221..de671ee 100644
28984 --- a/arch/x86/lib/rwlock.S
28985 +++ b/arch/x86/lib/rwlock.S
28986 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28987 FRAME
28988 0: LOCK_PREFIX
28989 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28990 +
28991 +#ifdef CONFIG_PAX_REFCOUNT
28992 + jno 1234f
28993 + LOCK_PREFIX
28994 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28995 + int $4
28996 +1234:
28997 + _ASM_EXTABLE(1234b, 1234b)
28998 +#endif
28999 +
29000 1: rep; nop
29001 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29002 jne 1b
29003 LOCK_PREFIX
29004 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29005 +
29006 +#ifdef CONFIG_PAX_REFCOUNT
29007 + jno 1234f
29008 + LOCK_PREFIX
29009 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29010 + int $4
29011 +1234:
29012 + _ASM_EXTABLE(1234b, 1234b)
29013 +#endif
29014 +
29015 jnz 0b
29016 ENDFRAME
29017 + pax_force_retaddr
29018 ret
29019 CFI_ENDPROC
29020 END(__write_lock_failed)
29021 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29022 FRAME
29023 0: LOCK_PREFIX
29024 READ_LOCK_SIZE(inc) (%__lock_ptr)
29025 +
29026 +#ifdef CONFIG_PAX_REFCOUNT
29027 + jno 1234f
29028 + LOCK_PREFIX
29029 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29030 + int $4
29031 +1234:
29032 + _ASM_EXTABLE(1234b, 1234b)
29033 +#endif
29034 +
29035 1: rep; nop
29036 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29037 js 1b
29038 LOCK_PREFIX
29039 READ_LOCK_SIZE(dec) (%__lock_ptr)
29040 +
29041 +#ifdef CONFIG_PAX_REFCOUNT
29042 + jno 1234f
29043 + LOCK_PREFIX
29044 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29045 + int $4
29046 +1234:
29047 + _ASM_EXTABLE(1234b, 1234b)
29048 +#endif
29049 +
29050 js 0b
29051 ENDFRAME
29052 + pax_force_retaddr
29053 ret
29054 CFI_ENDPROC
29055 END(__read_lock_failed)
29056 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29057 index 5dff5f0..cadebf4 100644
29058 --- a/arch/x86/lib/rwsem.S
29059 +++ b/arch/x86/lib/rwsem.S
29060 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29061 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29062 CFI_RESTORE __ASM_REG(dx)
29063 restore_common_regs
29064 + pax_force_retaddr
29065 ret
29066 CFI_ENDPROC
29067 ENDPROC(call_rwsem_down_read_failed)
29068 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29069 movq %rax,%rdi
29070 call rwsem_down_write_failed
29071 restore_common_regs
29072 + pax_force_retaddr
29073 ret
29074 CFI_ENDPROC
29075 ENDPROC(call_rwsem_down_write_failed)
29076 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29077 movq %rax,%rdi
29078 call rwsem_wake
29079 restore_common_regs
29080 -1: ret
29081 +1: pax_force_retaddr
29082 + ret
29083 CFI_ENDPROC
29084 ENDPROC(call_rwsem_wake)
29085
29086 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29087 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29088 CFI_RESTORE __ASM_REG(dx)
29089 restore_common_regs
29090 + pax_force_retaddr
29091 ret
29092 CFI_ENDPROC
29093 ENDPROC(call_rwsem_downgrade_wake)
29094 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29095 index a63efd6..ccecad8 100644
29096 --- a/arch/x86/lib/thunk_64.S
29097 +++ b/arch/x86/lib/thunk_64.S
29098 @@ -8,6 +8,7 @@
29099 #include <linux/linkage.h>
29100 #include <asm/dwarf2.h>
29101 #include <asm/calling.h>
29102 +#include <asm/alternative-asm.h>
29103
29104 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29105 .macro THUNK name, func, put_ret_addr_in_rdi=0
29106 @@ -41,5 +42,6 @@
29107 SAVE_ARGS
29108 restore:
29109 RESTORE_ARGS
29110 + pax_force_retaddr
29111 ret
29112 CFI_ENDPROC
29113 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29114 index 3eb18ac..6890bc3 100644
29115 --- a/arch/x86/lib/usercopy_32.c
29116 +++ b/arch/x86/lib/usercopy_32.c
29117 @@ -42,11 +42,13 @@ do { \
29118 int __d0; \
29119 might_fault(); \
29120 __asm__ __volatile__( \
29121 + __COPYUSER_SET_ES \
29122 ASM_STAC "\n" \
29123 "0: rep; stosl\n" \
29124 " movl %2,%0\n" \
29125 "1: rep; stosb\n" \
29126 "2: " ASM_CLAC "\n" \
29127 + __COPYUSER_RESTORE_ES \
29128 ".section .fixup,\"ax\"\n" \
29129 "3: lea 0(%2,%0,4),%0\n" \
29130 " jmp 2b\n" \
29131 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29132
29133 #ifdef CONFIG_X86_INTEL_USERCOPY
29134 static unsigned long
29135 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29136 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29137 {
29138 int d0, d1;
29139 __asm__ __volatile__(
29140 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29141 " .align 2,0x90\n"
29142 "3: movl 0(%4), %%eax\n"
29143 "4: movl 4(%4), %%edx\n"
29144 - "5: movl %%eax, 0(%3)\n"
29145 - "6: movl %%edx, 4(%3)\n"
29146 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29147 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29148 "7: movl 8(%4), %%eax\n"
29149 "8: movl 12(%4),%%edx\n"
29150 - "9: movl %%eax, 8(%3)\n"
29151 - "10: movl %%edx, 12(%3)\n"
29152 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29153 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29154 "11: movl 16(%4), %%eax\n"
29155 "12: movl 20(%4), %%edx\n"
29156 - "13: movl %%eax, 16(%3)\n"
29157 - "14: movl %%edx, 20(%3)\n"
29158 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29159 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29160 "15: movl 24(%4), %%eax\n"
29161 "16: movl 28(%4), %%edx\n"
29162 - "17: movl %%eax, 24(%3)\n"
29163 - "18: movl %%edx, 28(%3)\n"
29164 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29165 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29166 "19: movl 32(%4), %%eax\n"
29167 "20: movl 36(%4), %%edx\n"
29168 - "21: movl %%eax, 32(%3)\n"
29169 - "22: movl %%edx, 36(%3)\n"
29170 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29171 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29172 "23: movl 40(%4), %%eax\n"
29173 "24: movl 44(%4), %%edx\n"
29174 - "25: movl %%eax, 40(%3)\n"
29175 - "26: movl %%edx, 44(%3)\n"
29176 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29177 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29178 "27: movl 48(%4), %%eax\n"
29179 "28: movl 52(%4), %%edx\n"
29180 - "29: movl %%eax, 48(%3)\n"
29181 - "30: movl %%edx, 52(%3)\n"
29182 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29183 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29184 "31: movl 56(%4), %%eax\n"
29185 "32: movl 60(%4), %%edx\n"
29186 - "33: movl %%eax, 56(%3)\n"
29187 - "34: movl %%edx, 60(%3)\n"
29188 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29189 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29190 " addl $-64, %0\n"
29191 " addl $64, %4\n"
29192 " addl $64, %3\n"
29193 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29194 " shrl $2, %0\n"
29195 " andl $3, %%eax\n"
29196 " cld\n"
29197 + __COPYUSER_SET_ES
29198 "99: rep; movsl\n"
29199 "36: movl %%eax, %0\n"
29200 "37: rep; movsb\n"
29201 "100:\n"
29202 + __COPYUSER_RESTORE_ES
29203 ".section .fixup,\"ax\"\n"
29204 "101: lea 0(%%eax,%0,4),%0\n"
29205 " jmp 100b\n"
29206 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29207 }
29208
29209 static unsigned long
29210 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29211 +{
29212 + int d0, d1;
29213 + __asm__ __volatile__(
29214 + " .align 2,0x90\n"
29215 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29216 + " cmpl $67, %0\n"
29217 + " jbe 3f\n"
29218 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29219 + " .align 2,0x90\n"
29220 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29221 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29222 + "5: movl %%eax, 0(%3)\n"
29223 + "6: movl %%edx, 4(%3)\n"
29224 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29225 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29226 + "9: movl %%eax, 8(%3)\n"
29227 + "10: movl %%edx, 12(%3)\n"
29228 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29229 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29230 + "13: movl %%eax, 16(%3)\n"
29231 + "14: movl %%edx, 20(%3)\n"
29232 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29233 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29234 + "17: movl %%eax, 24(%3)\n"
29235 + "18: movl %%edx, 28(%3)\n"
29236 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29237 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29238 + "21: movl %%eax, 32(%3)\n"
29239 + "22: movl %%edx, 36(%3)\n"
29240 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29241 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29242 + "25: movl %%eax, 40(%3)\n"
29243 + "26: movl %%edx, 44(%3)\n"
29244 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29245 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29246 + "29: movl %%eax, 48(%3)\n"
29247 + "30: movl %%edx, 52(%3)\n"
29248 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29249 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29250 + "33: movl %%eax, 56(%3)\n"
29251 + "34: movl %%edx, 60(%3)\n"
29252 + " addl $-64, %0\n"
29253 + " addl $64, %4\n"
29254 + " addl $64, %3\n"
29255 + " cmpl $63, %0\n"
29256 + " ja 1b\n"
29257 + "35: movl %0, %%eax\n"
29258 + " shrl $2, %0\n"
29259 + " andl $3, %%eax\n"
29260 + " cld\n"
29261 + "99: rep; "__copyuser_seg" movsl\n"
29262 + "36: movl %%eax, %0\n"
29263 + "37: rep; "__copyuser_seg" movsb\n"
29264 + "100:\n"
29265 + ".section .fixup,\"ax\"\n"
29266 + "101: lea 0(%%eax,%0,4),%0\n"
29267 + " jmp 100b\n"
29268 + ".previous\n"
29269 + _ASM_EXTABLE(1b,100b)
29270 + _ASM_EXTABLE(2b,100b)
29271 + _ASM_EXTABLE(3b,100b)
29272 + _ASM_EXTABLE(4b,100b)
29273 + _ASM_EXTABLE(5b,100b)
29274 + _ASM_EXTABLE(6b,100b)
29275 + _ASM_EXTABLE(7b,100b)
29276 + _ASM_EXTABLE(8b,100b)
29277 + _ASM_EXTABLE(9b,100b)
29278 + _ASM_EXTABLE(10b,100b)
29279 + _ASM_EXTABLE(11b,100b)
29280 + _ASM_EXTABLE(12b,100b)
29281 + _ASM_EXTABLE(13b,100b)
29282 + _ASM_EXTABLE(14b,100b)
29283 + _ASM_EXTABLE(15b,100b)
29284 + _ASM_EXTABLE(16b,100b)
29285 + _ASM_EXTABLE(17b,100b)
29286 + _ASM_EXTABLE(18b,100b)
29287 + _ASM_EXTABLE(19b,100b)
29288 + _ASM_EXTABLE(20b,100b)
29289 + _ASM_EXTABLE(21b,100b)
29290 + _ASM_EXTABLE(22b,100b)
29291 + _ASM_EXTABLE(23b,100b)
29292 + _ASM_EXTABLE(24b,100b)
29293 + _ASM_EXTABLE(25b,100b)
29294 + _ASM_EXTABLE(26b,100b)
29295 + _ASM_EXTABLE(27b,100b)
29296 + _ASM_EXTABLE(28b,100b)
29297 + _ASM_EXTABLE(29b,100b)
29298 + _ASM_EXTABLE(30b,100b)
29299 + _ASM_EXTABLE(31b,100b)
29300 + _ASM_EXTABLE(32b,100b)
29301 + _ASM_EXTABLE(33b,100b)
29302 + _ASM_EXTABLE(34b,100b)
29303 + _ASM_EXTABLE(35b,100b)
29304 + _ASM_EXTABLE(36b,100b)
29305 + _ASM_EXTABLE(37b,100b)
29306 + _ASM_EXTABLE(99b,101b)
29307 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29308 + : "1"(to), "2"(from), "0"(size)
29309 + : "eax", "edx", "memory");
29310 + return size;
29311 +}
29312 +
29313 +static unsigned long __size_overflow(3)
29314 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29315 {
29316 int d0, d1;
29317 __asm__ __volatile__(
29318 " .align 2,0x90\n"
29319 - "0: movl 32(%4), %%eax\n"
29320 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29321 " cmpl $67, %0\n"
29322 " jbe 2f\n"
29323 - "1: movl 64(%4), %%eax\n"
29324 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29325 " .align 2,0x90\n"
29326 - "2: movl 0(%4), %%eax\n"
29327 - "21: movl 4(%4), %%edx\n"
29328 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29329 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29330 " movl %%eax, 0(%3)\n"
29331 " movl %%edx, 4(%3)\n"
29332 - "3: movl 8(%4), %%eax\n"
29333 - "31: movl 12(%4),%%edx\n"
29334 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29335 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29336 " movl %%eax, 8(%3)\n"
29337 " movl %%edx, 12(%3)\n"
29338 - "4: movl 16(%4), %%eax\n"
29339 - "41: movl 20(%4), %%edx\n"
29340 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29341 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29342 " movl %%eax, 16(%3)\n"
29343 " movl %%edx, 20(%3)\n"
29344 - "10: movl 24(%4), %%eax\n"
29345 - "51: movl 28(%4), %%edx\n"
29346 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29347 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29348 " movl %%eax, 24(%3)\n"
29349 " movl %%edx, 28(%3)\n"
29350 - "11: movl 32(%4), %%eax\n"
29351 - "61: movl 36(%4), %%edx\n"
29352 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29353 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29354 " movl %%eax, 32(%3)\n"
29355 " movl %%edx, 36(%3)\n"
29356 - "12: movl 40(%4), %%eax\n"
29357 - "71: movl 44(%4), %%edx\n"
29358 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29359 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29360 " movl %%eax, 40(%3)\n"
29361 " movl %%edx, 44(%3)\n"
29362 - "13: movl 48(%4), %%eax\n"
29363 - "81: movl 52(%4), %%edx\n"
29364 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29365 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29366 " movl %%eax, 48(%3)\n"
29367 " movl %%edx, 52(%3)\n"
29368 - "14: movl 56(%4), %%eax\n"
29369 - "91: movl 60(%4), %%edx\n"
29370 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29371 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29372 " movl %%eax, 56(%3)\n"
29373 " movl %%edx, 60(%3)\n"
29374 " addl $-64, %0\n"
29375 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29376 " shrl $2, %0\n"
29377 " andl $3, %%eax\n"
29378 " cld\n"
29379 - "6: rep; movsl\n"
29380 + "6: rep; "__copyuser_seg" movsl\n"
29381 " movl %%eax,%0\n"
29382 - "7: rep; movsb\n"
29383 + "7: rep; "__copyuser_seg" movsb\n"
29384 "8:\n"
29385 ".section .fixup,\"ax\"\n"
29386 "9: lea 0(%%eax,%0,4),%0\n"
29387 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29388 * hyoshiok@miraclelinux.com
29389 */
29390
29391 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29392 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29393 const void __user *from, unsigned long size)
29394 {
29395 int d0, d1;
29396
29397 __asm__ __volatile__(
29398 " .align 2,0x90\n"
29399 - "0: movl 32(%4), %%eax\n"
29400 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29401 " cmpl $67, %0\n"
29402 " jbe 2f\n"
29403 - "1: movl 64(%4), %%eax\n"
29404 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29405 " .align 2,0x90\n"
29406 - "2: movl 0(%4), %%eax\n"
29407 - "21: movl 4(%4), %%edx\n"
29408 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29409 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29410 " movnti %%eax, 0(%3)\n"
29411 " movnti %%edx, 4(%3)\n"
29412 - "3: movl 8(%4), %%eax\n"
29413 - "31: movl 12(%4),%%edx\n"
29414 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29415 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29416 " movnti %%eax, 8(%3)\n"
29417 " movnti %%edx, 12(%3)\n"
29418 - "4: movl 16(%4), %%eax\n"
29419 - "41: movl 20(%4), %%edx\n"
29420 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29421 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29422 " movnti %%eax, 16(%3)\n"
29423 " movnti %%edx, 20(%3)\n"
29424 - "10: movl 24(%4), %%eax\n"
29425 - "51: movl 28(%4), %%edx\n"
29426 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29427 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29428 " movnti %%eax, 24(%3)\n"
29429 " movnti %%edx, 28(%3)\n"
29430 - "11: movl 32(%4), %%eax\n"
29431 - "61: movl 36(%4), %%edx\n"
29432 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29433 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29434 " movnti %%eax, 32(%3)\n"
29435 " movnti %%edx, 36(%3)\n"
29436 - "12: movl 40(%4), %%eax\n"
29437 - "71: movl 44(%4), %%edx\n"
29438 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29439 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29440 " movnti %%eax, 40(%3)\n"
29441 " movnti %%edx, 44(%3)\n"
29442 - "13: movl 48(%4), %%eax\n"
29443 - "81: movl 52(%4), %%edx\n"
29444 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29445 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29446 " movnti %%eax, 48(%3)\n"
29447 " movnti %%edx, 52(%3)\n"
29448 - "14: movl 56(%4), %%eax\n"
29449 - "91: movl 60(%4), %%edx\n"
29450 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29451 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29452 " movnti %%eax, 56(%3)\n"
29453 " movnti %%edx, 60(%3)\n"
29454 " addl $-64, %0\n"
29455 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29456 " shrl $2, %0\n"
29457 " andl $3, %%eax\n"
29458 " cld\n"
29459 - "6: rep; movsl\n"
29460 + "6: rep; "__copyuser_seg" movsl\n"
29461 " movl %%eax,%0\n"
29462 - "7: rep; movsb\n"
29463 + "7: rep; "__copyuser_seg" movsb\n"
29464 "8:\n"
29465 ".section .fixup,\"ax\"\n"
29466 "9: lea 0(%%eax,%0,4),%0\n"
29467 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29468 return size;
29469 }
29470
29471 -static unsigned long __copy_user_intel_nocache(void *to,
29472 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29473 const void __user *from, unsigned long size)
29474 {
29475 int d0, d1;
29476
29477 __asm__ __volatile__(
29478 " .align 2,0x90\n"
29479 - "0: movl 32(%4), %%eax\n"
29480 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29481 " cmpl $67, %0\n"
29482 " jbe 2f\n"
29483 - "1: movl 64(%4), %%eax\n"
29484 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29485 " .align 2,0x90\n"
29486 - "2: movl 0(%4), %%eax\n"
29487 - "21: movl 4(%4), %%edx\n"
29488 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29489 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29490 " movnti %%eax, 0(%3)\n"
29491 " movnti %%edx, 4(%3)\n"
29492 - "3: movl 8(%4), %%eax\n"
29493 - "31: movl 12(%4),%%edx\n"
29494 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29495 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29496 " movnti %%eax, 8(%3)\n"
29497 " movnti %%edx, 12(%3)\n"
29498 - "4: movl 16(%4), %%eax\n"
29499 - "41: movl 20(%4), %%edx\n"
29500 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29501 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29502 " movnti %%eax, 16(%3)\n"
29503 " movnti %%edx, 20(%3)\n"
29504 - "10: movl 24(%4), %%eax\n"
29505 - "51: movl 28(%4), %%edx\n"
29506 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29507 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29508 " movnti %%eax, 24(%3)\n"
29509 " movnti %%edx, 28(%3)\n"
29510 - "11: movl 32(%4), %%eax\n"
29511 - "61: movl 36(%4), %%edx\n"
29512 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29513 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29514 " movnti %%eax, 32(%3)\n"
29515 " movnti %%edx, 36(%3)\n"
29516 - "12: movl 40(%4), %%eax\n"
29517 - "71: movl 44(%4), %%edx\n"
29518 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29519 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29520 " movnti %%eax, 40(%3)\n"
29521 " movnti %%edx, 44(%3)\n"
29522 - "13: movl 48(%4), %%eax\n"
29523 - "81: movl 52(%4), %%edx\n"
29524 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29525 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29526 " movnti %%eax, 48(%3)\n"
29527 " movnti %%edx, 52(%3)\n"
29528 - "14: movl 56(%4), %%eax\n"
29529 - "91: movl 60(%4), %%edx\n"
29530 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29531 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29532 " movnti %%eax, 56(%3)\n"
29533 " movnti %%edx, 60(%3)\n"
29534 " addl $-64, %0\n"
29535 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29536 " shrl $2, %0\n"
29537 " andl $3, %%eax\n"
29538 " cld\n"
29539 - "6: rep; movsl\n"
29540 + "6: rep; "__copyuser_seg" movsl\n"
29541 " movl %%eax,%0\n"
29542 - "7: rep; movsb\n"
29543 + "7: rep; "__copyuser_seg" movsb\n"
29544 "8:\n"
29545 ".section .fixup,\"ax\"\n"
29546 "9: lea 0(%%eax,%0,4),%0\n"
29547 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29548 */
29549 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29550 unsigned long size);
29551 -unsigned long __copy_user_intel(void __user *to, const void *from,
29552 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29553 + unsigned long size);
29554 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29555 unsigned long size);
29556 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29557 const void __user *from, unsigned long size);
29558 #endif /* CONFIG_X86_INTEL_USERCOPY */
29559
29560 /* Generic arbitrary sized copy. */
29561 -#define __copy_user(to, from, size) \
29562 +#define __copy_user(to, from, size, prefix, set, restore) \
29563 do { \
29564 int __d0, __d1, __d2; \
29565 __asm__ __volatile__( \
29566 + set \
29567 " cmp $7,%0\n" \
29568 " jbe 1f\n" \
29569 " movl %1,%0\n" \
29570 " negl %0\n" \
29571 " andl $7,%0\n" \
29572 " subl %0,%3\n" \
29573 - "4: rep; movsb\n" \
29574 + "4: rep; "prefix"movsb\n" \
29575 " movl %3,%0\n" \
29576 " shrl $2,%0\n" \
29577 " andl $3,%3\n" \
29578 " .align 2,0x90\n" \
29579 - "0: rep; movsl\n" \
29580 + "0: rep; "prefix"movsl\n" \
29581 " movl %3,%0\n" \
29582 - "1: rep; movsb\n" \
29583 + "1: rep; "prefix"movsb\n" \
29584 "2:\n" \
29585 + restore \
29586 ".section .fixup,\"ax\"\n" \
29587 "5: addl %3,%0\n" \
29588 " jmp 2b\n" \
29589 @@ -538,14 +650,14 @@ do { \
29590 " negl %0\n" \
29591 " andl $7,%0\n" \
29592 " subl %0,%3\n" \
29593 - "4: rep; movsb\n" \
29594 + "4: rep; "__copyuser_seg"movsb\n" \
29595 " movl %3,%0\n" \
29596 " shrl $2,%0\n" \
29597 " andl $3,%3\n" \
29598 " .align 2,0x90\n" \
29599 - "0: rep; movsl\n" \
29600 + "0: rep; "__copyuser_seg"movsl\n" \
29601 " movl %3,%0\n" \
29602 - "1: rep; movsb\n" \
29603 + "1: rep; "__copyuser_seg"movsb\n" \
29604 "2:\n" \
29605 ".section .fixup,\"ax\"\n" \
29606 "5: addl %3,%0\n" \
29607 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29608 {
29609 stac();
29610 if (movsl_is_ok(to, from, n))
29611 - __copy_user(to, from, n);
29612 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29613 else
29614 - n = __copy_user_intel(to, from, n);
29615 + n = __generic_copy_to_user_intel(to, from, n);
29616 clac();
29617 return n;
29618 }
29619 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29620 {
29621 stac();
29622 if (movsl_is_ok(to, from, n))
29623 - __copy_user(to, from, n);
29624 + __copy_user(to, from, n, __copyuser_seg, "", "");
29625 else
29626 - n = __copy_user_intel((void __user *)to,
29627 - (const void *)from, n);
29628 + n = __generic_copy_from_user_intel(to, from, n);
29629 clac();
29630 return n;
29631 }
29632 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29633 if (n > 64 && cpu_has_xmm2)
29634 n = __copy_user_intel_nocache(to, from, n);
29635 else
29636 - __copy_user(to, from, n);
29637 + __copy_user(to, from, n, __copyuser_seg, "", "");
29638 #else
29639 - __copy_user(to, from, n);
29640 + __copy_user(to, from, n, __copyuser_seg, "", "");
29641 #endif
29642 clac();
29643 return n;
29644 }
29645 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29646
29647 -/**
29648 - * copy_to_user: - Copy a block of data into user space.
29649 - * @to: Destination address, in user space.
29650 - * @from: Source address, in kernel space.
29651 - * @n: Number of bytes to copy.
29652 - *
29653 - * Context: User context only. This function may sleep.
29654 - *
29655 - * Copy data from kernel space to user space.
29656 - *
29657 - * Returns number of bytes that could not be copied.
29658 - * On success, this will be zero.
29659 - */
29660 -unsigned long
29661 -copy_to_user(void __user *to, const void *from, unsigned long n)
29662 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29663 +void __set_fs(mm_segment_t x)
29664 {
29665 - if (access_ok(VERIFY_WRITE, to, n))
29666 - n = __copy_to_user(to, from, n);
29667 - return n;
29668 + switch (x.seg) {
29669 + case 0:
29670 + loadsegment(gs, 0);
29671 + break;
29672 + case TASK_SIZE_MAX:
29673 + loadsegment(gs, __USER_DS);
29674 + break;
29675 + case -1UL:
29676 + loadsegment(gs, __KERNEL_DS);
29677 + break;
29678 + default:
29679 + BUG();
29680 + }
29681 }
29682 -EXPORT_SYMBOL(copy_to_user);
29683 +EXPORT_SYMBOL(__set_fs);
29684
29685 -/**
29686 - * copy_from_user: - Copy a block of data from user space.
29687 - * @to: Destination address, in kernel space.
29688 - * @from: Source address, in user space.
29689 - * @n: Number of bytes to copy.
29690 - *
29691 - * Context: User context only. This function may sleep.
29692 - *
29693 - * Copy data from user space to kernel space.
29694 - *
29695 - * Returns number of bytes that could not be copied.
29696 - * On success, this will be zero.
29697 - *
29698 - * If some data could not be copied, this function will pad the copied
29699 - * data to the requested size using zero bytes.
29700 - */
29701 -unsigned long
29702 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29703 +void set_fs(mm_segment_t x)
29704 {
29705 - if (access_ok(VERIFY_READ, from, n))
29706 - n = __copy_from_user(to, from, n);
29707 - else
29708 - memset(to, 0, n);
29709 - return n;
29710 + current_thread_info()->addr_limit = x;
29711 + __set_fs(x);
29712 }
29713 -EXPORT_SYMBOL(_copy_from_user);
29714 +EXPORT_SYMBOL(set_fs);
29715 +#endif
29716 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29717 index 906fea3..0194a18 100644
29718 --- a/arch/x86/lib/usercopy_64.c
29719 +++ b/arch/x86/lib/usercopy_64.c
29720 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29721 might_fault();
29722 /* no memory constraint because it doesn't change any memory gcc knows
29723 about */
29724 + pax_open_userland();
29725 stac();
29726 asm volatile(
29727 " testq %[size8],%[size8]\n"
29728 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29729 _ASM_EXTABLE(0b,3b)
29730 _ASM_EXTABLE(1b,2b)
29731 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29732 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29733 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29734 [zero] "r" (0UL), [eight] "r" (8UL));
29735 clac();
29736 + pax_close_userland();
29737 return size;
29738 }
29739 EXPORT_SYMBOL(__clear_user);
29740 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29741 }
29742 EXPORT_SYMBOL(clear_user);
29743
29744 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29745 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29746 {
29747 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29748 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29749 - }
29750 - return len;
29751 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29752 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29753 + return len;
29754 }
29755 EXPORT_SYMBOL(copy_in_user);
29756
29757 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29758 * it is not necessary to optimize tail handling.
29759 */
29760 unsigned long
29761 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29762 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29763 {
29764 char c;
29765 unsigned zero_len;
29766
29767 + clac();
29768 + pax_close_userland();
29769 for (; len; --len, to++) {
29770 if (__get_user_nocheck(c, from++, sizeof(char)))
29771 break;
29772 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29773 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29774 if (__put_user_nocheck(c, to++, sizeof(char)))
29775 break;
29776 - clac();
29777 return len;
29778 }
29779 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29780 index 23d8e5f..9ccc13a 100644
29781 --- a/arch/x86/mm/Makefile
29782 +++ b/arch/x86/mm/Makefile
29783 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29784 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29785
29786 obj-$(CONFIG_MEMTEST) += memtest.o
29787 +
29788 +quote:="
29789 +obj-$(CONFIG_X86_64) += uderef_64.o
29790 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29791 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29792 index 903ec1e..c4166b2 100644
29793 --- a/arch/x86/mm/extable.c
29794 +++ b/arch/x86/mm/extable.c
29795 @@ -6,12 +6,24 @@
29796 static inline unsigned long
29797 ex_insn_addr(const struct exception_table_entry *x)
29798 {
29799 - return (unsigned long)&x->insn + x->insn;
29800 + unsigned long reloc = 0;
29801 +
29802 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29803 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29804 +#endif
29805 +
29806 + return (unsigned long)&x->insn + x->insn + reloc;
29807 }
29808 static inline unsigned long
29809 ex_fixup_addr(const struct exception_table_entry *x)
29810 {
29811 - return (unsigned long)&x->fixup + x->fixup;
29812 + unsigned long reloc = 0;
29813 +
29814 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29815 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29816 +#endif
29817 +
29818 + return (unsigned long)&x->fixup + x->fixup + reloc;
29819 }
29820
29821 int fixup_exception(struct pt_regs *regs)
29822 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29823 unsigned long new_ip;
29824
29825 #ifdef CONFIG_PNPBIOS
29826 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29827 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29828 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29829 extern u32 pnp_bios_is_utter_crap;
29830 pnp_bios_is_utter_crap = 1;
29831 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29832 i += 4;
29833 p->fixup -= i;
29834 i += 4;
29835 +
29836 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29837 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29838 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29839 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29840 +#endif
29841 +
29842 }
29843 }
29844
29845 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29846 index 654be4a..a4a3da1 100644
29847 --- a/arch/x86/mm/fault.c
29848 +++ b/arch/x86/mm/fault.c
29849 @@ -14,11 +14,18 @@
29850 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29851 #include <linux/prefetch.h> /* prefetchw */
29852 #include <linux/context_tracking.h> /* exception_enter(), ... */
29853 +#include <linux/unistd.h>
29854 +#include <linux/compiler.h>
29855
29856 #include <asm/traps.h> /* dotraplinkage, ... */
29857 #include <asm/pgalloc.h> /* pgd_*(), ... */
29858 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29859 #include <asm/fixmap.h> /* VSYSCALL_START */
29860 +#include <asm/tlbflush.h>
29861 +
29862 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29863 +#include <asm/stacktrace.h>
29864 +#endif
29865
29866 /*
29867 * Page fault error code bits:
29868 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29869 int ret = 0;
29870
29871 /* kprobe_running() needs smp_processor_id() */
29872 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29873 + if (kprobes_built_in() && !user_mode(regs)) {
29874 preempt_disable();
29875 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29876 ret = 1;
29877 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29878 return !instr_lo || (instr_lo>>1) == 1;
29879 case 0x00:
29880 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29881 - if (probe_kernel_address(instr, opcode))
29882 + if (user_mode(regs)) {
29883 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29884 + return 0;
29885 + } else if (probe_kernel_address(instr, opcode))
29886 return 0;
29887
29888 *prefetch = (instr_lo == 0xF) &&
29889 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29890 while (instr < max_instr) {
29891 unsigned char opcode;
29892
29893 - if (probe_kernel_address(instr, opcode))
29894 + if (user_mode(regs)) {
29895 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29896 + break;
29897 + } else if (probe_kernel_address(instr, opcode))
29898 break;
29899
29900 instr++;
29901 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29902 force_sig_info(si_signo, &info, tsk);
29903 }
29904
29905 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29906 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29907 +#endif
29908 +
29909 +#ifdef CONFIG_PAX_EMUTRAMP
29910 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29911 +#endif
29912 +
29913 +#ifdef CONFIG_PAX_PAGEEXEC
29914 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29915 +{
29916 + pgd_t *pgd;
29917 + pud_t *pud;
29918 + pmd_t *pmd;
29919 +
29920 + pgd = pgd_offset(mm, address);
29921 + if (!pgd_present(*pgd))
29922 + return NULL;
29923 + pud = pud_offset(pgd, address);
29924 + if (!pud_present(*pud))
29925 + return NULL;
29926 + pmd = pmd_offset(pud, address);
29927 + if (!pmd_present(*pmd))
29928 + return NULL;
29929 + return pmd;
29930 +}
29931 +#endif
29932 +
29933 DEFINE_SPINLOCK(pgd_lock);
29934 LIST_HEAD(pgd_list);
29935
29936 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29937 for (address = VMALLOC_START & PMD_MASK;
29938 address >= TASK_SIZE && address < FIXADDR_TOP;
29939 address += PMD_SIZE) {
29940 +
29941 +#ifdef CONFIG_PAX_PER_CPU_PGD
29942 + unsigned long cpu;
29943 +#else
29944 struct page *page;
29945 +#endif
29946
29947 spin_lock(&pgd_lock);
29948 +
29949 +#ifdef CONFIG_PAX_PER_CPU_PGD
29950 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29951 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29952 + pmd_t *ret;
29953 +
29954 + ret = vmalloc_sync_one(pgd, address);
29955 + if (!ret)
29956 + break;
29957 + pgd = get_cpu_pgd(cpu, kernel);
29958 +#else
29959 list_for_each_entry(page, &pgd_list, lru) {
29960 + pgd_t *pgd;
29961 spinlock_t *pgt_lock;
29962 pmd_t *ret;
29963
29964 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29965 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29966
29967 spin_lock(pgt_lock);
29968 - ret = vmalloc_sync_one(page_address(page), address);
29969 + pgd = page_address(page);
29970 +#endif
29971 +
29972 + ret = vmalloc_sync_one(pgd, address);
29973 +
29974 +#ifndef CONFIG_PAX_PER_CPU_PGD
29975 spin_unlock(pgt_lock);
29976 +#endif
29977
29978 if (!ret)
29979 break;
29980 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29981 * an interrupt in the middle of a task switch..
29982 */
29983 pgd_paddr = read_cr3();
29984 +
29985 +#ifdef CONFIG_PAX_PER_CPU_PGD
29986 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29987 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29988 +#endif
29989 +
29990 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29991 if (!pmd_k)
29992 return -1;
29993 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29994 * happen within a race in page table update. In the later
29995 * case just flush:
29996 */
29997 - pgd = pgd_offset(current->active_mm, address);
29998 +
29999 pgd_ref = pgd_offset_k(address);
30000 if (pgd_none(*pgd_ref))
30001 return -1;
30002
30003 +#ifdef CONFIG_PAX_PER_CPU_PGD
30004 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30005 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30006 + if (pgd_none(*pgd)) {
30007 + set_pgd(pgd, *pgd_ref);
30008 + arch_flush_lazy_mmu_mode();
30009 + } else {
30010 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30011 + }
30012 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30013 +#else
30014 + pgd = pgd_offset(current->active_mm, address);
30015 +#endif
30016 +
30017 if (pgd_none(*pgd)) {
30018 set_pgd(pgd, *pgd_ref);
30019 arch_flush_lazy_mmu_mode();
30020 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30021 static int is_errata100(struct pt_regs *regs, unsigned long address)
30022 {
30023 #ifdef CONFIG_X86_64
30024 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30025 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30026 return 1;
30027 #endif
30028 return 0;
30029 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30030 }
30031
30032 static const char nx_warning[] = KERN_CRIT
30033 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30034 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30035
30036 static void
30037 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30038 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30039 if (!oops_may_print())
30040 return;
30041
30042 - if (error_code & PF_INSTR) {
30043 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30044 unsigned int level;
30045
30046 pte_t *pte = lookup_address(address, &level);
30047
30048 if (pte && pte_present(*pte) && !pte_exec(*pte))
30049 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30050 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30051 }
30052
30053 +#ifdef CONFIG_PAX_KERNEXEC
30054 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30055 + if (current->signal->curr_ip)
30056 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30057 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30058 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30059 + else
30060 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30061 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30062 + }
30063 +#endif
30064 +
30065 printk(KERN_ALERT "BUG: unable to handle kernel ");
30066 if (address < PAGE_SIZE)
30067 printk(KERN_CONT "NULL pointer dereference");
30068 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30069 return;
30070 }
30071 #endif
30072 +
30073 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30074 + if (pax_is_fetch_fault(regs, error_code, address)) {
30075 +
30076 +#ifdef CONFIG_PAX_EMUTRAMP
30077 + switch (pax_handle_fetch_fault(regs)) {
30078 + case 2:
30079 + return;
30080 + }
30081 +#endif
30082 +
30083 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30084 + do_group_exit(SIGKILL);
30085 + }
30086 +#endif
30087 +
30088 /* Kernel addresses are always protection faults: */
30089 if (address >= TASK_SIZE)
30090 error_code |= PF_PROT;
30091 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30092 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30093 printk(KERN_ERR
30094 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30095 - tsk->comm, tsk->pid, address);
30096 + tsk->comm, task_pid_nr(tsk), address);
30097 code = BUS_MCEERR_AR;
30098 }
30099 #endif
30100 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30101 return 1;
30102 }
30103
30104 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30105 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30106 +{
30107 + pte_t *pte;
30108 + pmd_t *pmd;
30109 + spinlock_t *ptl;
30110 + unsigned char pte_mask;
30111 +
30112 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30113 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30114 + return 0;
30115 +
30116 + /* PaX: it's our fault, let's handle it if we can */
30117 +
30118 + /* PaX: take a look at read faults before acquiring any locks */
30119 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30120 + /* instruction fetch attempt from a protected page in user mode */
30121 + up_read(&mm->mmap_sem);
30122 +
30123 +#ifdef CONFIG_PAX_EMUTRAMP
30124 + switch (pax_handle_fetch_fault(regs)) {
30125 + case 2:
30126 + return 1;
30127 + }
30128 +#endif
30129 +
30130 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30131 + do_group_exit(SIGKILL);
30132 + }
30133 +
30134 + pmd = pax_get_pmd(mm, address);
30135 + if (unlikely(!pmd))
30136 + return 0;
30137 +
30138 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30139 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30140 + pte_unmap_unlock(pte, ptl);
30141 + return 0;
30142 + }
30143 +
30144 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30145 + /* write attempt to a protected page in user mode */
30146 + pte_unmap_unlock(pte, ptl);
30147 + return 0;
30148 + }
30149 +
30150 +#ifdef CONFIG_SMP
30151 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30152 +#else
30153 + if (likely(address > get_limit(regs->cs)))
30154 +#endif
30155 + {
30156 + set_pte(pte, pte_mkread(*pte));
30157 + __flush_tlb_one(address);
30158 + pte_unmap_unlock(pte, ptl);
30159 + up_read(&mm->mmap_sem);
30160 + return 1;
30161 + }
30162 +
30163 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30164 +
30165 + /*
30166 + * PaX: fill DTLB with user rights and retry
30167 + */
30168 + __asm__ __volatile__ (
30169 + "orb %2,(%1)\n"
30170 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30171 +/*
30172 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30173 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30174 + * page fault when examined during a TLB load attempt. this is true not only
30175 + * for PTEs holding a non-present entry but also present entries that will
30176 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30177 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30178 + * for our target pages since their PTEs are simply not in the TLBs at all.
30179 +
30180 + * the best thing in omitting it is that we gain around 15-20% speed in the
30181 + * fast path of the page fault handler and can get rid of tracing since we
30182 + * can no longer flush unintended entries.
30183 + */
30184 + "invlpg (%0)\n"
30185 +#endif
30186 + __copyuser_seg"testb $0,(%0)\n"
30187 + "xorb %3,(%1)\n"
30188 + :
30189 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30190 + : "memory", "cc");
30191 + pte_unmap_unlock(pte, ptl);
30192 + up_read(&mm->mmap_sem);
30193 + return 1;
30194 +}
30195 +#endif
30196 +
30197 /*
30198 * Handle a spurious fault caused by a stale TLB entry.
30199 *
30200 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30201 static inline int
30202 access_error(unsigned long error_code, struct vm_area_struct *vma)
30203 {
30204 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30205 + return 1;
30206 +
30207 if (error_code & PF_WRITE) {
30208 /* write, present and write, not present: */
30209 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30210 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30211 if (error_code & PF_USER)
30212 return false;
30213
30214 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30215 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30216 return false;
30217
30218 return true;
30219 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30220 {
30221 struct vm_area_struct *vma;
30222 struct task_struct *tsk;
30223 - unsigned long address;
30224 struct mm_struct *mm;
30225 int fault;
30226 int write = error_code & PF_WRITE;
30227 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30228 (write ? FAULT_FLAG_WRITE : 0);
30229
30230 - tsk = current;
30231 - mm = tsk->mm;
30232 -
30233 /* Get the faulting address: */
30234 - address = read_cr2();
30235 + unsigned long address = read_cr2();
30236 +
30237 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30238 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30239 + if (!search_exception_tables(regs->ip)) {
30240 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30241 + bad_area_nosemaphore(regs, error_code, address);
30242 + return;
30243 + }
30244 + if (address < pax_user_shadow_base) {
30245 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30246 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30247 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30248 + } else
30249 + address -= pax_user_shadow_base;
30250 + }
30251 +#endif
30252 +
30253 + tsk = current;
30254 + mm = tsk->mm;
30255
30256 /*
30257 * Detect and handle instructions that would cause a page fault for
30258 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30259 * User-mode registers count as a user access even for any
30260 * potential system fault or CPU buglet:
30261 */
30262 - if (user_mode_vm(regs)) {
30263 + if (user_mode(regs)) {
30264 local_irq_enable();
30265 error_code |= PF_USER;
30266 } else {
30267 @@ -1142,6 +1365,11 @@ retry:
30268 might_sleep();
30269 }
30270
30271 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30272 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30273 + return;
30274 +#endif
30275 +
30276 vma = find_vma(mm, address);
30277 if (unlikely(!vma)) {
30278 bad_area(regs, error_code, address);
30279 @@ -1153,18 +1381,24 @@ retry:
30280 bad_area(regs, error_code, address);
30281 return;
30282 }
30283 - if (error_code & PF_USER) {
30284 - /*
30285 - * Accessing the stack below %sp is always a bug.
30286 - * The large cushion allows instructions like enter
30287 - * and pusha to work. ("enter $65535, $31" pushes
30288 - * 32 pointers and then decrements %sp by 65535.)
30289 - */
30290 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30291 - bad_area(regs, error_code, address);
30292 - return;
30293 - }
30294 + /*
30295 + * Accessing the stack below %sp is always a bug.
30296 + * The large cushion allows instructions like enter
30297 + * and pusha to work. ("enter $65535, $31" pushes
30298 + * 32 pointers and then decrements %sp by 65535.)
30299 + */
30300 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30301 + bad_area(regs, error_code, address);
30302 + return;
30303 }
30304 +
30305 +#ifdef CONFIG_PAX_SEGMEXEC
30306 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30307 + bad_area(regs, error_code, address);
30308 + return;
30309 + }
30310 +#endif
30311 +
30312 if (unlikely(expand_stack(vma, address))) {
30313 bad_area(regs, error_code, address);
30314 return;
30315 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30316 __do_page_fault(regs, error_code);
30317 exception_exit(prev_state);
30318 }
30319 +
30320 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30321 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30322 +{
30323 + struct mm_struct *mm = current->mm;
30324 + unsigned long ip = regs->ip;
30325 +
30326 + if (v8086_mode(regs))
30327 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30328 +
30329 +#ifdef CONFIG_PAX_PAGEEXEC
30330 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30331 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30332 + return true;
30333 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30334 + return true;
30335 + return false;
30336 + }
30337 +#endif
30338 +
30339 +#ifdef CONFIG_PAX_SEGMEXEC
30340 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30341 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30342 + return true;
30343 + return false;
30344 + }
30345 +#endif
30346 +
30347 + return false;
30348 +}
30349 +#endif
30350 +
30351 +#ifdef CONFIG_PAX_EMUTRAMP
30352 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30353 +{
30354 + int err;
30355 +
30356 + do { /* PaX: libffi trampoline emulation */
30357 + unsigned char mov, jmp;
30358 + unsigned int addr1, addr2;
30359 +
30360 +#ifdef CONFIG_X86_64
30361 + if ((regs->ip + 9) >> 32)
30362 + break;
30363 +#endif
30364 +
30365 + err = get_user(mov, (unsigned char __user *)regs->ip);
30366 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30367 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30368 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30369 +
30370 + if (err)
30371 + break;
30372 +
30373 + if (mov == 0xB8 && jmp == 0xE9) {
30374 + regs->ax = addr1;
30375 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30376 + return 2;
30377 + }
30378 + } while (0);
30379 +
30380 + do { /* PaX: gcc trampoline emulation #1 */
30381 + unsigned char mov1, mov2;
30382 + unsigned short jmp;
30383 + unsigned int addr1, addr2;
30384 +
30385 +#ifdef CONFIG_X86_64
30386 + if ((regs->ip + 11) >> 32)
30387 + break;
30388 +#endif
30389 +
30390 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30391 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30392 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30393 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30394 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30395 +
30396 + if (err)
30397 + break;
30398 +
30399 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30400 + regs->cx = addr1;
30401 + regs->ax = addr2;
30402 + regs->ip = addr2;
30403 + return 2;
30404 + }
30405 + } while (0);
30406 +
30407 + do { /* PaX: gcc trampoline emulation #2 */
30408 + unsigned char mov, jmp;
30409 + unsigned int addr1, addr2;
30410 +
30411 +#ifdef CONFIG_X86_64
30412 + if ((regs->ip + 9) >> 32)
30413 + break;
30414 +#endif
30415 +
30416 + err = get_user(mov, (unsigned char __user *)regs->ip);
30417 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30418 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30419 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30420 +
30421 + if (err)
30422 + break;
30423 +
30424 + if (mov == 0xB9 && jmp == 0xE9) {
30425 + regs->cx = addr1;
30426 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30427 + return 2;
30428 + }
30429 + } while (0);
30430 +
30431 + return 1; /* PaX in action */
30432 +}
30433 +
30434 +#ifdef CONFIG_X86_64
30435 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30436 +{
30437 + int err;
30438 +
30439 + do { /* PaX: libffi trampoline emulation */
30440 + unsigned short mov1, mov2, jmp1;
30441 + unsigned char stcclc, jmp2;
30442 + unsigned long addr1, addr2;
30443 +
30444 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30445 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30446 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30447 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30448 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30449 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30450 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30451 +
30452 + if (err)
30453 + break;
30454 +
30455 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30456 + regs->r11 = addr1;
30457 + regs->r10 = addr2;
30458 + if (stcclc == 0xF8)
30459 + regs->flags &= ~X86_EFLAGS_CF;
30460 + else
30461 + regs->flags |= X86_EFLAGS_CF;
30462 + regs->ip = addr1;
30463 + return 2;
30464 + }
30465 + } while (0);
30466 +
30467 + do { /* PaX: gcc trampoline emulation #1 */
30468 + unsigned short mov1, mov2, jmp1;
30469 + unsigned char jmp2;
30470 + unsigned int addr1;
30471 + unsigned long addr2;
30472 +
30473 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30474 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30475 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30476 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30477 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30478 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30479 +
30480 + if (err)
30481 + break;
30482 +
30483 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30484 + regs->r11 = addr1;
30485 + regs->r10 = addr2;
30486 + regs->ip = addr1;
30487 + return 2;
30488 + }
30489 + } while (0);
30490 +
30491 + do { /* PaX: gcc trampoline emulation #2 */
30492 + unsigned short mov1, mov2, jmp1;
30493 + unsigned char jmp2;
30494 + unsigned long addr1, addr2;
30495 +
30496 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30497 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30498 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30499 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30500 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30501 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30502 +
30503 + if (err)
30504 + break;
30505 +
30506 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30507 + regs->r11 = addr1;
30508 + regs->r10 = addr2;
30509 + regs->ip = addr1;
30510 + return 2;
30511 + }
30512 + } while (0);
30513 +
30514 + return 1; /* PaX in action */
30515 +}
30516 +#endif
30517 +
30518 +/*
30519 + * PaX: decide what to do with offenders (regs->ip = fault address)
30520 + *
30521 + * returns 1 when task should be killed
30522 + * 2 when gcc trampoline was detected
30523 + */
30524 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30525 +{
30526 + if (v8086_mode(regs))
30527 + return 1;
30528 +
30529 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30530 + return 1;
30531 +
30532 +#ifdef CONFIG_X86_32
30533 + return pax_handle_fetch_fault_32(regs);
30534 +#else
30535 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30536 + return pax_handle_fetch_fault_32(regs);
30537 + else
30538 + return pax_handle_fetch_fault_64(regs);
30539 +#endif
30540 +}
30541 +#endif
30542 +
30543 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30544 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30545 +{
30546 + long i;
30547 +
30548 + printk(KERN_ERR "PAX: bytes at PC: ");
30549 + for (i = 0; i < 20; i++) {
30550 + unsigned char c;
30551 + if (get_user(c, (unsigned char __force_user *)pc+i))
30552 + printk(KERN_CONT "?? ");
30553 + else
30554 + printk(KERN_CONT "%02x ", c);
30555 + }
30556 + printk("\n");
30557 +
30558 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30559 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30560 + unsigned long c;
30561 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30562 +#ifdef CONFIG_X86_32
30563 + printk(KERN_CONT "???????? ");
30564 +#else
30565 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30566 + printk(KERN_CONT "???????? ???????? ");
30567 + else
30568 + printk(KERN_CONT "???????????????? ");
30569 +#endif
30570 + } else {
30571 +#ifdef CONFIG_X86_64
30572 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30573 + printk(KERN_CONT "%08x ", (unsigned int)c);
30574 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30575 + } else
30576 +#endif
30577 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30578 + }
30579 + }
30580 + printk("\n");
30581 +}
30582 +#endif
30583 +
30584 +/**
30585 + * probe_kernel_write(): safely attempt to write to a location
30586 + * @dst: address to write to
30587 + * @src: pointer to the data that shall be written
30588 + * @size: size of the data chunk
30589 + *
30590 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30591 + * happens, handle that and return -EFAULT.
30592 + */
30593 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30594 +{
30595 + long ret;
30596 + mm_segment_t old_fs = get_fs();
30597 +
30598 + set_fs(KERNEL_DS);
30599 + pagefault_disable();
30600 + pax_open_kernel();
30601 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30602 + pax_close_kernel();
30603 + pagefault_enable();
30604 + set_fs(old_fs);
30605 +
30606 + return ret ? -EFAULT : 0;
30607 +}
30608 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30609 index dd74e46..7d26398 100644
30610 --- a/arch/x86/mm/gup.c
30611 +++ b/arch/x86/mm/gup.c
30612 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30613 addr = start;
30614 len = (unsigned long) nr_pages << PAGE_SHIFT;
30615 end = start + len;
30616 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30617 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30618 (void __user *)start, len)))
30619 return 0;
30620
30621 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30622 index 4500142..53a363c 100644
30623 --- a/arch/x86/mm/highmem_32.c
30624 +++ b/arch/x86/mm/highmem_32.c
30625 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30626 idx = type + KM_TYPE_NR*smp_processor_id();
30627 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30628 BUG_ON(!pte_none(*(kmap_pte-idx)));
30629 +
30630 + pax_open_kernel();
30631 set_pte(kmap_pte-idx, mk_pte(page, prot));
30632 + pax_close_kernel();
30633 +
30634 arch_flush_lazy_mmu_mode();
30635
30636 return (void *)vaddr;
30637 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30638 index 7e73e8c..11d3b86 100644
30639 --- a/arch/x86/mm/hugetlbpage.c
30640 +++ b/arch/x86/mm/hugetlbpage.c
30641 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30642 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30643 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30644 unsigned long addr, unsigned long len,
30645 - unsigned long pgoff, unsigned long flags)
30646 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30647 {
30648 struct hstate *h = hstate_file(file);
30649 struct vm_unmapped_area_info info;
30650 -
30651 +
30652 info.flags = 0;
30653 info.length = len;
30654 info.low_limit = TASK_UNMAPPED_BASE;
30655 +
30656 +#ifdef CONFIG_PAX_RANDMMAP
30657 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30658 + info.low_limit += current->mm->delta_mmap;
30659 +#endif
30660 +
30661 info.high_limit = TASK_SIZE;
30662 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30663 info.align_offset = 0;
30664 + info.threadstack_offset = offset;
30665 return vm_unmapped_area(&info);
30666 }
30667
30668 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30669 unsigned long addr0, unsigned long len,
30670 - unsigned long pgoff, unsigned long flags)
30671 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30672 {
30673 struct hstate *h = hstate_file(file);
30674 struct vm_unmapped_area_info info;
30675 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30676 info.high_limit = current->mm->mmap_base;
30677 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30678 info.align_offset = 0;
30679 + info.threadstack_offset = offset;
30680 addr = vm_unmapped_area(&info);
30681
30682 /*
30683 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30684 VM_BUG_ON(addr != -ENOMEM);
30685 info.flags = 0;
30686 info.low_limit = TASK_UNMAPPED_BASE;
30687 +
30688 +#ifdef CONFIG_PAX_RANDMMAP
30689 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30690 + info.low_limit += current->mm->delta_mmap;
30691 +#endif
30692 +
30693 info.high_limit = TASK_SIZE;
30694 addr = vm_unmapped_area(&info);
30695 }
30696 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30697 struct hstate *h = hstate_file(file);
30698 struct mm_struct *mm = current->mm;
30699 struct vm_area_struct *vma;
30700 + unsigned long pax_task_size = TASK_SIZE;
30701 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30702
30703 if (len & ~huge_page_mask(h))
30704 return -EINVAL;
30705 - if (len > TASK_SIZE)
30706 +
30707 +#ifdef CONFIG_PAX_SEGMEXEC
30708 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30709 + pax_task_size = SEGMEXEC_TASK_SIZE;
30710 +#endif
30711 +
30712 + pax_task_size -= PAGE_SIZE;
30713 +
30714 + if (len > pax_task_size)
30715 return -ENOMEM;
30716
30717 if (flags & MAP_FIXED) {
30718 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30719 return addr;
30720 }
30721
30722 +#ifdef CONFIG_PAX_RANDMMAP
30723 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30724 +#endif
30725 +
30726 if (addr) {
30727 addr = ALIGN(addr, huge_page_size(h));
30728 vma = find_vma(mm, addr);
30729 - if (TASK_SIZE - len >= addr &&
30730 - (!vma || addr + len <= vma->vm_start))
30731 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30732 return addr;
30733 }
30734 if (mm->get_unmapped_area == arch_get_unmapped_area)
30735 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30736 - pgoff, flags);
30737 + pgoff, flags, offset);
30738 else
30739 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30740 - pgoff, flags);
30741 + pgoff, flags, offset);
30742 }
30743
30744 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30745 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30746 index 04664cd..dae6e5d 100644
30747 --- a/arch/x86/mm/init.c
30748 +++ b/arch/x86/mm/init.c
30749 @@ -4,6 +4,7 @@
30750 #include <linux/swap.h>
30751 #include <linux/memblock.h>
30752 #include <linux/bootmem.h> /* for max_low_pfn */
30753 +#include <linux/tboot.h>
30754
30755 #include <asm/cacheflush.h>
30756 #include <asm/e820.h>
30757 @@ -17,6 +18,8 @@
30758 #include <asm/proto.h>
30759 #include <asm/dma.h> /* for MAX_DMA_PFN */
30760 #include <asm/microcode.h>
30761 +#include <asm/desc.h>
30762 +#include <asm/bios_ebda.h>
30763
30764 #include "mm_internal.h"
30765
30766 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30767 early_ioremap_page_table_range_init();
30768 #endif
30769
30770 +#ifdef CONFIG_PAX_PER_CPU_PGD
30771 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30772 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30773 + KERNEL_PGD_PTRS);
30774 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30775 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30776 + KERNEL_PGD_PTRS);
30777 + load_cr3(get_cpu_pgd(0, kernel));
30778 +#else
30779 load_cr3(swapper_pg_dir);
30780 +#endif
30781 +
30782 __flush_tlb_all();
30783
30784 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30785 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30786 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30787 * mmio resources as well as potential bios/acpi data regions.
30788 */
30789 +
30790 +#ifdef CONFIG_GRKERNSEC_KMEM
30791 +static unsigned int ebda_start __read_only;
30792 +static unsigned int ebda_end __read_only;
30793 +#endif
30794 +
30795 int devmem_is_allowed(unsigned long pagenr)
30796 {
30797 - if (pagenr < 256)
30798 +#ifdef CONFIG_GRKERNSEC_KMEM
30799 + /* allow BDA */
30800 + if (!pagenr)
30801 return 1;
30802 + /* allow EBDA */
30803 + if (pagenr >= ebda_start && pagenr < ebda_end)
30804 + return 1;
30805 + /* if tboot is in use, allow access to its hardcoded serial log range */
30806 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30807 + return 1;
30808 +#else
30809 + if (!pagenr)
30810 + return 1;
30811 +#ifdef CONFIG_VM86
30812 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30813 + return 1;
30814 +#endif
30815 +#endif
30816 +
30817 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30818 + return 1;
30819 +#ifdef CONFIG_GRKERNSEC_KMEM
30820 + /* throw out everything else below 1MB */
30821 + if (pagenr <= 256)
30822 + return 0;
30823 +#endif
30824 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30825 return 0;
30826 if (!page_is_ram(pagenr))
30827 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30828 #endif
30829 }
30830
30831 +#ifdef CONFIG_GRKERNSEC_KMEM
30832 +static inline void gr_init_ebda(void)
30833 +{
30834 + unsigned int ebda_addr;
30835 + unsigned int ebda_size = 0;
30836 +
30837 + ebda_addr = get_bios_ebda();
30838 + if (ebda_addr) {
30839 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30840 + ebda_size <<= 10;
30841 + }
30842 + if (ebda_addr && ebda_size) {
30843 + ebda_start = ebda_addr >> PAGE_SHIFT;
30844 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30845 + } else {
30846 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30847 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30848 + }
30849 +}
30850 +#else
30851 +static inline void gr_init_ebda(void) { }
30852 +#endif
30853 +
30854 void free_initmem(void)
30855 {
30856 +#ifdef CONFIG_PAX_KERNEXEC
30857 +#ifdef CONFIG_X86_32
30858 + /* PaX: limit KERNEL_CS to actual size */
30859 + unsigned long addr, limit;
30860 + struct desc_struct d;
30861 + int cpu;
30862 +#else
30863 + pgd_t *pgd;
30864 + pud_t *pud;
30865 + pmd_t *pmd;
30866 + unsigned long addr, end;
30867 +#endif
30868 +#endif
30869 +
30870 + gr_init_ebda();
30871 +
30872 +#ifdef CONFIG_PAX_KERNEXEC
30873 +#ifdef CONFIG_X86_32
30874 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30875 + limit = (limit - 1UL) >> PAGE_SHIFT;
30876 +
30877 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30878 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30879 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30880 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30881 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30882 + }
30883 +
30884 + /* PaX: make KERNEL_CS read-only */
30885 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30886 + if (!paravirt_enabled())
30887 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30888 +/*
30889 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30890 + pgd = pgd_offset_k(addr);
30891 + pud = pud_offset(pgd, addr);
30892 + pmd = pmd_offset(pud, addr);
30893 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30894 + }
30895 +*/
30896 +#ifdef CONFIG_X86_PAE
30897 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30898 +/*
30899 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30900 + pgd = pgd_offset_k(addr);
30901 + pud = pud_offset(pgd, addr);
30902 + pmd = pmd_offset(pud, addr);
30903 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30904 + }
30905 +*/
30906 +#endif
30907 +
30908 +#ifdef CONFIG_MODULES
30909 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30910 +#endif
30911 +
30912 +#else
30913 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30914 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30915 + pgd = pgd_offset_k(addr);
30916 + pud = pud_offset(pgd, addr);
30917 + pmd = pmd_offset(pud, addr);
30918 + if (!pmd_present(*pmd))
30919 + continue;
30920 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30921 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30922 + else
30923 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30924 + }
30925 +
30926 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30927 + end = addr + KERNEL_IMAGE_SIZE;
30928 + for (; addr < end; addr += PMD_SIZE) {
30929 + pgd = pgd_offset_k(addr);
30930 + pud = pud_offset(pgd, addr);
30931 + pmd = pmd_offset(pud, addr);
30932 + if (!pmd_present(*pmd))
30933 + continue;
30934 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30935 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30936 + }
30937 +#endif
30938 +
30939 + flush_tlb_all();
30940 +#endif
30941 +
30942 free_init_pages("unused kernel",
30943 (unsigned long)(&__init_begin),
30944 (unsigned long)(&__init_end));
30945 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30946 index 4287f1f..3b99c71 100644
30947 --- a/arch/x86/mm/init_32.c
30948 +++ b/arch/x86/mm/init_32.c
30949 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30950 bool __read_mostly __vmalloc_start_set = false;
30951
30952 /*
30953 - * Creates a middle page table and puts a pointer to it in the
30954 - * given global directory entry. This only returns the gd entry
30955 - * in non-PAE compilation mode, since the middle layer is folded.
30956 - */
30957 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30958 -{
30959 - pud_t *pud;
30960 - pmd_t *pmd_table;
30961 -
30962 -#ifdef CONFIG_X86_PAE
30963 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30964 - pmd_table = (pmd_t *)alloc_low_page();
30965 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30966 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30967 - pud = pud_offset(pgd, 0);
30968 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30969 -
30970 - return pmd_table;
30971 - }
30972 -#endif
30973 - pud = pud_offset(pgd, 0);
30974 - pmd_table = pmd_offset(pud, 0);
30975 -
30976 - return pmd_table;
30977 -}
30978 -
30979 -/*
30980 * Create a page table and place a pointer to it in a middle page
30981 * directory entry:
30982 */
30983 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30984 pte_t *page_table = (pte_t *)alloc_low_page();
30985
30986 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30987 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30988 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30989 +#else
30990 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30991 +#endif
30992 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30993 }
30994
30995 return pte_offset_kernel(pmd, 0);
30996 }
30997
30998 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30999 +{
31000 + pud_t *pud;
31001 + pmd_t *pmd_table;
31002 +
31003 + pud = pud_offset(pgd, 0);
31004 + pmd_table = pmd_offset(pud, 0);
31005 +
31006 + return pmd_table;
31007 +}
31008 +
31009 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31010 {
31011 int pgd_idx = pgd_index(vaddr);
31012 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31013 int pgd_idx, pmd_idx;
31014 unsigned long vaddr;
31015 pgd_t *pgd;
31016 + pud_t *pud;
31017 pmd_t *pmd;
31018 pte_t *pte = NULL;
31019 unsigned long count = page_table_range_init_count(start, end);
31020 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31021 pgd = pgd_base + pgd_idx;
31022
31023 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31024 - pmd = one_md_table_init(pgd);
31025 - pmd = pmd + pmd_index(vaddr);
31026 + pud = pud_offset(pgd, vaddr);
31027 + pmd = pmd_offset(pud, vaddr);
31028 +
31029 +#ifdef CONFIG_X86_PAE
31030 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31031 +#endif
31032 +
31033 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31034 pmd++, pmd_idx++) {
31035 pte = page_table_kmap_check(one_page_table_init(pmd),
31036 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31037 }
31038 }
31039
31040 -static inline int is_kernel_text(unsigned long addr)
31041 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31042 {
31043 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31044 - return 1;
31045 - return 0;
31046 + if ((start > ktla_ktva((unsigned long)_etext) ||
31047 + end <= ktla_ktva((unsigned long)_stext)) &&
31048 + (start > ktla_ktva((unsigned long)_einittext) ||
31049 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31050 +
31051 +#ifdef CONFIG_ACPI_SLEEP
31052 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31053 +#endif
31054 +
31055 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31056 + return 0;
31057 + return 1;
31058 }
31059
31060 /*
31061 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31062 unsigned long last_map_addr = end;
31063 unsigned long start_pfn, end_pfn;
31064 pgd_t *pgd_base = swapper_pg_dir;
31065 - int pgd_idx, pmd_idx, pte_ofs;
31066 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31067 unsigned long pfn;
31068 pgd_t *pgd;
31069 + pud_t *pud;
31070 pmd_t *pmd;
31071 pte_t *pte;
31072 unsigned pages_2m, pages_4k;
31073 @@ -291,8 +295,13 @@ repeat:
31074 pfn = start_pfn;
31075 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31076 pgd = pgd_base + pgd_idx;
31077 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31078 - pmd = one_md_table_init(pgd);
31079 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31080 + pud = pud_offset(pgd, 0);
31081 + pmd = pmd_offset(pud, 0);
31082 +
31083 +#ifdef CONFIG_X86_PAE
31084 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31085 +#endif
31086
31087 if (pfn >= end_pfn)
31088 continue;
31089 @@ -304,14 +313,13 @@ repeat:
31090 #endif
31091 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31092 pmd++, pmd_idx++) {
31093 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31094 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31095
31096 /*
31097 * Map with big pages if possible, otherwise
31098 * create normal page tables:
31099 */
31100 if (use_pse) {
31101 - unsigned int addr2;
31102 pgprot_t prot = PAGE_KERNEL_LARGE;
31103 /*
31104 * first pass will use the same initial
31105 @@ -322,11 +330,7 @@ repeat:
31106 _PAGE_PSE);
31107
31108 pfn &= PMD_MASK >> PAGE_SHIFT;
31109 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31110 - PAGE_OFFSET + PAGE_SIZE-1;
31111 -
31112 - if (is_kernel_text(addr) ||
31113 - is_kernel_text(addr2))
31114 + if (is_kernel_text(address, address + PMD_SIZE))
31115 prot = PAGE_KERNEL_LARGE_EXEC;
31116
31117 pages_2m++;
31118 @@ -343,7 +347,7 @@ repeat:
31119 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31120 pte += pte_ofs;
31121 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31122 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31123 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31124 pgprot_t prot = PAGE_KERNEL;
31125 /*
31126 * first pass will use the same initial
31127 @@ -351,7 +355,7 @@ repeat:
31128 */
31129 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31130
31131 - if (is_kernel_text(addr))
31132 + if (is_kernel_text(address, address + PAGE_SIZE))
31133 prot = PAGE_KERNEL_EXEC;
31134
31135 pages_4k++;
31136 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31137
31138 pud = pud_offset(pgd, va);
31139 pmd = pmd_offset(pud, va);
31140 - if (!pmd_present(*pmd))
31141 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31142 break;
31143
31144 /* should not be large page here */
31145 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31146
31147 static void __init pagetable_init(void)
31148 {
31149 - pgd_t *pgd_base = swapper_pg_dir;
31150 -
31151 - permanent_kmaps_init(pgd_base);
31152 + permanent_kmaps_init(swapper_pg_dir);
31153 }
31154
31155 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31156 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31157 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31158
31159 /* user-defined highmem size */
31160 @@ -787,10 +789,10 @@ void __init mem_init(void)
31161 ((unsigned long)&__init_end -
31162 (unsigned long)&__init_begin) >> 10,
31163
31164 - (unsigned long)&_etext, (unsigned long)&_edata,
31165 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31166 + (unsigned long)&_sdata, (unsigned long)&_edata,
31167 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31168
31169 - (unsigned long)&_text, (unsigned long)&_etext,
31170 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31171 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31172
31173 /*
31174 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31175 if (!kernel_set_to_readonly)
31176 return;
31177
31178 + start = ktla_ktva(start);
31179 pr_debug("Set kernel text: %lx - %lx for read write\n",
31180 start, start+size);
31181
31182 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31183 if (!kernel_set_to_readonly)
31184 return;
31185
31186 + start = ktla_ktva(start);
31187 pr_debug("Set kernel text: %lx - %lx for read only\n",
31188 start, start+size);
31189
31190 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31191 unsigned long start = PFN_ALIGN(_text);
31192 unsigned long size = PFN_ALIGN(_etext) - start;
31193
31194 + start = ktla_ktva(start);
31195 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31196 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31197 size >> 10);
31198 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31199 index 104d56a..62ba13f 100644
31200 --- a/arch/x86/mm/init_64.c
31201 +++ b/arch/x86/mm/init_64.c
31202 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31203 * around without checking the pgd every time.
31204 */
31205
31206 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31207 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31208 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31209
31210 int force_personality32;
31211 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31212
31213 for (address = start; address <= end; address += PGDIR_SIZE) {
31214 const pgd_t *pgd_ref = pgd_offset_k(address);
31215 +
31216 +#ifdef CONFIG_PAX_PER_CPU_PGD
31217 + unsigned long cpu;
31218 +#else
31219 struct page *page;
31220 +#endif
31221
31222 if (pgd_none(*pgd_ref))
31223 continue;
31224
31225 spin_lock(&pgd_lock);
31226 +
31227 +#ifdef CONFIG_PAX_PER_CPU_PGD
31228 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31229 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31230 +
31231 + if (pgd_none(*pgd))
31232 + set_pgd(pgd, *pgd_ref);
31233 + else
31234 + BUG_ON(pgd_page_vaddr(*pgd)
31235 + != pgd_page_vaddr(*pgd_ref));
31236 + pgd = pgd_offset_cpu(cpu, kernel, address);
31237 +#else
31238 list_for_each_entry(page, &pgd_list, lru) {
31239 pgd_t *pgd;
31240 spinlock_t *pgt_lock;
31241 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31242 /* the pgt_lock only for Xen */
31243 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31244 spin_lock(pgt_lock);
31245 +#endif
31246
31247 if (pgd_none(*pgd))
31248 set_pgd(pgd, *pgd_ref);
31249 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31250 BUG_ON(pgd_page_vaddr(*pgd)
31251 != pgd_page_vaddr(*pgd_ref));
31252
31253 +#ifndef CONFIG_PAX_PER_CPU_PGD
31254 spin_unlock(pgt_lock);
31255 +#endif
31256 +
31257 }
31258 spin_unlock(&pgd_lock);
31259 }
31260 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31261 {
31262 if (pgd_none(*pgd)) {
31263 pud_t *pud = (pud_t *)spp_getpage();
31264 - pgd_populate(&init_mm, pgd, pud);
31265 + pgd_populate_kernel(&init_mm, pgd, pud);
31266 if (pud != pud_offset(pgd, 0))
31267 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31268 pud, pud_offset(pgd, 0));
31269 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31270 {
31271 if (pud_none(*pud)) {
31272 pmd_t *pmd = (pmd_t *) spp_getpage();
31273 - pud_populate(&init_mm, pud, pmd);
31274 + pud_populate_kernel(&init_mm, pud, pmd);
31275 if (pmd != pmd_offset(pud, 0))
31276 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31277 pmd, pmd_offset(pud, 0));
31278 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31279 pmd = fill_pmd(pud, vaddr);
31280 pte = fill_pte(pmd, vaddr);
31281
31282 + pax_open_kernel();
31283 set_pte(pte, new_pte);
31284 + pax_close_kernel();
31285
31286 /*
31287 * It's enough to flush this one mapping.
31288 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31289 pgd = pgd_offset_k((unsigned long)__va(phys));
31290 if (pgd_none(*pgd)) {
31291 pud = (pud_t *) spp_getpage();
31292 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31293 - _PAGE_USER));
31294 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31295 }
31296 pud = pud_offset(pgd, (unsigned long)__va(phys));
31297 if (pud_none(*pud)) {
31298 pmd = (pmd_t *) spp_getpage();
31299 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31300 - _PAGE_USER));
31301 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31302 }
31303 pmd = pmd_offset(pud, phys);
31304 BUG_ON(!pmd_none(*pmd));
31305 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31306 prot);
31307
31308 spin_lock(&init_mm.page_table_lock);
31309 - pud_populate(&init_mm, pud, pmd);
31310 + pud_populate_kernel(&init_mm, pud, pmd);
31311 spin_unlock(&init_mm.page_table_lock);
31312 }
31313 __flush_tlb_all();
31314 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31315 page_size_mask);
31316
31317 spin_lock(&init_mm.page_table_lock);
31318 - pgd_populate(&init_mm, pgd, pud);
31319 + pgd_populate_kernel(&init_mm, pgd, pud);
31320 spin_unlock(&init_mm.page_table_lock);
31321 pgd_changed = true;
31322 }
31323 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31324 static struct vm_area_struct gate_vma = {
31325 .vm_start = VSYSCALL_START,
31326 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31327 - .vm_page_prot = PAGE_READONLY_EXEC,
31328 - .vm_flags = VM_READ | VM_EXEC
31329 + .vm_page_prot = PAGE_READONLY,
31330 + .vm_flags = VM_READ
31331 };
31332
31333 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31334 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31335
31336 const char *arch_vma_name(struct vm_area_struct *vma)
31337 {
31338 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31339 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31340 return "[vdso]";
31341 if (vma == &gate_vma)
31342 return "[vsyscall]";
31343 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31344 index 7b179b4..6bd17777 100644
31345 --- a/arch/x86/mm/iomap_32.c
31346 +++ b/arch/x86/mm/iomap_32.c
31347 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31348 type = kmap_atomic_idx_push();
31349 idx = type + KM_TYPE_NR * smp_processor_id();
31350 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31351 +
31352 + pax_open_kernel();
31353 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31354 + pax_close_kernel();
31355 +
31356 arch_flush_lazy_mmu_mode();
31357
31358 return (void *)vaddr;
31359 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31360 index 0215e2c..1c62dab 100644
31361 --- a/arch/x86/mm/ioremap.c
31362 +++ b/arch/x86/mm/ioremap.c
31363 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31364 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31365 int is_ram = page_is_ram(pfn);
31366
31367 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31368 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31369 return NULL;
31370 WARN_ON_ONCE(is_ram);
31371 }
31372 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31373 *
31374 * Caller must ensure there is only one unmapping for the same pointer.
31375 */
31376 -void iounmap(volatile void __iomem *addr)
31377 +void iounmap(const volatile void __iomem *addr)
31378 {
31379 struct vm_struct *p, *o;
31380
31381 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31382
31383 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31384 if (page_is_ram(start >> PAGE_SHIFT))
31385 +#ifdef CONFIG_HIGHMEM
31386 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31387 +#endif
31388 return __va(phys);
31389
31390 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31391 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31392 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31393 {
31394 if (page_is_ram(phys >> PAGE_SHIFT))
31395 +#ifdef CONFIG_HIGHMEM
31396 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31397 +#endif
31398 return;
31399
31400 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31401 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31402 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31403
31404 static __initdata int after_paging_init;
31405 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31406 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31407
31408 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31409 {
31410 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31411 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31412
31413 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31414 - memset(bm_pte, 0, sizeof(bm_pte));
31415 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31416 + pmd_populate_user(&init_mm, pmd, bm_pte);
31417
31418 /*
31419 * The boot-ioremap range spans multiple pmds, for which
31420 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31421 index d87dd6d..bf3fa66 100644
31422 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31423 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31424 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31425 * memory (e.g. tracked pages)? For now, we need this to avoid
31426 * invoking kmemcheck for PnP BIOS calls.
31427 */
31428 - if (regs->flags & X86_VM_MASK)
31429 + if (v8086_mode(regs))
31430 return false;
31431 - if (regs->cs != __KERNEL_CS)
31432 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31433 return false;
31434
31435 pte = kmemcheck_pte_lookup(address);
31436 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31437 index 25e7e13..1964579 100644
31438 --- a/arch/x86/mm/mmap.c
31439 +++ b/arch/x86/mm/mmap.c
31440 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31441 * Leave an at least ~128 MB hole with possible stack randomization.
31442 */
31443 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31444 -#define MAX_GAP (TASK_SIZE/6*5)
31445 +#define MAX_GAP (pax_task_size/6*5)
31446
31447 static int mmap_is_legacy(void)
31448 {
31449 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31450 return rnd << PAGE_SHIFT;
31451 }
31452
31453 -static unsigned long mmap_base(void)
31454 +static unsigned long mmap_base(struct mm_struct *mm)
31455 {
31456 unsigned long gap = rlimit(RLIMIT_STACK);
31457 + unsigned long pax_task_size = TASK_SIZE;
31458 +
31459 +#ifdef CONFIG_PAX_SEGMEXEC
31460 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31461 + pax_task_size = SEGMEXEC_TASK_SIZE;
31462 +#endif
31463
31464 if (gap < MIN_GAP)
31465 gap = MIN_GAP;
31466 else if (gap > MAX_GAP)
31467 gap = MAX_GAP;
31468
31469 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31470 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31471 }
31472
31473 /*
31474 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31475 * does, but not when emulating X86_32
31476 */
31477 -static unsigned long mmap_legacy_base(void)
31478 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31479 {
31480 - if (mmap_is_ia32())
31481 + if (mmap_is_ia32()) {
31482 +
31483 +#ifdef CONFIG_PAX_SEGMEXEC
31484 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31485 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31486 + else
31487 +#endif
31488 +
31489 return TASK_UNMAPPED_BASE;
31490 - else
31491 + } else
31492 return TASK_UNMAPPED_BASE + mmap_rnd();
31493 }
31494
31495 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31496 */
31497 void arch_pick_mmap_layout(struct mm_struct *mm)
31498 {
31499 - mm->mmap_legacy_base = mmap_legacy_base();
31500 - mm->mmap_base = mmap_base();
31501 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31502 + mm->mmap_base = mmap_base(mm);
31503 +
31504 +#ifdef CONFIG_PAX_RANDMMAP
31505 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31506 + mm->mmap_legacy_base += mm->delta_mmap;
31507 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31508 + }
31509 +#endif
31510
31511 if (mmap_is_legacy()) {
31512 mm->mmap_base = mm->mmap_legacy_base;
31513 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31514 index 0057a7a..95c7edd 100644
31515 --- a/arch/x86/mm/mmio-mod.c
31516 +++ b/arch/x86/mm/mmio-mod.c
31517 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31518 break;
31519 default:
31520 {
31521 - unsigned char *ip = (unsigned char *)instptr;
31522 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31523 my_trace->opcode = MMIO_UNKNOWN_OP;
31524 my_trace->width = 0;
31525 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31526 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31527 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31528 void __iomem *addr)
31529 {
31530 - static atomic_t next_id;
31531 + static atomic_unchecked_t next_id;
31532 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31533 /* These are page-unaligned. */
31534 struct mmiotrace_map map = {
31535 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31536 .private = trace
31537 },
31538 .phys = offset,
31539 - .id = atomic_inc_return(&next_id)
31540 + .id = atomic_inc_return_unchecked(&next_id)
31541 };
31542 map.map_id = trace->id;
31543
31544 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31545 ioremap_trace_core(offset, size, addr);
31546 }
31547
31548 -static void iounmap_trace_core(volatile void __iomem *addr)
31549 +static void iounmap_trace_core(const volatile void __iomem *addr)
31550 {
31551 struct mmiotrace_map map = {
31552 .phys = 0,
31553 @@ -328,7 +328,7 @@ not_enabled:
31554 }
31555 }
31556
31557 -void mmiotrace_iounmap(volatile void __iomem *addr)
31558 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31559 {
31560 might_sleep();
31561 if (is_enabled()) /* recheck and proper locking in *_core() */
31562 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31563 index 8bf93ba..dbcd670 100644
31564 --- a/arch/x86/mm/numa.c
31565 +++ b/arch/x86/mm/numa.c
31566 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31567 return true;
31568 }
31569
31570 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31571 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31572 {
31573 unsigned long uninitialized_var(pfn_align);
31574 int i, nid;
31575 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31576 index d0b1773..4c3327c 100644
31577 --- a/arch/x86/mm/pageattr-test.c
31578 +++ b/arch/x86/mm/pageattr-test.c
31579 @@ -36,7 +36,7 @@ enum {
31580
31581 static int pte_testbit(pte_t pte)
31582 {
31583 - return pte_flags(pte) & _PAGE_UNUSED1;
31584 + return pte_flags(pte) & _PAGE_CPA_TEST;
31585 }
31586
31587 struct split_state {
31588 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31589 index bb32480..75f2f5e 100644
31590 --- a/arch/x86/mm/pageattr.c
31591 +++ b/arch/x86/mm/pageattr.c
31592 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31593 */
31594 #ifdef CONFIG_PCI_BIOS
31595 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31596 - pgprot_val(forbidden) |= _PAGE_NX;
31597 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31598 #endif
31599
31600 /*
31601 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31602 * Does not cover __inittext since that is gone later on. On
31603 * 64bit we do not enforce !NX on the low mapping
31604 */
31605 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31606 - pgprot_val(forbidden) |= _PAGE_NX;
31607 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31608 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31609
31610 +#ifdef CONFIG_DEBUG_RODATA
31611 /*
31612 * The .rodata section needs to be read-only. Using the pfn
31613 * catches all aliases.
31614 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31615 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31616 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31617 pgprot_val(forbidden) |= _PAGE_RW;
31618 +#endif
31619
31620 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31621 /*
31622 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31623 }
31624 #endif
31625
31626 +#ifdef CONFIG_PAX_KERNEXEC
31627 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31628 + pgprot_val(forbidden) |= _PAGE_RW;
31629 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31630 + }
31631 +#endif
31632 +
31633 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31634
31635 return prot;
31636 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31637 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31638 {
31639 /* change init_mm */
31640 + pax_open_kernel();
31641 set_pte_atomic(kpte, pte);
31642 +
31643 #ifdef CONFIG_X86_32
31644 if (!SHARED_KERNEL_PMD) {
31645 +
31646 +#ifdef CONFIG_PAX_PER_CPU_PGD
31647 + unsigned long cpu;
31648 +#else
31649 struct page *page;
31650 +#endif
31651
31652 +#ifdef CONFIG_PAX_PER_CPU_PGD
31653 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31654 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31655 +#else
31656 list_for_each_entry(page, &pgd_list, lru) {
31657 - pgd_t *pgd;
31658 + pgd_t *pgd = (pgd_t *)page_address(page);
31659 +#endif
31660 +
31661 pud_t *pud;
31662 pmd_t *pmd;
31663
31664 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31665 + pgd += pgd_index(address);
31666 pud = pud_offset(pgd, address);
31667 pmd = pmd_offset(pud, address);
31668 set_pte_atomic((pte_t *)pmd, pte);
31669 }
31670 }
31671 #endif
31672 + pax_close_kernel();
31673 }
31674
31675 static int
31676 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31677 index 6574388..87e9bef 100644
31678 --- a/arch/x86/mm/pat.c
31679 +++ b/arch/x86/mm/pat.c
31680 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31681
31682 if (!entry) {
31683 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31684 - current->comm, current->pid, start, end - 1);
31685 + current->comm, task_pid_nr(current), start, end - 1);
31686 return -EINVAL;
31687 }
31688
31689 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31690
31691 while (cursor < to) {
31692 if (!devmem_is_allowed(pfn)) {
31693 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31694 - current->comm, from, to - 1);
31695 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31696 + current->comm, from, to - 1, cursor);
31697 return 0;
31698 }
31699 cursor += PAGE_SIZE;
31700 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31701 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31702 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31703 "for [mem %#010Lx-%#010Lx]\n",
31704 - current->comm, current->pid,
31705 + current->comm, task_pid_nr(current),
31706 cattr_name(flags),
31707 base, (unsigned long long)(base + size-1));
31708 return -EINVAL;
31709 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31710 flags = lookup_memtype(paddr);
31711 if (want_flags != flags) {
31712 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31713 - current->comm, current->pid,
31714 + current->comm, task_pid_nr(current),
31715 cattr_name(want_flags),
31716 (unsigned long long)paddr,
31717 (unsigned long long)(paddr + size - 1),
31718 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31719 free_memtype(paddr, paddr + size);
31720 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31721 " for [mem %#010Lx-%#010Lx], got %s\n",
31722 - current->comm, current->pid,
31723 + current->comm, task_pid_nr(current),
31724 cattr_name(want_flags),
31725 (unsigned long long)paddr,
31726 (unsigned long long)(paddr + size - 1),
31727 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31728 index 415f6c4..d319983 100644
31729 --- a/arch/x86/mm/pat_rbtree.c
31730 +++ b/arch/x86/mm/pat_rbtree.c
31731 @@ -160,7 +160,7 @@ success:
31732
31733 failure:
31734 printk(KERN_INFO "%s:%d conflicting memory types "
31735 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31736 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31737 end, cattr_name(found_type), cattr_name(match->type));
31738 return -EBUSY;
31739 }
31740 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31741 index 9f0614d..92ae64a 100644
31742 --- a/arch/x86/mm/pf_in.c
31743 +++ b/arch/x86/mm/pf_in.c
31744 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31745 int i;
31746 enum reason_type rv = OTHERS;
31747
31748 - p = (unsigned char *)ins_addr;
31749 + p = (unsigned char *)ktla_ktva(ins_addr);
31750 p += skip_prefix(p, &prf);
31751 p += get_opcode(p, &opcode);
31752
31753 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31754 struct prefix_bits prf;
31755 int i;
31756
31757 - p = (unsigned char *)ins_addr;
31758 + p = (unsigned char *)ktla_ktva(ins_addr);
31759 p += skip_prefix(p, &prf);
31760 p += get_opcode(p, &opcode);
31761
31762 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31763 struct prefix_bits prf;
31764 int i;
31765
31766 - p = (unsigned char *)ins_addr;
31767 + p = (unsigned char *)ktla_ktva(ins_addr);
31768 p += skip_prefix(p, &prf);
31769 p += get_opcode(p, &opcode);
31770
31771 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31772 struct prefix_bits prf;
31773 int i;
31774
31775 - p = (unsigned char *)ins_addr;
31776 + p = (unsigned char *)ktla_ktva(ins_addr);
31777 p += skip_prefix(p, &prf);
31778 p += get_opcode(p, &opcode);
31779 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31780 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31781 struct prefix_bits prf;
31782 int i;
31783
31784 - p = (unsigned char *)ins_addr;
31785 + p = (unsigned char *)ktla_ktva(ins_addr);
31786 p += skip_prefix(p, &prf);
31787 p += get_opcode(p, &opcode);
31788 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31789 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31790 index dfa537a..fd45c64 100644
31791 --- a/arch/x86/mm/pgtable.c
31792 +++ b/arch/x86/mm/pgtable.c
31793 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31794 list_del(&page->lru);
31795 }
31796
31797 -#define UNSHARED_PTRS_PER_PGD \
31798 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31799 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31800 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31801
31802 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31803 +{
31804 + unsigned int count = USER_PGD_PTRS;
31805
31806 + if (!pax_user_shadow_base)
31807 + return;
31808 +
31809 + while (count--)
31810 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31811 +}
31812 +#endif
31813 +
31814 +#ifdef CONFIG_PAX_PER_CPU_PGD
31815 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31816 +{
31817 + unsigned int count = USER_PGD_PTRS;
31818 +
31819 + while (count--) {
31820 + pgd_t pgd;
31821 +
31822 +#ifdef CONFIG_X86_64
31823 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31824 +#else
31825 + pgd = *src++;
31826 +#endif
31827 +
31828 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31829 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31830 +#endif
31831 +
31832 + *dst++ = pgd;
31833 + }
31834 +
31835 +}
31836 +#endif
31837 +
31838 +#ifdef CONFIG_X86_64
31839 +#define pxd_t pud_t
31840 +#define pyd_t pgd_t
31841 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31842 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31843 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31844 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31845 +#define PYD_SIZE PGDIR_SIZE
31846 +#else
31847 +#define pxd_t pmd_t
31848 +#define pyd_t pud_t
31849 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31850 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31851 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31852 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31853 +#define PYD_SIZE PUD_SIZE
31854 +#endif
31855 +
31856 +#ifdef CONFIG_PAX_PER_CPU_PGD
31857 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31858 +static inline void pgd_dtor(pgd_t *pgd) {}
31859 +#else
31860 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31861 {
31862 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31863 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31864 pgd_list_del(pgd);
31865 spin_unlock(&pgd_lock);
31866 }
31867 +#endif
31868
31869 /*
31870 * List of all pgd's needed for non-PAE so it can invalidate entries
31871 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31872 * -- nyc
31873 */
31874
31875 -#ifdef CONFIG_X86_PAE
31876 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31877 /*
31878 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31879 * updating the top-level pagetable entries to guarantee the
31880 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31881 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31882 * and initialize the kernel pmds here.
31883 */
31884 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31885 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31886
31887 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31888 {
31889 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31890 */
31891 flush_tlb_mm(mm);
31892 }
31893 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31894 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31895 #else /* !CONFIG_X86_PAE */
31896
31897 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31898 -#define PREALLOCATED_PMDS 0
31899 +#define PREALLOCATED_PXDS 0
31900
31901 #endif /* CONFIG_X86_PAE */
31902
31903 -static void free_pmds(pmd_t *pmds[])
31904 +static void free_pxds(pxd_t *pxds[])
31905 {
31906 int i;
31907
31908 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31909 - if (pmds[i])
31910 - free_page((unsigned long)pmds[i]);
31911 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31912 + if (pxds[i])
31913 + free_page((unsigned long)pxds[i]);
31914 }
31915
31916 -static int preallocate_pmds(pmd_t *pmds[])
31917 +static int preallocate_pxds(pxd_t *pxds[])
31918 {
31919 int i;
31920 bool failed = false;
31921
31922 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31923 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31924 - if (pmd == NULL)
31925 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31926 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31927 + if (pxd == NULL)
31928 failed = true;
31929 - pmds[i] = pmd;
31930 + pxds[i] = pxd;
31931 }
31932
31933 if (failed) {
31934 - free_pmds(pmds);
31935 + free_pxds(pxds);
31936 return -ENOMEM;
31937 }
31938
31939 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31940 * preallocate which never got a corresponding vma will need to be
31941 * freed manually.
31942 */
31943 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31944 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31945 {
31946 int i;
31947
31948 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31949 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31950 pgd_t pgd = pgdp[i];
31951
31952 if (pgd_val(pgd) != 0) {
31953 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31954 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31955
31956 - pgdp[i] = native_make_pgd(0);
31957 + set_pgd(pgdp + i, native_make_pgd(0));
31958
31959 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31960 - pmd_free(mm, pmd);
31961 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31962 + pxd_free(mm, pxd);
31963 }
31964 }
31965 }
31966
31967 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31968 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31969 {
31970 - pud_t *pud;
31971 + pyd_t *pyd;
31972 int i;
31973
31974 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31975 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31976 return;
31977
31978 - pud = pud_offset(pgd, 0);
31979 -
31980 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31981 - pmd_t *pmd = pmds[i];
31982 +#ifdef CONFIG_X86_64
31983 + pyd = pyd_offset(mm, 0L);
31984 +#else
31985 + pyd = pyd_offset(pgd, 0L);
31986 +#endif
31987
31988 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31989 + pxd_t *pxd = pxds[i];
31990 if (i >= KERNEL_PGD_BOUNDARY)
31991 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31992 - sizeof(pmd_t) * PTRS_PER_PMD);
31993 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31994 + sizeof(pxd_t) * PTRS_PER_PMD);
31995
31996 - pud_populate(mm, pud, pmd);
31997 + pyd_populate(mm, pyd, pxd);
31998 }
31999 }
32000
32001 pgd_t *pgd_alloc(struct mm_struct *mm)
32002 {
32003 pgd_t *pgd;
32004 - pmd_t *pmds[PREALLOCATED_PMDS];
32005 + pxd_t *pxds[PREALLOCATED_PXDS];
32006
32007 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32008
32009 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32010
32011 mm->pgd = pgd;
32012
32013 - if (preallocate_pmds(pmds) != 0)
32014 + if (preallocate_pxds(pxds) != 0)
32015 goto out_free_pgd;
32016
32017 if (paravirt_pgd_alloc(mm) != 0)
32018 - goto out_free_pmds;
32019 + goto out_free_pxds;
32020
32021 /*
32022 * Make sure that pre-populating the pmds is atomic with
32023 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32024 spin_lock(&pgd_lock);
32025
32026 pgd_ctor(mm, pgd);
32027 - pgd_prepopulate_pmd(mm, pgd, pmds);
32028 + pgd_prepopulate_pxd(mm, pgd, pxds);
32029
32030 spin_unlock(&pgd_lock);
32031
32032 return pgd;
32033
32034 -out_free_pmds:
32035 - free_pmds(pmds);
32036 +out_free_pxds:
32037 + free_pxds(pxds);
32038 out_free_pgd:
32039 free_page((unsigned long)pgd);
32040 out:
32041 @@ -300,7 +363,7 @@ out:
32042
32043 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32044 {
32045 - pgd_mop_up_pmds(mm, pgd);
32046 + pgd_mop_up_pxds(mm, pgd);
32047 pgd_dtor(pgd);
32048 paravirt_pgd_free(mm, pgd);
32049 free_page((unsigned long)pgd);
32050 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32051 index a69bcb8..19068ab 100644
32052 --- a/arch/x86/mm/pgtable_32.c
32053 +++ b/arch/x86/mm/pgtable_32.c
32054 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32055 return;
32056 }
32057 pte = pte_offset_kernel(pmd, vaddr);
32058 +
32059 + pax_open_kernel();
32060 if (pte_val(pteval))
32061 set_pte_at(&init_mm, vaddr, pte, pteval);
32062 else
32063 pte_clear(&init_mm, vaddr, pte);
32064 + pax_close_kernel();
32065
32066 /*
32067 * It's enough to flush this one mapping.
32068 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32069 index e666cbb..61788c45 100644
32070 --- a/arch/x86/mm/physaddr.c
32071 +++ b/arch/x86/mm/physaddr.c
32072 @@ -10,7 +10,7 @@
32073 #ifdef CONFIG_X86_64
32074
32075 #ifdef CONFIG_DEBUG_VIRTUAL
32076 -unsigned long __phys_addr(unsigned long x)
32077 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32078 {
32079 unsigned long y = x - __START_KERNEL_map;
32080
32081 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32082 #else
32083
32084 #ifdef CONFIG_DEBUG_VIRTUAL
32085 -unsigned long __phys_addr(unsigned long x)
32086 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32087 {
32088 unsigned long phys_addr = x - PAGE_OFFSET;
32089 /* VMALLOC_* aren't constants */
32090 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32091 index 90555bf..f5f1828 100644
32092 --- a/arch/x86/mm/setup_nx.c
32093 +++ b/arch/x86/mm/setup_nx.c
32094 @@ -5,8 +5,10 @@
32095 #include <asm/pgtable.h>
32096 #include <asm/proto.h>
32097
32098 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32099 static int disable_nx;
32100
32101 +#ifndef CONFIG_PAX_PAGEEXEC
32102 /*
32103 * noexec = on|off
32104 *
32105 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32106 return 0;
32107 }
32108 early_param("noexec", noexec_setup);
32109 +#endif
32110 +
32111 +#endif
32112
32113 void x86_configure_nx(void)
32114 {
32115 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32116 if (cpu_has_nx && !disable_nx)
32117 __supported_pte_mask |= _PAGE_NX;
32118 else
32119 +#endif
32120 __supported_pte_mask &= ~_PAGE_NX;
32121 }
32122
32123 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32124 index 282375f..e03a98f 100644
32125 --- a/arch/x86/mm/tlb.c
32126 +++ b/arch/x86/mm/tlb.c
32127 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32128 BUG();
32129 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32130 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32131 +
32132 +#ifndef CONFIG_PAX_PER_CPU_PGD
32133 load_cr3(swapper_pg_dir);
32134 +#endif
32135 +
32136 }
32137 }
32138 EXPORT_SYMBOL_GPL(leave_mm);
32139 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32140 new file mode 100644
32141 index 0000000..dace51c
32142 --- /dev/null
32143 +++ b/arch/x86/mm/uderef_64.c
32144 @@ -0,0 +1,37 @@
32145 +#include <linux/mm.h>
32146 +#include <asm/pgtable.h>
32147 +#include <asm/uaccess.h>
32148 +
32149 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32150 +/* PaX: due to the special call convention these functions must
32151 + * - remain leaf functions under all configurations,
32152 + * - never be called directly, only dereferenced from the wrappers.
32153 + */
32154 +void __pax_open_userland(void)
32155 +{
32156 + unsigned int cpu;
32157 +
32158 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32159 + return;
32160 +
32161 + cpu = raw_get_cpu();
32162 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32163 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32164 + raw_put_cpu_no_resched();
32165 +}
32166 +EXPORT_SYMBOL(__pax_open_userland);
32167 +
32168 +void __pax_close_userland(void)
32169 +{
32170 + unsigned int cpu;
32171 +
32172 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32173 + return;
32174 +
32175 + cpu = raw_get_cpu();
32176 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32177 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32178 + raw_put_cpu_no_resched();
32179 +}
32180 +EXPORT_SYMBOL(__pax_close_userland);
32181 +#endif
32182 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32183 index 877b9a1..a8ecf42 100644
32184 --- a/arch/x86/net/bpf_jit.S
32185 +++ b/arch/x86/net/bpf_jit.S
32186 @@ -9,6 +9,7 @@
32187 */
32188 #include <linux/linkage.h>
32189 #include <asm/dwarf2.h>
32190 +#include <asm/alternative-asm.h>
32191
32192 /*
32193 * Calling convention :
32194 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32195 jle bpf_slow_path_word
32196 mov (SKBDATA,%rsi),%eax
32197 bswap %eax /* ntohl() */
32198 + pax_force_retaddr
32199 ret
32200
32201 sk_load_half:
32202 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32203 jle bpf_slow_path_half
32204 movzwl (SKBDATA,%rsi),%eax
32205 rol $8,%ax # ntohs()
32206 + pax_force_retaddr
32207 ret
32208
32209 sk_load_byte:
32210 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32211 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32212 jle bpf_slow_path_byte
32213 movzbl (SKBDATA,%rsi),%eax
32214 + pax_force_retaddr
32215 ret
32216
32217 /**
32218 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32219 movzbl (SKBDATA,%rsi),%ebx
32220 and $15,%bl
32221 shl $2,%bl
32222 + pax_force_retaddr
32223 ret
32224
32225 /* rsi contains offset and can be scratched */
32226 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32227 js bpf_error
32228 mov -12(%rbp),%eax
32229 bswap %eax
32230 + pax_force_retaddr
32231 ret
32232
32233 bpf_slow_path_half:
32234 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32235 mov -12(%rbp),%ax
32236 rol $8,%ax
32237 movzwl %ax,%eax
32238 + pax_force_retaddr
32239 ret
32240
32241 bpf_slow_path_byte:
32242 bpf_slow_path_common(1)
32243 js bpf_error
32244 movzbl -12(%rbp),%eax
32245 + pax_force_retaddr
32246 ret
32247
32248 bpf_slow_path_byte_msh:
32249 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32250 and $15,%al
32251 shl $2,%al
32252 xchg %eax,%ebx
32253 + pax_force_retaddr
32254 ret
32255
32256 #define sk_negative_common(SIZE) \
32257 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32258 sk_negative_common(4)
32259 mov (%rax), %eax
32260 bswap %eax
32261 + pax_force_retaddr
32262 ret
32263
32264 bpf_slow_path_half_neg:
32265 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32266 mov (%rax),%ax
32267 rol $8,%ax
32268 movzwl %ax,%eax
32269 + pax_force_retaddr
32270 ret
32271
32272 bpf_slow_path_byte_neg:
32273 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32274 .globl sk_load_byte_negative_offset
32275 sk_negative_common(1)
32276 movzbl (%rax), %eax
32277 + pax_force_retaddr
32278 ret
32279
32280 bpf_slow_path_byte_msh_neg:
32281 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32282 and $15,%al
32283 shl $2,%al
32284 xchg %eax,%ebx
32285 + pax_force_retaddr
32286 ret
32287
32288 bpf_error:
32289 @@ -197,4 +210,5 @@ bpf_error:
32290 xor %eax,%eax
32291 mov -8(%rbp),%rbx
32292 leaveq
32293 + pax_force_retaddr
32294 ret
32295 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32296 index 79c216a..08d39cc 100644
32297 --- a/arch/x86/net/bpf_jit_comp.c
32298 +++ b/arch/x86/net/bpf_jit_comp.c
32299 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32300 return ptr + len;
32301 }
32302
32303 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32304 +#define MAX_INSTR_CODE_SIZE 96
32305 +#else
32306 +#define MAX_INSTR_CODE_SIZE 64
32307 +#endif
32308 +
32309 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32310
32311 #define EMIT1(b1) EMIT(b1, 1)
32312 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32313 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32314 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32315 +
32316 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32317 +/* original constant will appear in ecx */
32318 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32319 +do { \
32320 + /* mov ecx, randkey */ \
32321 + EMIT1(0xb9); \
32322 + EMIT(_key, 4); \
32323 + /* xor ecx, randkey ^ off */ \
32324 + EMIT2(0x81, 0xf1); \
32325 + EMIT((_key) ^ (_off), 4); \
32326 +} while (0)
32327 +
32328 +#define EMIT1_off32(b1, _off) \
32329 +do { \
32330 + switch (b1) { \
32331 + case 0x05: /* add eax, imm32 */ \
32332 + case 0x2d: /* sub eax, imm32 */ \
32333 + case 0x25: /* and eax, imm32 */ \
32334 + case 0x0d: /* or eax, imm32 */ \
32335 + case 0xb8: /* mov eax, imm32 */ \
32336 + case 0x35: /* xor eax, imm32 */ \
32337 + case 0x3d: /* cmp eax, imm32 */ \
32338 + case 0xa9: /* test eax, imm32 */ \
32339 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32340 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32341 + break; \
32342 + case 0xbb: /* mov ebx, imm32 */ \
32343 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32344 + /* mov ebx, ecx */ \
32345 + EMIT2(0x89, 0xcb); \
32346 + break; \
32347 + case 0xbe: /* mov esi, imm32 */ \
32348 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32349 + /* mov esi, ecx */ \
32350 + EMIT2(0x89, 0xce); \
32351 + break; \
32352 + case 0xe8: /* call rel imm32, always to known funcs */ \
32353 + EMIT1(b1); \
32354 + EMIT(_off, 4); \
32355 + break; \
32356 + case 0xe9: /* jmp rel imm32 */ \
32357 + EMIT1(b1); \
32358 + EMIT(_off, 4); \
32359 + /* prevent fall-through, we're not called if off = 0 */ \
32360 + EMIT(0xcccccccc, 4); \
32361 + EMIT(0xcccccccc, 4); \
32362 + break; \
32363 + default: \
32364 + BUILD_BUG(); \
32365 + } \
32366 +} while (0)
32367 +
32368 +#define EMIT2_off32(b1, b2, _off) \
32369 +do { \
32370 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32371 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32372 + EMIT(randkey, 4); \
32373 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32374 + EMIT((_off) - randkey, 4); \
32375 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32376 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32377 + /* imul eax, ecx */ \
32378 + EMIT3(0x0f, 0xaf, 0xc1); \
32379 + } else { \
32380 + BUILD_BUG(); \
32381 + } \
32382 +} while (0)
32383 +#else
32384 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32385 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32386 +#endif
32387
32388 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32389 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32390 @@ -91,6 +168,24 @@ do { \
32391 #define X86_JBE 0x76
32392 #define X86_JA 0x77
32393
32394 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32395 +#define APPEND_FLOW_VERIFY() \
32396 +do { \
32397 + /* mov ecx, randkey */ \
32398 + EMIT1(0xb9); \
32399 + EMIT(randkey, 4); \
32400 + /* cmp ecx, randkey */ \
32401 + EMIT2(0x81, 0xf9); \
32402 + EMIT(randkey, 4); \
32403 + /* jz after 8 int 3s */ \
32404 + EMIT2(0x74, 0x08); \
32405 + EMIT(0xcccccccc, 4); \
32406 + EMIT(0xcccccccc, 4); \
32407 +} while (0)
32408 +#else
32409 +#define APPEND_FLOW_VERIFY() do { } while (0)
32410 +#endif
32411 +
32412 #define EMIT_COND_JMP(op, offset) \
32413 do { \
32414 if (is_near(offset)) \
32415 @@ -98,6 +193,7 @@ do { \
32416 else { \
32417 EMIT2(0x0f, op + 0x10); \
32418 EMIT(offset, 4); /* jxx .+off32 */ \
32419 + APPEND_FLOW_VERIFY(); \
32420 } \
32421 } while (0)
32422
32423 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32424 return -1;
32425 }
32426
32427 -struct bpf_binary_header {
32428 - unsigned int pages;
32429 - /* Note : for security reasons, bpf code will follow a randomly
32430 - * sized amount of int3 instructions
32431 - */
32432 - u8 image[];
32433 -};
32434 -
32435 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32436 +/* Note : for security reasons, bpf code will follow a randomly
32437 + * sized amount of int3 instructions
32438 + */
32439 +static u8 *bpf_alloc_binary(unsigned int proglen,
32440 u8 **image_ptr)
32441 {
32442 unsigned int sz, hole;
32443 - struct bpf_binary_header *header;
32444 + u8 *header;
32445
32446 /* Most of BPF filters are really small,
32447 * but if some of them fill a page, allow at least
32448 * 128 extra bytes to insert a random section of int3
32449 */
32450 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32451 - header = module_alloc(sz);
32452 + sz = round_up(proglen + 128, PAGE_SIZE);
32453 + header = module_alloc_exec(sz);
32454 if (!header)
32455 return NULL;
32456
32457 + pax_open_kernel();
32458 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32459 + pax_close_kernel();
32460
32461 - header->pages = sz / PAGE_SIZE;
32462 - hole = sz - (proglen + sizeof(*header));
32463 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32464
32465 /* insert a random number of int3 instructions before BPF code */
32466 - *image_ptr = &header->image[prandom_u32() % hole];
32467 + *image_ptr = &header[prandom_u32() % hole];
32468 return header;
32469 }
32470
32471 void bpf_jit_compile(struct sk_filter *fp)
32472 {
32473 - u8 temp[64];
32474 + u8 temp[MAX_INSTR_CODE_SIZE];
32475 u8 *prog;
32476 unsigned int proglen, oldproglen = 0;
32477 int ilen, i;
32478 int t_offset, f_offset;
32479 u8 t_op, f_op, seen = 0, pass;
32480 u8 *image = NULL;
32481 - struct bpf_binary_header *header = NULL;
32482 + u8 *header = NULL;
32483 u8 *func;
32484 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32485 unsigned int cleanup_addr; /* epilogue code offset */
32486 unsigned int *addrs;
32487 const struct sock_filter *filter = fp->insns;
32488 int flen = fp->len;
32489 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32490 + unsigned int randkey;
32491 +#endif
32492
32493 if (!bpf_jit_enable)
32494 return;
32495 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32496 if (addrs == NULL)
32497 return;
32498
32499 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32500 + randkey = get_random_int();
32501 +#endif
32502 +
32503 /* Before first pass, make a rough estimation of addrs[]
32504 - * each bpf instruction is translated to less than 64 bytes
32505 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32506 */
32507 for (proglen = 0, i = 0; i < flen; i++) {
32508 - proglen += 64;
32509 + proglen += MAX_INSTR_CODE_SIZE;
32510 addrs[i] = proglen;
32511 }
32512 cleanup_addr = proglen; /* epilogue address */
32513 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32514 case BPF_S_ALU_MUL_K: /* A *= K */
32515 if (is_imm8(K))
32516 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32517 - else {
32518 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32519 - EMIT(K, 4);
32520 - }
32521 + else
32522 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32523 break;
32524 case BPF_S_ALU_DIV_X: /* A /= X; */
32525 seen |= SEEN_XREG;
32526 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32527 break;
32528 case BPF_S_ALU_MOD_K: /* A %= K; */
32529 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32530 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32531 + DILUTE_CONST_SEQUENCE(K, randkey);
32532 +#else
32533 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32534 +#endif
32535 EMIT2(0xf7, 0xf1); /* div %ecx */
32536 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32537 break;
32538 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32539 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32540 + DILUTE_CONST_SEQUENCE(K, randkey);
32541 + // imul rax, rcx
32542 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32543 +#else
32544 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32545 EMIT(K, 4);
32546 +#endif
32547 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32548 break;
32549 case BPF_S_ALU_AND_X:
32550 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32551 if (is_imm8(K)) {
32552 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32553 } else {
32554 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32555 - EMIT(K, 4);
32556 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32557 }
32558 } else {
32559 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32560 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32561 if (unlikely(proglen + ilen > oldproglen)) {
32562 pr_err("bpb_jit_compile fatal error\n");
32563 kfree(addrs);
32564 - module_free(NULL, header);
32565 + module_free_exec(NULL, image);
32566 return;
32567 }
32568 + pax_open_kernel();
32569 memcpy(image + proglen, temp, ilen);
32570 + pax_close_kernel();
32571 }
32572 proglen += ilen;
32573 addrs[i] = proglen;
32574 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32575
32576 if (image) {
32577 bpf_flush_icache(header, image + proglen);
32578 - set_memory_ro((unsigned long)header, header->pages);
32579 fp->bpf_func = (void *)image;
32580 }
32581 out:
32582 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32583 {
32584 if (fp->bpf_func != sk_run_filter) {
32585 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32586 - struct bpf_binary_header *header = (void *)addr;
32587 -
32588 - set_memory_rw(addr, header->pages);
32589 - module_free(NULL, header);
32590 + set_memory_rw(addr, 1);
32591 + module_free_exec(NULL, (void *)addr);
32592 }
32593 }
32594 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32595 index d6aa6e8..266395a 100644
32596 --- a/arch/x86/oprofile/backtrace.c
32597 +++ b/arch/x86/oprofile/backtrace.c
32598 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32599 struct stack_frame_ia32 *fp;
32600 unsigned long bytes;
32601
32602 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32603 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32604 if (bytes != sizeof(bufhead))
32605 return NULL;
32606
32607 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32608 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32609
32610 oprofile_add_trace(bufhead[0].return_address);
32611
32612 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32613 struct stack_frame bufhead[2];
32614 unsigned long bytes;
32615
32616 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32617 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32618 if (bytes != sizeof(bufhead))
32619 return NULL;
32620
32621 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32622 {
32623 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32624
32625 - if (!user_mode_vm(regs)) {
32626 + if (!user_mode(regs)) {
32627 unsigned long stack = kernel_stack_pointer(regs);
32628 if (depth)
32629 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32630 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32631 index 48768df..ba9143c 100644
32632 --- a/arch/x86/oprofile/nmi_int.c
32633 +++ b/arch/x86/oprofile/nmi_int.c
32634 @@ -23,6 +23,7 @@
32635 #include <asm/nmi.h>
32636 #include <asm/msr.h>
32637 #include <asm/apic.h>
32638 +#include <asm/pgtable.h>
32639
32640 #include "op_counter.h"
32641 #include "op_x86_model.h"
32642 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32643 if (ret)
32644 return ret;
32645
32646 - if (!model->num_virt_counters)
32647 - model->num_virt_counters = model->num_counters;
32648 + if (!model->num_virt_counters) {
32649 + pax_open_kernel();
32650 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32651 + pax_close_kernel();
32652 + }
32653
32654 mux_init(ops);
32655
32656 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32657 index b2b9443..be58856 100644
32658 --- a/arch/x86/oprofile/op_model_amd.c
32659 +++ b/arch/x86/oprofile/op_model_amd.c
32660 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32661 num_counters = AMD64_NUM_COUNTERS;
32662 }
32663
32664 - op_amd_spec.num_counters = num_counters;
32665 - op_amd_spec.num_controls = num_counters;
32666 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_open_kernel();
32668 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32669 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32670 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32671 + pax_close_kernel();
32672
32673 return 0;
32674 }
32675 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32676 index d90528e..0127e2b 100644
32677 --- a/arch/x86/oprofile/op_model_ppro.c
32678 +++ b/arch/x86/oprofile/op_model_ppro.c
32679 @@ -19,6 +19,7 @@
32680 #include <asm/msr.h>
32681 #include <asm/apic.h>
32682 #include <asm/nmi.h>
32683 +#include <asm/pgtable.h>
32684
32685 #include "op_x86_model.h"
32686 #include "op_counter.h"
32687 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32688
32689 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32690
32691 - op_arch_perfmon_spec.num_counters = num_counters;
32692 - op_arch_perfmon_spec.num_controls = num_counters;
32693 + pax_open_kernel();
32694 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32695 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32696 + pax_close_kernel();
32697 }
32698
32699 static int arch_perfmon_init(struct oprofile_operations *ignore)
32700 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32701 index 71e8a67..6a313bb 100644
32702 --- a/arch/x86/oprofile/op_x86_model.h
32703 +++ b/arch/x86/oprofile/op_x86_model.h
32704 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32705 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32706 struct op_msrs const * const msrs);
32707 #endif
32708 -};
32709 +} __do_const;
32710
32711 struct op_counter_config;
32712
32713 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32714 index 372e9b8..e775a6c 100644
32715 --- a/arch/x86/pci/irq.c
32716 +++ b/arch/x86/pci/irq.c
32717 @@ -50,7 +50,7 @@ struct irq_router {
32718 struct irq_router_handler {
32719 u16 vendor;
32720 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32721 -};
32722 +} __do_const;
32723
32724 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32725 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32726 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32727 return 0;
32728 }
32729
32730 -static __initdata struct irq_router_handler pirq_routers[] = {
32731 +static __initconst const struct irq_router_handler pirq_routers[] = {
32732 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32733 { PCI_VENDOR_ID_AL, ali_router_probe },
32734 { PCI_VENDOR_ID_ITE, ite_router_probe },
32735 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32736 static void __init pirq_find_router(struct irq_router *r)
32737 {
32738 struct irq_routing_table *rt = pirq_table;
32739 - struct irq_router_handler *h;
32740 + const struct irq_router_handler *h;
32741
32742 #ifdef CONFIG_PCI_BIOS
32743 if (!rt->signature) {
32744 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32745 return 0;
32746 }
32747
32748 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32749 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32750 {
32751 .callback = fix_broken_hp_bios_irq9,
32752 .ident = "HP Pavilion N5400 Series Laptop",
32753 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32754 index 6eb18c4..20d83de 100644
32755 --- a/arch/x86/pci/mrst.c
32756 +++ b/arch/x86/pci/mrst.c
32757 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32758 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32759 pci_mmcfg_late_init();
32760 pcibios_enable_irq = mrst_pci_irq_enable;
32761 - pci_root_ops = pci_mrst_ops;
32762 + pax_open_kernel();
32763 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32764 + pax_close_kernel();
32765 pci_soc_mode = 1;
32766 /* Continue with standard init */
32767 return 1;
32768 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32769 index c77b24a..c979855 100644
32770 --- a/arch/x86/pci/pcbios.c
32771 +++ b/arch/x86/pci/pcbios.c
32772 @@ -79,7 +79,7 @@ union bios32 {
32773 static struct {
32774 unsigned long address;
32775 unsigned short segment;
32776 -} bios32_indirect = { 0, __KERNEL_CS };
32777 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32778
32779 /*
32780 * Returns the entry point for the given service, NULL on error
32781 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32782 unsigned long length; /* %ecx */
32783 unsigned long entry; /* %edx */
32784 unsigned long flags;
32785 + struct desc_struct d, *gdt;
32786
32787 local_irq_save(flags);
32788 - __asm__("lcall *(%%edi); cld"
32789 +
32790 + gdt = get_cpu_gdt_table(smp_processor_id());
32791 +
32792 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32793 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32794 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32795 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32796 +
32797 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32798 : "=a" (return_code),
32799 "=b" (address),
32800 "=c" (length),
32801 "=d" (entry)
32802 : "0" (service),
32803 "1" (0),
32804 - "D" (&bios32_indirect));
32805 + "D" (&bios32_indirect),
32806 + "r"(__PCIBIOS_DS)
32807 + : "memory");
32808 +
32809 + pax_open_kernel();
32810 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32811 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32812 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32813 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32814 + pax_close_kernel();
32815 +
32816 local_irq_restore(flags);
32817
32818 switch (return_code) {
32819 - case 0:
32820 - return address + entry;
32821 - case 0x80: /* Not present */
32822 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32823 - return 0;
32824 - default: /* Shouldn't happen */
32825 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32826 - service, return_code);
32827 + case 0: {
32828 + int cpu;
32829 + unsigned char flags;
32830 +
32831 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32832 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32833 + printk(KERN_WARNING "bios32_service: not valid\n");
32834 return 0;
32835 + }
32836 + address = address + PAGE_OFFSET;
32837 + length += 16UL; /* some BIOSs underreport this... */
32838 + flags = 4;
32839 + if (length >= 64*1024*1024) {
32840 + length >>= PAGE_SHIFT;
32841 + flags |= 8;
32842 + }
32843 +
32844 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32845 + gdt = get_cpu_gdt_table(cpu);
32846 + pack_descriptor(&d, address, length, 0x9b, flags);
32847 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32848 + pack_descriptor(&d, address, length, 0x93, flags);
32849 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32850 + }
32851 + return entry;
32852 + }
32853 + case 0x80: /* Not present */
32854 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32855 + return 0;
32856 + default: /* Shouldn't happen */
32857 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32858 + service, return_code);
32859 + return 0;
32860 }
32861 }
32862
32863 static struct {
32864 unsigned long address;
32865 unsigned short segment;
32866 -} pci_indirect = { 0, __KERNEL_CS };
32867 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32868
32869 -static int pci_bios_present;
32870 +static int pci_bios_present __read_only;
32871
32872 static int check_pcibios(void)
32873 {
32874 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32875 unsigned long flags, pcibios_entry;
32876
32877 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32878 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32879 + pci_indirect.address = pcibios_entry;
32880
32881 local_irq_save(flags);
32882 - __asm__(
32883 - "lcall *(%%edi); cld\n\t"
32884 + __asm__("movw %w6, %%ds\n\t"
32885 + "lcall *%%ss:(%%edi); cld\n\t"
32886 + "push %%ss\n\t"
32887 + "pop %%ds\n\t"
32888 "jc 1f\n\t"
32889 "xor %%ah, %%ah\n"
32890 "1:"
32891 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32892 "=b" (ebx),
32893 "=c" (ecx)
32894 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32895 - "D" (&pci_indirect)
32896 + "D" (&pci_indirect),
32897 + "r" (__PCIBIOS_DS)
32898 : "memory");
32899 local_irq_restore(flags);
32900
32901 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32902
32903 switch (len) {
32904 case 1:
32905 - __asm__("lcall *(%%esi); cld\n\t"
32906 + __asm__("movw %w6, %%ds\n\t"
32907 + "lcall *%%ss:(%%esi); cld\n\t"
32908 + "push %%ss\n\t"
32909 + "pop %%ds\n\t"
32910 "jc 1f\n\t"
32911 "xor %%ah, %%ah\n"
32912 "1:"
32913 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32914 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32915 "b" (bx),
32916 "D" ((long)reg),
32917 - "S" (&pci_indirect));
32918 + "S" (&pci_indirect),
32919 + "r" (__PCIBIOS_DS));
32920 /*
32921 * Zero-extend the result beyond 8 bits, do not trust the
32922 * BIOS having done it:
32923 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32924 *value &= 0xff;
32925 break;
32926 case 2:
32927 - __asm__("lcall *(%%esi); cld\n\t"
32928 + __asm__("movw %w6, %%ds\n\t"
32929 + "lcall *%%ss:(%%esi); cld\n\t"
32930 + "push %%ss\n\t"
32931 + "pop %%ds\n\t"
32932 "jc 1f\n\t"
32933 "xor %%ah, %%ah\n"
32934 "1:"
32935 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32936 : "1" (PCIBIOS_READ_CONFIG_WORD),
32937 "b" (bx),
32938 "D" ((long)reg),
32939 - "S" (&pci_indirect));
32940 + "S" (&pci_indirect),
32941 + "r" (__PCIBIOS_DS));
32942 /*
32943 * Zero-extend the result beyond 16 bits, do not trust the
32944 * BIOS having done it:
32945 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32946 *value &= 0xffff;
32947 break;
32948 case 4:
32949 - __asm__("lcall *(%%esi); cld\n\t"
32950 + __asm__("movw %w6, %%ds\n\t"
32951 + "lcall *%%ss:(%%esi); cld\n\t"
32952 + "push %%ss\n\t"
32953 + "pop %%ds\n\t"
32954 "jc 1f\n\t"
32955 "xor %%ah, %%ah\n"
32956 "1:"
32957 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32958 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32959 "b" (bx),
32960 "D" ((long)reg),
32961 - "S" (&pci_indirect));
32962 + "S" (&pci_indirect),
32963 + "r" (__PCIBIOS_DS));
32964 break;
32965 }
32966
32967 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32968
32969 switch (len) {
32970 case 1:
32971 - __asm__("lcall *(%%esi); cld\n\t"
32972 + __asm__("movw %w6, %%ds\n\t"
32973 + "lcall *%%ss:(%%esi); cld\n\t"
32974 + "push %%ss\n\t"
32975 + "pop %%ds\n\t"
32976 "jc 1f\n\t"
32977 "xor %%ah, %%ah\n"
32978 "1:"
32979 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32980 "c" (value),
32981 "b" (bx),
32982 "D" ((long)reg),
32983 - "S" (&pci_indirect));
32984 + "S" (&pci_indirect),
32985 + "r" (__PCIBIOS_DS));
32986 break;
32987 case 2:
32988 - __asm__("lcall *(%%esi); cld\n\t"
32989 + __asm__("movw %w6, %%ds\n\t"
32990 + "lcall *%%ss:(%%esi); cld\n\t"
32991 + "push %%ss\n\t"
32992 + "pop %%ds\n\t"
32993 "jc 1f\n\t"
32994 "xor %%ah, %%ah\n"
32995 "1:"
32996 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32997 "c" (value),
32998 "b" (bx),
32999 "D" ((long)reg),
33000 - "S" (&pci_indirect));
33001 + "S" (&pci_indirect),
33002 + "r" (__PCIBIOS_DS));
33003 break;
33004 case 4:
33005 - __asm__("lcall *(%%esi); cld\n\t"
33006 + __asm__("movw %w6, %%ds\n\t"
33007 + "lcall *%%ss:(%%esi); cld\n\t"
33008 + "push %%ss\n\t"
33009 + "pop %%ds\n\t"
33010 "jc 1f\n\t"
33011 "xor %%ah, %%ah\n"
33012 "1:"
33013 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33014 "c" (value),
33015 "b" (bx),
33016 "D" ((long)reg),
33017 - "S" (&pci_indirect));
33018 + "S" (&pci_indirect),
33019 + "r" (__PCIBIOS_DS));
33020 break;
33021 }
33022
33023 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33024
33025 DBG("PCI: Fetching IRQ routing table... ");
33026 __asm__("push %%es\n\t"
33027 + "movw %w8, %%ds\n\t"
33028 "push %%ds\n\t"
33029 "pop %%es\n\t"
33030 - "lcall *(%%esi); cld\n\t"
33031 + "lcall *%%ss:(%%esi); cld\n\t"
33032 "pop %%es\n\t"
33033 + "push %%ss\n\t"
33034 + "pop %%ds\n"
33035 "jc 1f\n\t"
33036 "xor %%ah, %%ah\n"
33037 "1:"
33038 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33039 "1" (0),
33040 "D" ((long) &opt),
33041 "S" (&pci_indirect),
33042 - "m" (opt)
33043 + "m" (opt),
33044 + "r" (__PCIBIOS_DS)
33045 : "memory");
33046 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33047 if (ret & 0xff00)
33048 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33049 {
33050 int ret;
33051
33052 - __asm__("lcall *(%%esi); cld\n\t"
33053 + __asm__("movw %w5, %%ds\n\t"
33054 + "lcall *%%ss:(%%esi); cld\n\t"
33055 + "push %%ss\n\t"
33056 + "pop %%ds\n"
33057 "jc 1f\n\t"
33058 "xor %%ah, %%ah\n"
33059 "1:"
33060 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33061 : "0" (PCIBIOS_SET_PCI_HW_INT),
33062 "b" ((dev->bus->number << 8) | dev->devfn),
33063 "c" ((irq << 8) | (pin + 10)),
33064 - "S" (&pci_indirect));
33065 + "S" (&pci_indirect),
33066 + "r" (__PCIBIOS_DS));
33067 return !(ret & 0xff00);
33068 }
33069 EXPORT_SYMBOL(pcibios_set_irq_routing);
33070 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33071 index 40e4469..d915bf9 100644
33072 --- a/arch/x86/platform/efi/efi_32.c
33073 +++ b/arch/x86/platform/efi/efi_32.c
33074 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33075 {
33076 struct desc_ptr gdt_descr;
33077
33078 +#ifdef CONFIG_PAX_KERNEXEC
33079 + struct desc_struct d;
33080 +#endif
33081 +
33082 local_irq_save(efi_rt_eflags);
33083
33084 load_cr3(initial_page_table);
33085 __flush_tlb_all();
33086
33087 +#ifdef CONFIG_PAX_KERNEXEC
33088 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33089 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33090 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33091 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33092 +#endif
33093 +
33094 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33095 gdt_descr.size = GDT_SIZE - 1;
33096 load_gdt(&gdt_descr);
33097 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33098 {
33099 struct desc_ptr gdt_descr;
33100
33101 +#ifdef CONFIG_PAX_KERNEXEC
33102 + struct desc_struct d;
33103 +
33104 + memset(&d, 0, sizeof d);
33105 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33106 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33107 +#endif
33108 +
33109 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33110 gdt_descr.size = GDT_SIZE - 1;
33111 load_gdt(&gdt_descr);
33112
33113 +#ifdef CONFIG_PAX_PER_CPU_PGD
33114 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33115 +#else
33116 load_cr3(swapper_pg_dir);
33117 +#endif
33118 +
33119 __flush_tlb_all();
33120
33121 local_irq_restore(efi_rt_eflags);
33122 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33123 index 39a0e7f1..872396e 100644
33124 --- a/arch/x86/platform/efi/efi_64.c
33125 +++ b/arch/x86/platform/efi/efi_64.c
33126 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33127 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33128 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33129 }
33130 +
33131 +#ifdef CONFIG_PAX_PER_CPU_PGD
33132 + load_cr3(swapper_pg_dir);
33133 +#endif
33134 +
33135 __flush_tlb_all();
33136 }
33137
33138 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33139 for (pgd = 0; pgd < n_pgds; pgd++)
33140 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33141 kfree(save_pgd);
33142 +
33143 +#ifdef CONFIG_PAX_PER_CPU_PGD
33144 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33145 +#endif
33146 +
33147 __flush_tlb_all();
33148 local_irq_restore(efi_flags);
33149 early_code_mapping_set_exec(0);
33150 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33151 index fbe66e6..eae5e38 100644
33152 --- a/arch/x86/platform/efi/efi_stub_32.S
33153 +++ b/arch/x86/platform/efi/efi_stub_32.S
33154 @@ -6,7 +6,9 @@
33155 */
33156
33157 #include <linux/linkage.h>
33158 +#include <linux/init.h>
33159 #include <asm/page_types.h>
33160 +#include <asm/segment.h>
33161
33162 /*
33163 * efi_call_phys(void *, ...) is a function with variable parameters.
33164 @@ -20,7 +22,7 @@
33165 * service functions will comply with gcc calling convention, too.
33166 */
33167
33168 -.text
33169 +__INIT
33170 ENTRY(efi_call_phys)
33171 /*
33172 * 0. The function can only be called in Linux kernel. So CS has been
33173 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33174 * The mapping of lower virtual memory has been created in prelog and
33175 * epilog.
33176 */
33177 - movl $1f, %edx
33178 - subl $__PAGE_OFFSET, %edx
33179 - jmp *%edx
33180 +#ifdef CONFIG_PAX_KERNEXEC
33181 + movl $(__KERNEXEC_EFI_DS), %edx
33182 + mov %edx, %ds
33183 + mov %edx, %es
33184 + mov %edx, %ss
33185 + addl $2f,(1f)
33186 + ljmp *(1f)
33187 +
33188 +__INITDATA
33189 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33190 +.previous
33191 +
33192 +2:
33193 + subl $2b,(1b)
33194 +#else
33195 + jmp 1f-__PAGE_OFFSET
33196 1:
33197 +#endif
33198
33199 /*
33200 * 2. Now on the top of stack is the return
33201 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33202 * parameter 2, ..., param n. To make things easy, we save the return
33203 * address of efi_call_phys in a global variable.
33204 */
33205 - popl %edx
33206 - movl %edx, saved_return_addr
33207 - /* get the function pointer into ECX*/
33208 - popl %ecx
33209 - movl %ecx, efi_rt_function_ptr
33210 - movl $2f, %edx
33211 - subl $__PAGE_OFFSET, %edx
33212 - pushl %edx
33213 + popl (saved_return_addr)
33214 + popl (efi_rt_function_ptr)
33215
33216 /*
33217 * 3. Clear PG bit in %CR0.
33218 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33219 /*
33220 * 5. Call the physical function.
33221 */
33222 - jmp *%ecx
33223 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33224
33225 -2:
33226 /*
33227 * 6. After EFI runtime service returns, control will return to
33228 * following instruction. We'd better readjust stack pointer first.
33229 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33230 movl %cr0, %edx
33231 orl $0x80000000, %edx
33232 movl %edx, %cr0
33233 - jmp 1f
33234 -1:
33235 +
33236 /*
33237 * 8. Now restore the virtual mode from flat mode by
33238 * adding EIP with PAGE_OFFSET.
33239 */
33240 - movl $1f, %edx
33241 - jmp *%edx
33242 +#ifdef CONFIG_PAX_KERNEXEC
33243 + movl $(__KERNEL_DS), %edx
33244 + mov %edx, %ds
33245 + mov %edx, %es
33246 + mov %edx, %ss
33247 + ljmp $(__KERNEL_CS),$1f
33248 +#else
33249 + jmp 1f+__PAGE_OFFSET
33250 +#endif
33251 1:
33252
33253 /*
33254 * 9. Balance the stack. And because EAX contain the return value,
33255 * we'd better not clobber it.
33256 */
33257 - leal efi_rt_function_ptr, %edx
33258 - movl (%edx), %ecx
33259 - pushl %ecx
33260 + pushl (efi_rt_function_ptr)
33261
33262 /*
33263 - * 10. Push the saved return address onto the stack and return.
33264 + * 10. Return to the saved return address.
33265 */
33266 - leal saved_return_addr, %edx
33267 - movl (%edx), %ecx
33268 - pushl %ecx
33269 - ret
33270 + jmpl *(saved_return_addr)
33271 ENDPROC(efi_call_phys)
33272 .previous
33273
33274 -.data
33275 +__INITDATA
33276 saved_return_addr:
33277 .long 0
33278 efi_rt_function_ptr:
33279 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33280 index 4c07cca..2c8427d 100644
33281 --- a/arch/x86/platform/efi/efi_stub_64.S
33282 +++ b/arch/x86/platform/efi/efi_stub_64.S
33283 @@ -7,6 +7,7 @@
33284 */
33285
33286 #include <linux/linkage.h>
33287 +#include <asm/alternative-asm.h>
33288
33289 #define SAVE_XMM \
33290 mov %rsp, %rax; \
33291 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33292 call *%rdi
33293 addq $32, %rsp
33294 RESTORE_XMM
33295 + pax_force_retaddr 0, 1
33296 ret
33297 ENDPROC(efi_call0)
33298
33299 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33300 call *%rdi
33301 addq $32, %rsp
33302 RESTORE_XMM
33303 + pax_force_retaddr 0, 1
33304 ret
33305 ENDPROC(efi_call1)
33306
33307 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33308 call *%rdi
33309 addq $32, %rsp
33310 RESTORE_XMM
33311 + pax_force_retaddr 0, 1
33312 ret
33313 ENDPROC(efi_call2)
33314
33315 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33316 call *%rdi
33317 addq $32, %rsp
33318 RESTORE_XMM
33319 + pax_force_retaddr 0, 1
33320 ret
33321 ENDPROC(efi_call3)
33322
33323 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33324 call *%rdi
33325 addq $32, %rsp
33326 RESTORE_XMM
33327 + pax_force_retaddr 0, 1
33328 ret
33329 ENDPROC(efi_call4)
33330
33331 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33332 call *%rdi
33333 addq $48, %rsp
33334 RESTORE_XMM
33335 + pax_force_retaddr 0, 1
33336 ret
33337 ENDPROC(efi_call5)
33338
33339 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33340 call *%rdi
33341 addq $48, %rsp
33342 RESTORE_XMM
33343 + pax_force_retaddr 0, 1
33344 ret
33345 ENDPROC(efi_call6)
33346 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33347 index 47fe66f..6206449 100644
33348 --- a/arch/x86/platform/mrst/mrst.c
33349 +++ b/arch/x86/platform/mrst/mrst.c
33350 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33351 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33352 int sfi_mrtc_num;
33353
33354 -static void mrst_power_off(void)
33355 +static __noreturn void mrst_power_off(void)
33356 {
33357 + BUG();
33358 }
33359
33360 -static void mrst_reboot(void)
33361 +static __noreturn void mrst_reboot(void)
33362 {
33363 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33364 + BUG();
33365 }
33366
33367 /* parse all the mtimer info to a static mtimer array */
33368 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33369 index d6ee929..3637cb5 100644
33370 --- a/arch/x86/platform/olpc/olpc_dt.c
33371 +++ b/arch/x86/platform/olpc/olpc_dt.c
33372 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33373 return res;
33374 }
33375
33376 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33377 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33378 .nextprop = olpc_dt_nextprop,
33379 .getproplen = olpc_dt_getproplen,
33380 .getproperty = olpc_dt_getproperty,
33381 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33382 index 1cf5b30..fd45732 100644
33383 --- a/arch/x86/power/cpu.c
33384 +++ b/arch/x86/power/cpu.c
33385 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33386 static void fix_processor_context(void)
33387 {
33388 int cpu = smp_processor_id();
33389 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33390 -#ifdef CONFIG_X86_64
33391 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33392 - tss_desc tss;
33393 -#endif
33394 + struct tss_struct *t = init_tss + cpu;
33395 +
33396 set_tss_desc(cpu, t); /*
33397 * This just modifies memory; should not be
33398 * necessary. But... This is necessary, because
33399 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33400 */
33401
33402 #ifdef CONFIG_X86_64
33403 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33404 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33405 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33406 -
33407 syscall_init(); /* This sets MSR_*STAR and related */
33408 #endif
33409 load_TR_desc(); /* This does ltr */
33410 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33411 index a44f457..9140171 100644
33412 --- a/arch/x86/realmode/init.c
33413 +++ b/arch/x86/realmode/init.c
33414 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33415 __va(real_mode_header->trampoline_header);
33416
33417 #ifdef CONFIG_X86_32
33418 - trampoline_header->start = __pa_symbol(startup_32_smp);
33419 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33420 +
33421 +#ifdef CONFIG_PAX_KERNEXEC
33422 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33423 +#endif
33424 +
33425 + trampoline_header->boot_cs = __BOOT_CS;
33426 trampoline_header->gdt_limit = __BOOT_DS + 7;
33427 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33428 #else
33429 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33430 *trampoline_cr4_features = read_cr4();
33431
33432 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33433 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33434 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33435 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33436 #endif
33437 }
33438 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33439 index 8869287..d577672 100644
33440 --- a/arch/x86/realmode/rm/Makefile
33441 +++ b/arch/x86/realmode/rm/Makefile
33442 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33443 $(call cc-option, -fno-unit-at-a-time)) \
33444 $(call cc-option, -fno-stack-protector) \
33445 $(call cc-option, -mpreferred-stack-boundary=2)
33446 +ifdef CONSTIFY_PLUGIN
33447 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33448 +endif
33449 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33450 GCOV_PROFILE := n
33451 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33452 index a28221d..93c40f1 100644
33453 --- a/arch/x86/realmode/rm/header.S
33454 +++ b/arch/x86/realmode/rm/header.S
33455 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33456 #endif
33457 /* APM/BIOS reboot */
33458 .long pa_machine_real_restart_asm
33459 -#ifdef CONFIG_X86_64
33460 +#ifdef CONFIG_X86_32
33461 + .long __KERNEL_CS
33462 +#else
33463 .long __KERNEL32_CS
33464 #endif
33465 END(real_mode_header)
33466 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33467 index c1b2791..f9e31c7 100644
33468 --- a/arch/x86/realmode/rm/trampoline_32.S
33469 +++ b/arch/x86/realmode/rm/trampoline_32.S
33470 @@ -25,6 +25,12 @@
33471 #include <asm/page_types.h>
33472 #include "realmode.h"
33473
33474 +#ifdef CONFIG_PAX_KERNEXEC
33475 +#define ta(X) (X)
33476 +#else
33477 +#define ta(X) (pa_ ## X)
33478 +#endif
33479 +
33480 .text
33481 .code16
33482
33483 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33484
33485 cli # We should be safe anyway
33486
33487 - movl tr_start, %eax # where we need to go
33488 -
33489 movl $0xA5A5A5A5, trampoline_status
33490 # write marker for master knows we're running
33491
33492 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33493 movw $1, %dx # protected mode (PE) bit
33494 lmsw %dx # into protected mode
33495
33496 - ljmpl $__BOOT_CS, $pa_startup_32
33497 + ljmpl *(trampoline_header)
33498
33499 .section ".text32","ax"
33500 .code32
33501 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33502 .balign 8
33503 GLOBAL(trampoline_header)
33504 tr_start: .space 4
33505 - tr_gdt_pad: .space 2
33506 + tr_boot_cs: .space 2
33507 tr_gdt: .space 6
33508 END(trampoline_header)
33509
33510 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33511 index bb360dc..d0fd8f8 100644
33512 --- a/arch/x86/realmode/rm/trampoline_64.S
33513 +++ b/arch/x86/realmode/rm/trampoline_64.S
33514 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33515 movl %edx, %gs
33516
33517 movl pa_tr_cr4, %eax
33518 + andl $~X86_CR4_PCIDE, %eax
33519 movl %eax, %cr4 # Enable PAE mode
33520
33521 # Setup trampoline 4 level pagetables
33522 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33523 wrmsr
33524
33525 # Enable paging and in turn activate Long Mode
33526 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33527 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33528 movl %eax, %cr0
33529
33530 /*
33531 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33532 index e812034..c747134 100644
33533 --- a/arch/x86/tools/Makefile
33534 +++ b/arch/x86/tools/Makefile
33535 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33536
33537 $(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
33538
33539 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33540 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33541 hostprogs-y += relocs
33542 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33543 relocs: $(obj)/relocs
33544 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33545 index f7bab68..b6d9886 100644
33546 --- a/arch/x86/tools/relocs.c
33547 +++ b/arch/x86/tools/relocs.c
33548 @@ -1,5 +1,7 @@
33549 /* This is included from relocs_32/64.c */
33550
33551 +#include "../../../include/generated/autoconf.h"
33552 +
33553 #define ElfW(type) _ElfW(ELF_BITS, type)
33554 #define _ElfW(bits, type) __ElfW(bits, type)
33555 #define __ElfW(bits, type) Elf##bits##_##type
33556 @@ -11,6 +13,7 @@
33557 #define Elf_Sym ElfW(Sym)
33558
33559 static Elf_Ehdr ehdr;
33560 +static Elf_Phdr *phdr;
33561
33562 struct relocs {
33563 uint32_t *offset;
33564 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33565 }
33566 }
33567
33568 +static void read_phdrs(FILE *fp)
33569 +{
33570 + unsigned int i;
33571 +
33572 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33573 + if (!phdr) {
33574 + die("Unable to allocate %d program headers\n",
33575 + ehdr.e_phnum);
33576 + }
33577 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33578 + die("Seek to %d failed: %s\n",
33579 + ehdr.e_phoff, strerror(errno));
33580 + }
33581 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33582 + die("Cannot read ELF program headers: %s\n",
33583 + strerror(errno));
33584 + }
33585 + for(i = 0; i < ehdr.e_phnum; i++) {
33586 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33587 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33588 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33589 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33590 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33591 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33592 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33593 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33594 + }
33595 +
33596 +}
33597 +
33598 static void read_shdrs(FILE *fp)
33599 {
33600 - int i;
33601 + unsigned int i;
33602 Elf_Shdr shdr;
33603
33604 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33605 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33606
33607 static void read_strtabs(FILE *fp)
33608 {
33609 - int i;
33610 + unsigned int i;
33611 for (i = 0; i < ehdr.e_shnum; i++) {
33612 struct section *sec = &secs[i];
33613 if (sec->shdr.sh_type != SHT_STRTAB) {
33614 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33615
33616 static void read_symtabs(FILE *fp)
33617 {
33618 - int i,j;
33619 + unsigned int i,j;
33620 for (i = 0; i < ehdr.e_shnum; i++) {
33621 struct section *sec = &secs[i];
33622 if (sec->shdr.sh_type != SHT_SYMTAB) {
33623 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33624 }
33625
33626
33627 -static void read_relocs(FILE *fp)
33628 +static void read_relocs(FILE *fp, int use_real_mode)
33629 {
33630 - int i,j;
33631 + unsigned int i,j;
33632 + uint32_t base;
33633 +
33634 for (i = 0; i < ehdr.e_shnum; i++) {
33635 struct section *sec = &secs[i];
33636 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33637 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33638 die("Cannot read symbol table: %s\n",
33639 strerror(errno));
33640 }
33641 + base = 0;
33642 +
33643 +#ifdef CONFIG_X86_32
33644 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33645 + if (phdr[j].p_type != PT_LOAD )
33646 + continue;
33647 + 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)
33648 + continue;
33649 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33650 + break;
33651 + }
33652 +#endif
33653 +
33654 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33655 Elf_Rel *rel = &sec->reltab[j];
33656 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33657 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33658 rel->r_info = elf_xword_to_cpu(rel->r_info);
33659 #if (SHT_REL_TYPE == SHT_RELA)
33660 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33661 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33662
33663 static void print_absolute_symbols(void)
33664 {
33665 - int i;
33666 + unsigned int i;
33667 const char *format;
33668
33669 if (ELF_BITS == 64)
33670 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33671 for (i = 0; i < ehdr.e_shnum; i++) {
33672 struct section *sec = &secs[i];
33673 char *sym_strtab;
33674 - int j;
33675 + unsigned int j;
33676
33677 if (sec->shdr.sh_type != SHT_SYMTAB) {
33678 continue;
33679 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33680
33681 static void print_absolute_relocs(void)
33682 {
33683 - int i, printed = 0;
33684 + unsigned int i, printed = 0;
33685 const char *format;
33686
33687 if (ELF_BITS == 64)
33688 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33689 struct section *sec_applies, *sec_symtab;
33690 char *sym_strtab;
33691 Elf_Sym *sh_symtab;
33692 - int j;
33693 + unsigned int j;
33694 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33695 continue;
33696 }
33697 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33698 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33699 Elf_Sym *sym, const char *symname))
33700 {
33701 - int i;
33702 + unsigned int i;
33703 /* Walk through the relocations */
33704 for (i = 0; i < ehdr.e_shnum; i++) {
33705 char *sym_strtab;
33706 Elf_Sym *sh_symtab;
33707 struct section *sec_applies, *sec_symtab;
33708 - int j;
33709 + unsigned int j;
33710 struct section *sec = &secs[i];
33711
33712 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33713 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33714 {
33715 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33716 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33717 + char *sym_strtab = sec->link->link->strtab;
33718 +
33719 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33720 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33721 + return 0;
33722 +
33723 +#ifdef CONFIG_PAX_KERNEXEC
33724 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33725 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33728 + return 0;
33729 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33730 + return 0;
33731 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33732 + return 0;
33733 +#endif
33734
33735 switch (r_type) {
33736 case R_386_NONE:
33737 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33738
33739 static void emit_relocs(int as_text, int use_real_mode)
33740 {
33741 - int i;
33742 + unsigned int i;
33743 int (*write_reloc)(uint32_t, FILE *) = write32;
33744 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33745 const char *symname);
33746 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33747 {
33748 regex_init(use_real_mode);
33749 read_ehdr(fp);
33750 + read_phdrs(fp);
33751 read_shdrs(fp);
33752 read_strtabs(fp);
33753 read_symtabs(fp);
33754 - read_relocs(fp);
33755 + read_relocs(fp, use_real_mode);
33756 if (ELF_BITS == 64)
33757 percpu_init();
33758 if (show_absolute_syms) {
33759 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33760 index 80ffa5b..a33bd15 100644
33761 --- a/arch/x86/um/tls_32.c
33762 +++ b/arch/x86/um/tls_32.c
33763 @@ -260,7 +260,7 @@ out:
33764 if (unlikely(task == current &&
33765 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33766 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33767 - "without flushed TLS.", current->pid);
33768 + "without flushed TLS.", task_pid_nr(current));
33769 }
33770
33771 return 0;
33772 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33773 index fd14be1..e3c79c0 100644
33774 --- a/arch/x86/vdso/Makefile
33775 +++ b/arch/x86/vdso/Makefile
33776 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33777 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33778 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33779
33780 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33781 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33782 GCOV_PROFILE := n
33783
33784 #
33785 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33786 index d6bfb87..876ee18 100644
33787 --- a/arch/x86/vdso/vdso32-setup.c
33788 +++ b/arch/x86/vdso/vdso32-setup.c
33789 @@ -25,6 +25,7 @@
33790 #include <asm/tlbflush.h>
33791 #include <asm/vdso.h>
33792 #include <asm/proto.h>
33793 +#include <asm/mman.h>
33794
33795 enum {
33796 VDSO_DISABLED = 0,
33797 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33798 void enable_sep_cpu(void)
33799 {
33800 int cpu = get_cpu();
33801 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33802 + struct tss_struct *tss = init_tss + cpu;
33803
33804 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33805 put_cpu();
33806 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33807 gate_vma.vm_start = FIXADDR_USER_START;
33808 gate_vma.vm_end = FIXADDR_USER_END;
33809 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33810 - gate_vma.vm_page_prot = __P101;
33811 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33812
33813 return 0;
33814 }
33815 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33816 if (compat)
33817 addr = VDSO_HIGH_BASE;
33818 else {
33819 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33820 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33821 if (IS_ERR_VALUE(addr)) {
33822 ret = addr;
33823 goto up_fail;
33824 }
33825 }
33826
33827 - current->mm->context.vdso = (void *)addr;
33828 + current->mm->context.vdso = addr;
33829
33830 if (compat_uses_vma || !compat) {
33831 /*
33832 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33833 }
33834
33835 current_thread_info()->sysenter_return =
33836 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33837 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33838
33839 up_fail:
33840 if (ret)
33841 - current->mm->context.vdso = NULL;
33842 + current->mm->context.vdso = 0;
33843
33844 up_write(&mm->mmap_sem);
33845
33846 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33847
33848 const char *arch_vma_name(struct vm_area_struct *vma)
33849 {
33850 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33851 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33852 return "[vdso]";
33853 +
33854 +#ifdef CONFIG_PAX_SEGMEXEC
33855 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33856 + return "[vdso]";
33857 +#endif
33858 +
33859 return NULL;
33860 }
33861
33862 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33863 * Check to see if the corresponding task was created in compat vdso
33864 * mode.
33865 */
33866 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33867 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33868 return &gate_vma;
33869 return NULL;
33870 }
33871 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33872 index 431e875..cbb23f3 100644
33873 --- a/arch/x86/vdso/vma.c
33874 +++ b/arch/x86/vdso/vma.c
33875 @@ -16,8 +16,6 @@
33876 #include <asm/vdso.h>
33877 #include <asm/page.h>
33878
33879 -unsigned int __read_mostly vdso_enabled = 1;
33880 -
33881 extern char vdso_start[], vdso_end[];
33882 extern unsigned short vdso_sync_cpuid;
33883
33884 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33885 * unaligned here as a result of stack start randomization.
33886 */
33887 addr = PAGE_ALIGN(addr);
33888 - addr = align_vdso_addr(addr);
33889
33890 return addr;
33891 }
33892 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33893 unsigned size)
33894 {
33895 struct mm_struct *mm = current->mm;
33896 - unsigned long addr;
33897 + unsigned long addr = 0;
33898 int ret;
33899
33900 - if (!vdso_enabled)
33901 - return 0;
33902 -
33903 down_write(&mm->mmap_sem);
33904 +
33905 +#ifdef CONFIG_PAX_RANDMMAP
33906 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33907 +#endif
33908 +
33909 addr = vdso_addr(mm->start_stack, size);
33910 + addr = align_vdso_addr(addr);
33911 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33912 if (IS_ERR_VALUE(addr)) {
33913 ret = addr;
33914 goto up_fail;
33915 }
33916
33917 - current->mm->context.vdso = (void *)addr;
33918 + mm->context.vdso = addr;
33919
33920 ret = install_special_mapping(mm, addr, size,
33921 VM_READ|VM_EXEC|
33922 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33923 pages);
33924 - if (ret) {
33925 - current->mm->context.vdso = NULL;
33926 - goto up_fail;
33927 - }
33928 + if (ret)
33929 + mm->context.vdso = 0;
33930
33931 up_fail:
33932 up_write(&mm->mmap_sem);
33933 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33934 vdsox32_size);
33935 }
33936 #endif
33937 -
33938 -static __init int vdso_setup(char *s)
33939 -{
33940 - vdso_enabled = simple_strtoul(s, NULL, 0);
33941 - return 0;
33942 -}
33943 -__setup("vdso=", vdso_setup);
33944 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33945 index 193097e..7590269 100644
33946 --- a/arch/x86/xen/enlighten.c
33947 +++ b/arch/x86/xen/enlighten.c
33948 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33949
33950 struct shared_info xen_dummy_shared_info;
33951
33952 -void *xen_initial_gdt;
33953 -
33954 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33955 __read_mostly int xen_have_vector_callback;
33956 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33957 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33958 {
33959 unsigned long va = dtr->address;
33960 unsigned int size = dtr->size + 1;
33961 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33962 - unsigned long frames[pages];
33963 + unsigned long frames[65536 / PAGE_SIZE];
33964 int f;
33965
33966 /*
33967 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33968 {
33969 unsigned long va = dtr->address;
33970 unsigned int size = dtr->size + 1;
33971 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33972 - unsigned long frames[pages];
33973 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33974 int f;
33975
33976 /*
33977 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33978 * 8-byte entries, or 16 4k pages..
33979 */
33980
33981 - BUG_ON(size > 65536);
33982 + BUG_ON(size > GDT_SIZE);
33983 BUG_ON(va & ~PAGE_MASK);
33984
33985 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33986 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33987 return 0;
33988 }
33989
33990 -static void set_xen_basic_apic_ops(void)
33991 +static void __init set_xen_basic_apic_ops(void)
33992 {
33993 apic->read = xen_apic_read;
33994 apic->write = xen_apic_write;
33995 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33996 #endif
33997 };
33998
33999 -static void xen_reboot(int reason)
34000 +static __noreturn void xen_reboot(int reason)
34001 {
34002 struct sched_shutdown r = { .reason = reason };
34003
34004 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34005 - BUG();
34006 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34007 + BUG();
34008 }
34009
34010 -static void xen_restart(char *msg)
34011 +static __noreturn void xen_restart(char *msg)
34012 {
34013 xen_reboot(SHUTDOWN_reboot);
34014 }
34015
34016 -static void xen_emergency_restart(void)
34017 +static __noreturn void xen_emergency_restart(void)
34018 {
34019 xen_reboot(SHUTDOWN_reboot);
34020 }
34021
34022 -static void xen_machine_halt(void)
34023 +static __noreturn void xen_machine_halt(void)
34024 {
34025 xen_reboot(SHUTDOWN_poweroff);
34026 }
34027
34028 -static void xen_machine_power_off(void)
34029 +static __noreturn void xen_machine_power_off(void)
34030 {
34031 if (pm_power_off)
34032 pm_power_off();
34033 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34034 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34035
34036 /* Work out if we support NX */
34037 - x86_configure_nx();
34038 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34039 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34040 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34041 + unsigned l, h;
34042 +
34043 + __supported_pte_mask |= _PAGE_NX;
34044 + rdmsr(MSR_EFER, l, h);
34045 + l |= EFER_NX;
34046 + wrmsr(MSR_EFER, l, h);
34047 + }
34048 +#endif
34049
34050 xen_setup_features();
34051
34052 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34053
34054 machine_ops = xen_machine_ops;
34055
34056 - /*
34057 - * The only reliable way to retain the initial address of the
34058 - * percpu gdt_page is to remember it here, so we can go and
34059 - * mark it RW later, when the initial percpu area is freed.
34060 - */
34061 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34062 -
34063 xen_smp_init();
34064
34065 #ifdef CONFIG_ACPI_NUMA
34066 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34067 index fdc3ba2..3daee39 100644
34068 --- a/arch/x86/xen/mmu.c
34069 +++ b/arch/x86/xen/mmu.c
34070 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34071 /* L3_k[510] -> level2_kernel_pgt
34072 * L3_i[511] -> level2_fixmap_pgt */
34073 convert_pfn_mfn(level3_kernel_pgt);
34074 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34075 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34076 + convert_pfn_mfn(level3_vmemmap_pgt);
34077
34078 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34079 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34080 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34081 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34082 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34083 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34084 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34085 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34086 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34088 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34089 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34090 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34091 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34092
34093 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34094 pv_mmu_ops.set_pud = xen_set_pud;
34095 #if PAGETABLE_LEVELS == 4
34096 pv_mmu_ops.set_pgd = xen_set_pgd;
34097 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34098 #endif
34099
34100 /* This will work as long as patching hasn't happened yet
34101 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34102 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34103 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34104 .set_pgd = xen_set_pgd_hyper,
34105 + .set_pgd_batched = xen_set_pgd_hyper,
34106
34107 .alloc_pud = xen_alloc_pmd_init,
34108 .release_pud = xen_release_pmd_init,
34109 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34110 index b81c88e..2cbe7b8 100644
34111 --- a/arch/x86/xen/smp.c
34112 +++ b/arch/x86/xen/smp.c
34113 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34114 {
34115 BUG_ON(smp_processor_id() != 0);
34116 native_smp_prepare_boot_cpu();
34117 -
34118 - /* We've switched to the "real" per-cpu gdt, so make sure the
34119 - old memory can be recycled */
34120 - make_lowmem_page_readwrite(xen_initial_gdt);
34121 -
34122 xen_filter_cpu_maps();
34123 xen_setup_vcpu_info_placement();
34124 }
34125 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34126 ctxt->user_regs.ss = __KERNEL_DS;
34127 #ifdef CONFIG_X86_32
34128 ctxt->user_regs.fs = __KERNEL_PERCPU;
34129 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34130 + savesegment(gs, ctxt->user_regs.gs);
34131 #else
34132 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34133 #endif
34134 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34135
34136 {
34137 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34138 - ctxt->user_regs.ds = __USER_DS;
34139 - ctxt->user_regs.es = __USER_DS;
34140 + ctxt->user_regs.ds = __KERNEL_DS;
34141 + ctxt->user_regs.es = __KERNEL_DS;
34142
34143 xen_copy_trap_info(ctxt->trap_ctxt);
34144
34145 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34146 int rc;
34147
34148 per_cpu(current_task, cpu) = idle;
34149 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34150 #ifdef CONFIG_X86_32
34151 irq_ctx_init(cpu);
34152 #else
34153 clear_tsk_thread_flag(idle, TIF_FORK);
34154 - per_cpu(kernel_stack, cpu) =
34155 - (unsigned long)task_stack_page(idle) -
34156 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34157 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34158 #endif
34159 xen_setup_runstate_info(cpu);
34160 xen_setup_timer(cpu);
34161 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34162
34163 void __init xen_smp_init(void)
34164 {
34165 - smp_ops = xen_smp_ops;
34166 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34167 xen_fill_possible_map();
34168 xen_init_spinlocks();
34169 }
34170 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34171 index 33ca6e4..0ded929 100644
34172 --- a/arch/x86/xen/xen-asm_32.S
34173 +++ b/arch/x86/xen/xen-asm_32.S
34174 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34175 ESP_OFFSET=4 # bytes pushed onto stack
34176
34177 /*
34178 - * Store vcpu_info pointer for easy access. Do it this way to
34179 - * avoid having to reload %fs
34180 + * Store vcpu_info pointer for easy access.
34181 */
34182 #ifdef CONFIG_SMP
34183 - GET_THREAD_INFO(%eax)
34184 - movl %ss:TI_cpu(%eax), %eax
34185 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34186 - mov %ss:xen_vcpu(%eax), %eax
34187 + push %fs
34188 + mov $(__KERNEL_PERCPU), %eax
34189 + mov %eax, %fs
34190 + mov PER_CPU_VAR(xen_vcpu), %eax
34191 + pop %fs
34192 #else
34193 movl %ss:xen_vcpu, %eax
34194 #endif
34195 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34196 index 7faed58..ba4427c 100644
34197 --- a/arch/x86/xen/xen-head.S
34198 +++ b/arch/x86/xen/xen-head.S
34199 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34200 #ifdef CONFIG_X86_32
34201 mov %esi,xen_start_info
34202 mov $init_thread_union+THREAD_SIZE,%esp
34203 +#ifdef CONFIG_SMP
34204 + movl $cpu_gdt_table,%edi
34205 + movl $__per_cpu_load,%eax
34206 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34207 + rorl $16,%eax
34208 + movb %al,__KERNEL_PERCPU + 4(%edi)
34209 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34210 + movl $__per_cpu_end - 1,%eax
34211 + subl $__per_cpu_start,%eax
34212 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34213 +#endif
34214 #else
34215 mov %rsi,xen_start_info
34216 mov $init_thread_union+THREAD_SIZE,%rsp
34217 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34218 index 86782c5..fa272c8 100644
34219 --- a/arch/x86/xen/xen-ops.h
34220 +++ b/arch/x86/xen/xen-ops.h
34221 @@ -10,8 +10,6 @@
34222 extern const char xen_hypervisor_callback[];
34223 extern const char xen_failsafe_callback[];
34224
34225 -extern void *xen_initial_gdt;
34226 -
34227 struct trap_info;
34228 void xen_copy_trap_info(struct trap_info *traps);
34229
34230 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34231 index 525bd3d..ef888b1 100644
34232 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34233 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34234 @@ -119,9 +119,9 @@
34235 ----------------------------------------------------------------------*/
34236
34237 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34238 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34239 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34240 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34241 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34242
34243 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34244 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34245 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34246 index 2f33760..835e50a 100644
34247 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34248 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34249 @@ -11,6 +11,7 @@
34250 #ifndef _XTENSA_CORE_H
34251 #define _XTENSA_CORE_H
34252
34253 +#include <linux/const.h>
34254
34255 /****************************************************************************
34256 Parameters Useful for Any Code, USER or PRIVILEGED
34257 @@ -112,9 +113,9 @@
34258 ----------------------------------------------------------------------*/
34259
34260 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34261 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34262 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34263 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34264 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34265
34266 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34267 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34268 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34269 index af00795..2bb8105 100644
34270 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34271 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34272 @@ -11,6 +11,7 @@
34273 #ifndef _XTENSA_CORE_CONFIGURATION_H
34274 #define _XTENSA_CORE_CONFIGURATION_H
34275
34276 +#include <linux/const.h>
34277
34278 /****************************************************************************
34279 Parameters Useful for Any Code, USER or PRIVILEGED
34280 @@ -118,9 +119,9 @@
34281 ----------------------------------------------------------------------*/
34282
34283 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34284 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34285 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34286 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34287 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34288
34289 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34290 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34291 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34292 index 290792a..416f287 100644
34293 --- a/block/blk-cgroup.c
34294 +++ b/block/blk-cgroup.c
34295 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34296
34297 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34298 {
34299 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34300 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34301 struct blkcg *blkcg;
34302 struct cgroup *parent = cgroup->parent;
34303
34304 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34305
34306 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34307 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34308 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34309 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34310 done:
34311 spin_lock_init(&blkcg->lock);
34312 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34313 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34314 index 4b8d9b54..a7178c0 100644
34315 --- a/block/blk-iopoll.c
34316 +++ b/block/blk-iopoll.c
34317 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34318 }
34319 EXPORT_SYMBOL(blk_iopoll_complete);
34320
34321 -static void blk_iopoll_softirq(struct softirq_action *h)
34322 +static __latent_entropy void blk_iopoll_softirq(void)
34323 {
34324 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34325 int rearm = 0, budget = blk_iopoll_budget;
34326 diff --git a/block/blk-map.c b/block/blk-map.c
34327 index 623e1cd..ca1e109 100644
34328 --- a/block/blk-map.c
34329 +++ b/block/blk-map.c
34330 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34331 if (!len || !kbuf)
34332 return -EINVAL;
34333
34334 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34335 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34336 if (do_copy)
34337 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34338 else
34339 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34340 index ec9e606..3f38839 100644
34341 --- a/block/blk-softirq.c
34342 +++ b/block/blk-softirq.c
34343 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34344 * Softirq action handler - move entries to local list and loop over them
34345 * while passing them to the queue registered handler.
34346 */
34347 -static void blk_done_softirq(struct softirq_action *h)
34348 +static __latent_entropy void blk_done_softirq(void)
34349 {
34350 struct list_head *cpu_list, local_list;
34351
34352 diff --git a/block/bsg.c b/block/bsg.c
34353 index 420a5a9..23834aa 100644
34354 --- a/block/bsg.c
34355 +++ b/block/bsg.c
34356 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34357 struct sg_io_v4 *hdr, struct bsg_device *bd,
34358 fmode_t has_write_perm)
34359 {
34360 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34361 + unsigned char *cmdptr;
34362 +
34363 if (hdr->request_len > BLK_MAX_CDB) {
34364 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34365 if (!rq->cmd)
34366 return -ENOMEM;
34367 - }
34368 + cmdptr = rq->cmd;
34369 + } else
34370 + cmdptr = tmpcmd;
34371
34372 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34373 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34374 hdr->request_len))
34375 return -EFAULT;
34376
34377 + if (cmdptr != rq->cmd)
34378 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34379 +
34380 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34381 if (blk_verify_command(rq->cmd, has_write_perm))
34382 return -EPERM;
34383 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34384 index 7e5d474..0cf0017 100644
34385 --- a/block/compat_ioctl.c
34386 +++ b/block/compat_ioctl.c
34387 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34388 err |= __get_user(f->spec1, &uf->spec1);
34389 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34390 err |= __get_user(name, &uf->name);
34391 - f->name = compat_ptr(name);
34392 + f->name = (void __force_kernel *)compat_ptr(name);
34393 if (err) {
34394 err = -EFAULT;
34395 goto out;
34396 diff --git a/block/genhd.c b/block/genhd.c
34397 index dadf42b..48dc887 100644
34398 --- a/block/genhd.c
34399 +++ b/block/genhd.c
34400 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34401
34402 /*
34403 * Register device numbers dev..(dev+range-1)
34404 - * range must be nonzero
34405 + * Noop if @range is zero.
34406 * The hash chain is sorted on range, so that subranges can override.
34407 */
34408 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34409 struct kobject *(*probe)(dev_t, int *, void *),
34410 int (*lock)(dev_t, void *), void *data)
34411 {
34412 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34413 + if (range)
34414 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34415 }
34416
34417 EXPORT_SYMBOL(blk_register_region);
34418
34419 +/* undo blk_register_region(), noop if @range is zero */
34420 void blk_unregister_region(dev_t devt, unsigned long range)
34421 {
34422 - kobj_unmap(bdev_map, devt, range);
34423 + if (range)
34424 + kobj_unmap(bdev_map, devt, range);
34425 }
34426
34427 EXPORT_SYMBOL(blk_unregister_region);
34428 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34429 index c85fc89..51e690b 100644
34430 --- a/block/partitions/efi.c
34431 +++ b/block/partitions/efi.c
34432 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34433 if (!gpt)
34434 return NULL;
34435
34436 + if (!le32_to_cpu(gpt->num_partition_entries))
34437 + return NULL;
34438 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34439 + if (!pte)
34440 + return NULL;
34441 +
34442 count = le32_to_cpu(gpt->num_partition_entries) *
34443 le32_to_cpu(gpt->sizeof_partition_entry);
34444 - if (!count)
34445 - return NULL;
34446 - pte = kmalloc(count, GFP_KERNEL);
34447 - if (!pte)
34448 - return NULL;
34449 -
34450 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34451 (u8 *) pte,
34452 count) < count) {
34453 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34454 index a5ffcc9..3cedc9c 100644
34455 --- a/block/scsi_ioctl.c
34456 +++ b/block/scsi_ioctl.c
34457 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34458 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34459 struct sg_io_hdr *hdr, fmode_t mode)
34460 {
34461 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34462 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34463 + unsigned char *cmdptr;
34464 +
34465 + if (rq->cmd != rq->__cmd)
34466 + cmdptr = rq->cmd;
34467 + else
34468 + cmdptr = tmpcmd;
34469 +
34470 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34471 return -EFAULT;
34472 +
34473 + if (cmdptr != rq->cmd)
34474 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34475 +
34476 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34477 return -EPERM;
34478
34479 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34480 int err;
34481 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34482 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34483 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34484 + unsigned char *cmdptr;
34485
34486 if (!sic)
34487 return -EINVAL;
34488 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34489 */
34490 err = -EFAULT;
34491 rq->cmd_len = cmdlen;
34492 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34493 +
34494 + if (rq->cmd != rq->__cmd)
34495 + cmdptr = rq->cmd;
34496 + else
34497 + cmdptr = tmpcmd;
34498 +
34499 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34500 goto error;
34501
34502 + if (rq->cmd != cmdptr)
34503 + memcpy(rq->cmd, cmdptr, cmdlen);
34504 +
34505 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34506 goto error;
34507
34508 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34509 index 7bdd61b..afec999 100644
34510 --- a/crypto/cryptd.c
34511 +++ b/crypto/cryptd.c
34512 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34513
34514 struct cryptd_blkcipher_request_ctx {
34515 crypto_completion_t complete;
34516 -};
34517 +} __no_const;
34518
34519 struct cryptd_hash_ctx {
34520 struct crypto_shash *child;
34521 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34522
34523 struct cryptd_aead_request_ctx {
34524 crypto_completion_t complete;
34525 -};
34526 +} __no_const;
34527
34528 static void cryptd_queue_worker(struct work_struct *work);
34529
34530 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34531 index f8c920c..ab2cb5a 100644
34532 --- a/crypto/pcrypt.c
34533 +++ b/crypto/pcrypt.c
34534 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34535 int ret;
34536
34537 pinst->kobj.kset = pcrypt_kset;
34538 - ret = kobject_add(&pinst->kobj, NULL, name);
34539 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34540 if (!ret)
34541 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34542
34543 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34544 index f220d64..d359ad6 100644
34545 --- a/drivers/acpi/apei/apei-internal.h
34546 +++ b/drivers/acpi/apei/apei-internal.h
34547 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34548 struct apei_exec_ins_type {
34549 u32 flags;
34550 apei_exec_ins_func_t run;
34551 -};
34552 +} __do_const;
34553
34554 struct apei_exec_context {
34555 u32 ip;
34556 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34557 index 33dc6a0..4b24b47 100644
34558 --- a/drivers/acpi/apei/cper.c
34559 +++ b/drivers/acpi/apei/cper.c
34560 @@ -39,12 +39,12 @@
34561 */
34562 u64 cper_next_record_id(void)
34563 {
34564 - static atomic64_t seq;
34565 + static atomic64_unchecked_t seq;
34566
34567 - if (!atomic64_read(&seq))
34568 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34569 + if (!atomic64_read_unchecked(&seq))
34570 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34571
34572 - return atomic64_inc_return(&seq);
34573 + return atomic64_inc_return_unchecked(&seq);
34574 }
34575 EXPORT_SYMBOL_GPL(cper_next_record_id);
34576
34577 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34578 index ec9b57d..9682b3a 100644
34579 --- a/drivers/acpi/apei/ghes.c
34580 +++ b/drivers/acpi/apei/ghes.c
34581 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34582 const struct acpi_hest_generic *generic,
34583 const struct acpi_hest_generic_status *estatus)
34584 {
34585 - static atomic_t seqno;
34586 + static atomic_unchecked_t seqno;
34587 unsigned int curr_seqno;
34588 char pfx_seq[64];
34589
34590 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34591 else
34592 pfx = KERN_ERR;
34593 }
34594 - curr_seqno = atomic_inc_return(&seqno);
34595 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34596 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34597 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34598 pfx_seq, generic->header.source_id);
34599 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34600 index be60399..778b33e8 100644
34601 --- a/drivers/acpi/bgrt.c
34602 +++ b/drivers/acpi/bgrt.c
34603 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34604 return -ENODEV;
34605
34606 sysfs_bin_attr_init(&image_attr);
34607 - image_attr.private = bgrt_image;
34608 - image_attr.size = bgrt_image_size;
34609 + pax_open_kernel();
34610 + *(void **)&image_attr.private = bgrt_image;
34611 + *(size_t *)&image_attr.size = bgrt_image_size;
34612 + pax_close_kernel();
34613
34614 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34615 if (!bgrt_kobj)
34616 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34617 index cb96296..b81293b 100644
34618 --- a/drivers/acpi/blacklist.c
34619 +++ b/drivers/acpi/blacklist.c
34620 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34621 u32 is_critical_error;
34622 };
34623
34624 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34625 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34626
34627 /*
34628 * POLICY: If *anything* doesn't work, put it on the blacklist.
34629 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34630 return 0;
34631 }
34632
34633 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34634 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34635 {
34636 .callback = dmi_disable_osi_vista,
34637 .ident = "Fujitsu Siemens",
34638 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34639 index f98dd00..7b69865 100644
34640 --- a/drivers/acpi/processor_idle.c
34641 +++ b/drivers/acpi/processor_idle.c
34642 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34643 {
34644 int i, count = CPUIDLE_DRIVER_STATE_START;
34645 struct acpi_processor_cx *cx;
34646 - struct cpuidle_state *state;
34647 + cpuidle_state_no_const *state;
34648 struct cpuidle_driver *drv = &acpi_idle_driver;
34649
34650 if (!pr->flags.power_setup_done)
34651 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34652 index 05306a5..733d1f0 100644
34653 --- a/drivers/acpi/sysfs.c
34654 +++ b/drivers/acpi/sysfs.c
34655 @@ -423,11 +423,11 @@ static u32 num_counters;
34656 static struct attribute **all_attrs;
34657 static u32 acpi_gpe_count;
34658
34659 -static struct attribute_group interrupt_stats_attr_group = {
34660 +static attribute_group_no_const interrupt_stats_attr_group = {
34661 .name = "interrupts",
34662 };
34663
34664 -static struct kobj_attribute *counter_attrs;
34665 +static kobj_attribute_no_const *counter_attrs;
34666
34667 static void delete_gpe_attr_array(void)
34668 {
34669 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34670 index acfd0f7..e5acb08 100644
34671 --- a/drivers/ata/libahci.c
34672 +++ b/drivers/ata/libahci.c
34673 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34674 }
34675 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34676
34677 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34678 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34679 struct ata_taskfile *tf, int is_cmd, u16 flags,
34680 unsigned long timeout_msec)
34681 {
34682 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34683 index c24354d..335c975 100644
34684 --- a/drivers/ata/libata-core.c
34685 +++ b/drivers/ata/libata-core.c
34686 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34687 static void ata_dev_xfermask(struct ata_device *dev);
34688 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34689
34690 -atomic_t ata_print_id = ATOMIC_INIT(0);
34691 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34692
34693 struct ata_force_param {
34694 const char *name;
34695 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34696 struct ata_port *ap;
34697 unsigned int tag;
34698
34699 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34700 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34701 ap = qc->ap;
34702
34703 qc->flags = 0;
34704 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34705 struct ata_port *ap;
34706 struct ata_link *link;
34707
34708 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34709 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34710 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34711 ap = qc->ap;
34712 link = qc->dev->link;
34713 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34714 return;
34715
34716 spin_lock(&lock);
34717 + pax_open_kernel();
34718
34719 for (cur = ops->inherits; cur; cur = cur->inherits) {
34720 void **inherit = (void **)cur;
34721 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34722 if (IS_ERR(*pp))
34723 *pp = NULL;
34724
34725 - ops->inherits = NULL;
34726 + *(struct ata_port_operations **)&ops->inherits = NULL;
34727
34728 + pax_close_kernel();
34729 spin_unlock(&lock);
34730 }
34731
34732 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34733
34734 /* give ports names and add SCSI hosts */
34735 for (i = 0; i < host->n_ports; i++) {
34736 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34737 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34738 host->ports[i]->local_port_no = i + 1;
34739 }
34740
34741 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34742 index b1e880a..8cf82e1 100644
34743 --- a/drivers/ata/libata-scsi.c
34744 +++ b/drivers/ata/libata-scsi.c
34745 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34746
34747 if (rc)
34748 return rc;
34749 - ap->print_id = atomic_inc_return(&ata_print_id);
34750 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34751 return 0;
34752 }
34753 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34754 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34755 index 577d902b..cb4781e 100644
34756 --- a/drivers/ata/libata.h
34757 +++ b/drivers/ata/libata.h
34758 @@ -53,7 +53,7 @@ enum {
34759 ATA_DNXFER_QUIET = (1 << 31),
34760 };
34761
34762 -extern atomic_t ata_print_id;
34763 +extern atomic_unchecked_t ata_print_id;
34764 extern int atapi_passthru16;
34765 extern int libata_fua;
34766 extern int libata_noacpi;
34767 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34768 index 848ed32..132f39d 100644
34769 --- a/drivers/ata/pata_arasan_cf.c
34770 +++ b/drivers/ata/pata_arasan_cf.c
34771 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34772 /* Handle platform specific quirks */
34773 if (quirk) {
34774 if (quirk & CF_BROKEN_PIO) {
34775 - ap->ops->set_piomode = NULL;
34776 + pax_open_kernel();
34777 + *(void **)&ap->ops->set_piomode = NULL;
34778 + pax_close_kernel();
34779 ap->pio_mask = 0;
34780 }
34781 if (quirk & CF_BROKEN_MWDMA)
34782 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34783 index f9b983a..887b9d8 100644
34784 --- a/drivers/atm/adummy.c
34785 +++ b/drivers/atm/adummy.c
34786 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34787 vcc->pop(vcc, skb);
34788 else
34789 dev_kfree_skb_any(skb);
34790 - atomic_inc(&vcc->stats->tx);
34791 + atomic_inc_unchecked(&vcc->stats->tx);
34792
34793 return 0;
34794 }
34795 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34796 index 62a7607..cc4be104 100644
34797 --- a/drivers/atm/ambassador.c
34798 +++ b/drivers/atm/ambassador.c
34799 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34800 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34801
34802 // VC layer stats
34803 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34804 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34805
34806 // free the descriptor
34807 kfree (tx_descr);
34808 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34809 dump_skb ("<<<", vc, skb);
34810
34811 // VC layer stats
34812 - atomic_inc(&atm_vcc->stats->rx);
34813 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34814 __net_timestamp(skb);
34815 // end of our responsibility
34816 atm_vcc->push (atm_vcc, skb);
34817 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34818 } else {
34819 PRINTK (KERN_INFO, "dropped over-size frame");
34820 // should we count this?
34821 - atomic_inc(&atm_vcc->stats->rx_drop);
34822 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34823 }
34824
34825 } else {
34826 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34827 }
34828
34829 if (check_area (skb->data, skb->len)) {
34830 - atomic_inc(&atm_vcc->stats->tx_err);
34831 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34832 return -ENOMEM; // ?
34833 }
34834
34835 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34836 index 0e3f8f9..765a7a5 100644
34837 --- a/drivers/atm/atmtcp.c
34838 +++ b/drivers/atm/atmtcp.c
34839 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34840 if (vcc->pop) vcc->pop(vcc,skb);
34841 else dev_kfree_skb(skb);
34842 if (dev_data) return 0;
34843 - atomic_inc(&vcc->stats->tx_err);
34844 + atomic_inc_unchecked(&vcc->stats->tx_err);
34845 return -ENOLINK;
34846 }
34847 size = skb->len+sizeof(struct atmtcp_hdr);
34848 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34849 if (!new_skb) {
34850 if (vcc->pop) vcc->pop(vcc,skb);
34851 else dev_kfree_skb(skb);
34852 - atomic_inc(&vcc->stats->tx_err);
34853 + atomic_inc_unchecked(&vcc->stats->tx_err);
34854 return -ENOBUFS;
34855 }
34856 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34857 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34858 if (vcc->pop) vcc->pop(vcc,skb);
34859 else dev_kfree_skb(skb);
34860 out_vcc->push(out_vcc,new_skb);
34861 - atomic_inc(&vcc->stats->tx);
34862 - atomic_inc(&out_vcc->stats->rx);
34863 + atomic_inc_unchecked(&vcc->stats->tx);
34864 + atomic_inc_unchecked(&out_vcc->stats->rx);
34865 return 0;
34866 }
34867
34868 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34869 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34870 read_unlock(&vcc_sklist_lock);
34871 if (!out_vcc) {
34872 - atomic_inc(&vcc->stats->tx_err);
34873 + atomic_inc_unchecked(&vcc->stats->tx_err);
34874 goto done;
34875 }
34876 skb_pull(skb,sizeof(struct atmtcp_hdr));
34877 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34878 __net_timestamp(new_skb);
34879 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34880 out_vcc->push(out_vcc,new_skb);
34881 - atomic_inc(&vcc->stats->tx);
34882 - atomic_inc(&out_vcc->stats->rx);
34883 + atomic_inc_unchecked(&vcc->stats->tx);
34884 + atomic_inc_unchecked(&out_vcc->stats->rx);
34885 done:
34886 if (vcc->pop) vcc->pop(vcc,skb);
34887 else dev_kfree_skb(skb);
34888 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34889 index b1955ba..b179940 100644
34890 --- a/drivers/atm/eni.c
34891 +++ b/drivers/atm/eni.c
34892 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34893 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34894 vcc->dev->number);
34895 length = 0;
34896 - atomic_inc(&vcc->stats->rx_err);
34897 + atomic_inc_unchecked(&vcc->stats->rx_err);
34898 }
34899 else {
34900 length = ATM_CELL_SIZE-1; /* no HEC */
34901 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34902 size);
34903 }
34904 eff = length = 0;
34905 - atomic_inc(&vcc->stats->rx_err);
34906 + atomic_inc_unchecked(&vcc->stats->rx_err);
34907 }
34908 else {
34909 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34910 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34911 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34912 vcc->dev->number,vcc->vci,length,size << 2,descr);
34913 length = eff = 0;
34914 - atomic_inc(&vcc->stats->rx_err);
34915 + atomic_inc_unchecked(&vcc->stats->rx_err);
34916 }
34917 }
34918 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34919 @@ -767,7 +767,7 @@ rx_dequeued++;
34920 vcc->push(vcc,skb);
34921 pushed++;
34922 }
34923 - atomic_inc(&vcc->stats->rx);
34924 + atomic_inc_unchecked(&vcc->stats->rx);
34925 }
34926 wake_up(&eni_dev->rx_wait);
34927 }
34928 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34929 PCI_DMA_TODEVICE);
34930 if (vcc->pop) vcc->pop(vcc,skb);
34931 else dev_kfree_skb_irq(skb);
34932 - atomic_inc(&vcc->stats->tx);
34933 + atomic_inc_unchecked(&vcc->stats->tx);
34934 wake_up(&eni_dev->tx_wait);
34935 dma_complete++;
34936 }
34937 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34938 index b41c948..a002b17 100644
34939 --- a/drivers/atm/firestream.c
34940 +++ b/drivers/atm/firestream.c
34941 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34942 }
34943 }
34944
34945 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34946 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34947
34948 fs_dprintk (FS_DEBUG_TXMEM, "i");
34949 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34950 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34951 #endif
34952 skb_put (skb, qe->p1 & 0xffff);
34953 ATM_SKB(skb)->vcc = atm_vcc;
34954 - atomic_inc(&atm_vcc->stats->rx);
34955 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34956 __net_timestamp(skb);
34957 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34958 atm_vcc->push (atm_vcc, skb);
34959 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34960 kfree (pe);
34961 }
34962 if (atm_vcc)
34963 - atomic_inc(&atm_vcc->stats->rx_drop);
34964 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34965 break;
34966 case 0x1f: /* Reassembly abort: no buffers. */
34967 /* Silently increment error counter. */
34968 if (atm_vcc)
34969 - atomic_inc(&atm_vcc->stats->rx_drop);
34970 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34971 break;
34972 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34973 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34974 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34975 index 204814e..cede831 100644
34976 --- a/drivers/atm/fore200e.c
34977 +++ b/drivers/atm/fore200e.c
34978 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34979 #endif
34980 /* check error condition */
34981 if (*entry->status & STATUS_ERROR)
34982 - atomic_inc(&vcc->stats->tx_err);
34983 + atomic_inc_unchecked(&vcc->stats->tx_err);
34984 else
34985 - atomic_inc(&vcc->stats->tx);
34986 + atomic_inc_unchecked(&vcc->stats->tx);
34987 }
34988 }
34989
34990 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34991 if (skb == NULL) {
34992 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34993
34994 - atomic_inc(&vcc->stats->rx_drop);
34995 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34996 return -ENOMEM;
34997 }
34998
34999 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35000
35001 dev_kfree_skb_any(skb);
35002
35003 - atomic_inc(&vcc->stats->rx_drop);
35004 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35005 return -ENOMEM;
35006 }
35007
35008 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35009
35010 vcc->push(vcc, skb);
35011 - atomic_inc(&vcc->stats->rx);
35012 + atomic_inc_unchecked(&vcc->stats->rx);
35013
35014 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35015
35016 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35017 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35018 fore200e->atm_dev->number,
35019 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35020 - atomic_inc(&vcc->stats->rx_err);
35021 + atomic_inc_unchecked(&vcc->stats->rx_err);
35022 }
35023 }
35024
35025 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35026 goto retry_here;
35027 }
35028
35029 - atomic_inc(&vcc->stats->tx_err);
35030 + atomic_inc_unchecked(&vcc->stats->tx_err);
35031
35032 fore200e->tx_sat++;
35033 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35034 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35035 index 507362a..a845e57 100644
35036 --- a/drivers/atm/he.c
35037 +++ b/drivers/atm/he.c
35038 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35039
35040 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35041 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35042 - atomic_inc(&vcc->stats->rx_drop);
35043 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35044 goto return_host_buffers;
35045 }
35046
35047 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35048 RBRQ_LEN_ERR(he_dev->rbrq_head)
35049 ? "LEN_ERR" : "",
35050 vcc->vpi, vcc->vci);
35051 - atomic_inc(&vcc->stats->rx_err);
35052 + atomic_inc_unchecked(&vcc->stats->rx_err);
35053 goto return_host_buffers;
35054 }
35055
35056 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35057 vcc->push(vcc, skb);
35058 spin_lock(&he_dev->global_lock);
35059
35060 - atomic_inc(&vcc->stats->rx);
35061 + atomic_inc_unchecked(&vcc->stats->rx);
35062
35063 return_host_buffers:
35064 ++pdus_assembled;
35065 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35066 tpd->vcc->pop(tpd->vcc, tpd->skb);
35067 else
35068 dev_kfree_skb_any(tpd->skb);
35069 - atomic_inc(&tpd->vcc->stats->tx_err);
35070 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35071 }
35072 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35073 return;
35074 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35075 vcc->pop(vcc, skb);
35076 else
35077 dev_kfree_skb_any(skb);
35078 - atomic_inc(&vcc->stats->tx_err);
35079 + atomic_inc_unchecked(&vcc->stats->tx_err);
35080 return -EINVAL;
35081 }
35082
35083 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35084 vcc->pop(vcc, skb);
35085 else
35086 dev_kfree_skb_any(skb);
35087 - atomic_inc(&vcc->stats->tx_err);
35088 + atomic_inc_unchecked(&vcc->stats->tx_err);
35089 return -EINVAL;
35090 }
35091 #endif
35092 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35093 vcc->pop(vcc, skb);
35094 else
35095 dev_kfree_skb_any(skb);
35096 - atomic_inc(&vcc->stats->tx_err);
35097 + atomic_inc_unchecked(&vcc->stats->tx_err);
35098 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35099 return -ENOMEM;
35100 }
35101 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35102 vcc->pop(vcc, skb);
35103 else
35104 dev_kfree_skb_any(skb);
35105 - atomic_inc(&vcc->stats->tx_err);
35106 + atomic_inc_unchecked(&vcc->stats->tx_err);
35107 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35108 return -ENOMEM;
35109 }
35110 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35111 __enqueue_tpd(he_dev, tpd, cid);
35112 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35113
35114 - atomic_inc(&vcc->stats->tx);
35115 + atomic_inc_unchecked(&vcc->stats->tx);
35116
35117 return 0;
35118 }
35119 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35120 index 1dc0519..1aadaf7 100644
35121 --- a/drivers/atm/horizon.c
35122 +++ b/drivers/atm/horizon.c
35123 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35124 {
35125 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35126 // VC layer stats
35127 - atomic_inc(&vcc->stats->rx);
35128 + atomic_inc_unchecked(&vcc->stats->rx);
35129 __net_timestamp(skb);
35130 // end of our responsibility
35131 vcc->push (vcc, skb);
35132 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35133 dev->tx_iovec = NULL;
35134
35135 // VC layer stats
35136 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35137 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35138
35139 // free the skb
35140 hrz_kfree_skb (skb);
35141 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35142 index 272f009..a18ba55 100644
35143 --- a/drivers/atm/idt77252.c
35144 +++ b/drivers/atm/idt77252.c
35145 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35146 else
35147 dev_kfree_skb(skb);
35148
35149 - atomic_inc(&vcc->stats->tx);
35150 + atomic_inc_unchecked(&vcc->stats->tx);
35151 }
35152
35153 atomic_dec(&scq->used);
35154 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35155 if ((sb = dev_alloc_skb(64)) == NULL) {
35156 printk("%s: Can't allocate buffers for aal0.\n",
35157 card->name);
35158 - atomic_add(i, &vcc->stats->rx_drop);
35159 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35160 break;
35161 }
35162 if (!atm_charge(vcc, sb->truesize)) {
35163 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35164 card->name);
35165 - atomic_add(i - 1, &vcc->stats->rx_drop);
35166 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35167 dev_kfree_skb(sb);
35168 break;
35169 }
35170 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35171 ATM_SKB(sb)->vcc = vcc;
35172 __net_timestamp(sb);
35173 vcc->push(vcc, sb);
35174 - atomic_inc(&vcc->stats->rx);
35175 + atomic_inc_unchecked(&vcc->stats->rx);
35176
35177 cell += ATM_CELL_PAYLOAD;
35178 }
35179 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35180 "(CDC: %08x)\n",
35181 card->name, len, rpp->len, readl(SAR_REG_CDC));
35182 recycle_rx_pool_skb(card, rpp);
35183 - atomic_inc(&vcc->stats->rx_err);
35184 + atomic_inc_unchecked(&vcc->stats->rx_err);
35185 return;
35186 }
35187 if (stat & SAR_RSQE_CRC) {
35188 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35189 recycle_rx_pool_skb(card, rpp);
35190 - atomic_inc(&vcc->stats->rx_err);
35191 + atomic_inc_unchecked(&vcc->stats->rx_err);
35192 return;
35193 }
35194 if (skb_queue_len(&rpp->queue) > 1) {
35195 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35196 RXPRINTK("%s: Can't alloc RX skb.\n",
35197 card->name);
35198 recycle_rx_pool_skb(card, rpp);
35199 - atomic_inc(&vcc->stats->rx_err);
35200 + atomic_inc_unchecked(&vcc->stats->rx_err);
35201 return;
35202 }
35203 if (!atm_charge(vcc, skb->truesize)) {
35204 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35205 __net_timestamp(skb);
35206
35207 vcc->push(vcc, skb);
35208 - atomic_inc(&vcc->stats->rx);
35209 + atomic_inc_unchecked(&vcc->stats->rx);
35210
35211 return;
35212 }
35213 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35214 __net_timestamp(skb);
35215
35216 vcc->push(vcc, skb);
35217 - atomic_inc(&vcc->stats->rx);
35218 + atomic_inc_unchecked(&vcc->stats->rx);
35219
35220 if (skb->truesize > SAR_FB_SIZE_3)
35221 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35222 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35223 if (vcc->qos.aal != ATM_AAL0) {
35224 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35225 card->name, vpi, vci);
35226 - atomic_inc(&vcc->stats->rx_drop);
35227 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35228 goto drop;
35229 }
35230
35231 if ((sb = dev_alloc_skb(64)) == NULL) {
35232 printk("%s: Can't allocate buffers for AAL0.\n",
35233 card->name);
35234 - atomic_inc(&vcc->stats->rx_err);
35235 + atomic_inc_unchecked(&vcc->stats->rx_err);
35236 goto drop;
35237 }
35238
35239 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35240 ATM_SKB(sb)->vcc = vcc;
35241 __net_timestamp(sb);
35242 vcc->push(vcc, sb);
35243 - atomic_inc(&vcc->stats->rx);
35244 + atomic_inc_unchecked(&vcc->stats->rx);
35245
35246 drop:
35247 skb_pull(queue, 64);
35248 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35249
35250 if (vc == NULL) {
35251 printk("%s: NULL connection in send().\n", card->name);
35252 - atomic_inc(&vcc->stats->tx_err);
35253 + atomic_inc_unchecked(&vcc->stats->tx_err);
35254 dev_kfree_skb(skb);
35255 return -EINVAL;
35256 }
35257 if (!test_bit(VCF_TX, &vc->flags)) {
35258 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35259 - atomic_inc(&vcc->stats->tx_err);
35260 + atomic_inc_unchecked(&vcc->stats->tx_err);
35261 dev_kfree_skb(skb);
35262 return -EINVAL;
35263 }
35264 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35265 break;
35266 default:
35267 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35268 - atomic_inc(&vcc->stats->tx_err);
35269 + atomic_inc_unchecked(&vcc->stats->tx_err);
35270 dev_kfree_skb(skb);
35271 return -EINVAL;
35272 }
35273
35274 if (skb_shinfo(skb)->nr_frags != 0) {
35275 printk("%s: No scatter-gather yet.\n", card->name);
35276 - atomic_inc(&vcc->stats->tx_err);
35277 + atomic_inc_unchecked(&vcc->stats->tx_err);
35278 dev_kfree_skb(skb);
35279 return -EINVAL;
35280 }
35281 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35282
35283 err = queue_skb(card, vc, skb, oam);
35284 if (err) {
35285 - atomic_inc(&vcc->stats->tx_err);
35286 + atomic_inc_unchecked(&vcc->stats->tx_err);
35287 dev_kfree_skb(skb);
35288 return err;
35289 }
35290 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35291 skb = dev_alloc_skb(64);
35292 if (!skb) {
35293 printk("%s: Out of memory in send_oam().\n", card->name);
35294 - atomic_inc(&vcc->stats->tx_err);
35295 + atomic_inc_unchecked(&vcc->stats->tx_err);
35296 return -ENOMEM;
35297 }
35298 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35299 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35300 index 4217f29..88f547a 100644
35301 --- a/drivers/atm/iphase.c
35302 +++ b/drivers/atm/iphase.c
35303 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35304 status = (u_short) (buf_desc_ptr->desc_mode);
35305 if (status & (RX_CER | RX_PTE | RX_OFL))
35306 {
35307 - atomic_inc(&vcc->stats->rx_err);
35308 + atomic_inc_unchecked(&vcc->stats->rx_err);
35309 IF_ERR(printk("IA: bad packet, dropping it");)
35310 if (status & RX_CER) {
35311 IF_ERR(printk(" cause: packet CRC error\n");)
35312 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35313 len = dma_addr - buf_addr;
35314 if (len > iadev->rx_buf_sz) {
35315 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35316 - atomic_inc(&vcc->stats->rx_err);
35317 + atomic_inc_unchecked(&vcc->stats->rx_err);
35318 goto out_free_desc;
35319 }
35320
35321 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35322 ia_vcc = INPH_IA_VCC(vcc);
35323 if (ia_vcc == NULL)
35324 {
35325 - atomic_inc(&vcc->stats->rx_err);
35326 + atomic_inc_unchecked(&vcc->stats->rx_err);
35327 atm_return(vcc, skb->truesize);
35328 dev_kfree_skb_any(skb);
35329 goto INCR_DLE;
35330 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35331 if ((length > iadev->rx_buf_sz) || (length >
35332 (skb->len - sizeof(struct cpcs_trailer))))
35333 {
35334 - atomic_inc(&vcc->stats->rx_err);
35335 + atomic_inc_unchecked(&vcc->stats->rx_err);
35336 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35337 length, skb->len);)
35338 atm_return(vcc, skb->truesize);
35339 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35340
35341 IF_RX(printk("rx_dle_intr: skb push");)
35342 vcc->push(vcc,skb);
35343 - atomic_inc(&vcc->stats->rx);
35344 + atomic_inc_unchecked(&vcc->stats->rx);
35345 iadev->rx_pkt_cnt++;
35346 }
35347 INCR_DLE:
35348 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35349 {
35350 struct k_sonet_stats *stats;
35351 stats = &PRIV(_ia_dev[board])->sonet_stats;
35352 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35353 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35354 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35355 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35356 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35357 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35358 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35359 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35360 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35361 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35362 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35363 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35364 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35365 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35366 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35367 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35368 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35369 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35370 }
35371 ia_cmds.status = 0;
35372 break;
35373 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35374 if ((desc == 0) || (desc > iadev->num_tx_desc))
35375 {
35376 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35377 - atomic_inc(&vcc->stats->tx);
35378 + atomic_inc_unchecked(&vcc->stats->tx);
35379 if (vcc->pop)
35380 vcc->pop(vcc, skb);
35381 else
35382 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35383 ATM_DESC(skb) = vcc->vci;
35384 skb_queue_tail(&iadev->tx_dma_q, skb);
35385
35386 - atomic_inc(&vcc->stats->tx);
35387 + atomic_inc_unchecked(&vcc->stats->tx);
35388 iadev->tx_pkt_cnt++;
35389 /* Increment transaction counter */
35390 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35391
35392 #if 0
35393 /* add flow control logic */
35394 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35395 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35396 if (iavcc->vc_desc_cnt > 10) {
35397 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35398 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35399 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35400 index fa7d701..1e404c7 100644
35401 --- a/drivers/atm/lanai.c
35402 +++ b/drivers/atm/lanai.c
35403 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35404 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35405 lanai_endtx(lanai, lvcc);
35406 lanai_free_skb(lvcc->tx.atmvcc, skb);
35407 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35408 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35409 }
35410
35411 /* Try to fill the buffer - don't call unless there is backlog */
35412 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35413 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35414 __net_timestamp(skb);
35415 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35416 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35417 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35418 out:
35419 lvcc->rx.buf.ptr = end;
35420 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35421 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35422 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35423 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35424 lanai->stats.service_rxnotaal5++;
35425 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35426 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35427 return 0;
35428 }
35429 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35430 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35431 int bytes;
35432 read_unlock(&vcc_sklist_lock);
35433 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35434 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35435 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35436 lvcc->stats.x.aal5.service_trash++;
35437 bytes = (SERVICE_GET_END(s) * 16) -
35438 (((unsigned long) lvcc->rx.buf.ptr) -
35439 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35440 }
35441 if (s & SERVICE_STREAM) {
35442 read_unlock(&vcc_sklist_lock);
35443 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35444 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35445 lvcc->stats.x.aal5.service_stream++;
35446 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35447 "PDU on VCI %d!\n", lanai->number, vci);
35448 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35449 return 0;
35450 }
35451 DPRINTK("got rx crc error on vci %d\n", vci);
35452 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35453 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35454 lvcc->stats.x.aal5.service_rxcrc++;
35455 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35456 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35457 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35458 index 6587dc2..149833d 100644
35459 --- a/drivers/atm/nicstar.c
35460 +++ b/drivers/atm/nicstar.c
35461 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35462 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35463 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35464 card->index);
35465 - atomic_inc(&vcc->stats->tx_err);
35466 + atomic_inc_unchecked(&vcc->stats->tx_err);
35467 dev_kfree_skb_any(skb);
35468 return -EINVAL;
35469 }
35470 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35471 if (!vc->tx) {
35472 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35473 card->index);
35474 - atomic_inc(&vcc->stats->tx_err);
35475 + atomic_inc_unchecked(&vcc->stats->tx_err);
35476 dev_kfree_skb_any(skb);
35477 return -EINVAL;
35478 }
35479 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35480 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35481 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35482 card->index);
35483 - atomic_inc(&vcc->stats->tx_err);
35484 + atomic_inc_unchecked(&vcc->stats->tx_err);
35485 dev_kfree_skb_any(skb);
35486 return -EINVAL;
35487 }
35488
35489 if (skb_shinfo(skb)->nr_frags != 0) {
35490 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35491 - atomic_inc(&vcc->stats->tx_err);
35492 + atomic_inc_unchecked(&vcc->stats->tx_err);
35493 dev_kfree_skb_any(skb);
35494 return -EINVAL;
35495 }
35496 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35497 }
35498
35499 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35500 - atomic_inc(&vcc->stats->tx_err);
35501 + atomic_inc_unchecked(&vcc->stats->tx_err);
35502 dev_kfree_skb_any(skb);
35503 return -EIO;
35504 }
35505 - atomic_inc(&vcc->stats->tx);
35506 + atomic_inc_unchecked(&vcc->stats->tx);
35507
35508 return 0;
35509 }
35510 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35511 printk
35512 ("nicstar%d: Can't allocate buffers for aal0.\n",
35513 card->index);
35514 - atomic_add(i, &vcc->stats->rx_drop);
35515 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35516 break;
35517 }
35518 if (!atm_charge(vcc, sb->truesize)) {
35519 RXPRINTK
35520 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35521 card->index);
35522 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35523 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35524 dev_kfree_skb_any(sb);
35525 break;
35526 }
35527 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35528 ATM_SKB(sb)->vcc = vcc;
35529 __net_timestamp(sb);
35530 vcc->push(vcc, sb);
35531 - atomic_inc(&vcc->stats->rx);
35532 + atomic_inc_unchecked(&vcc->stats->rx);
35533 cell += ATM_CELL_PAYLOAD;
35534 }
35535
35536 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35537 if (iovb == NULL) {
35538 printk("nicstar%d: Out of iovec buffers.\n",
35539 card->index);
35540 - atomic_inc(&vcc->stats->rx_drop);
35541 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35542 recycle_rx_buf(card, skb);
35543 return;
35544 }
35545 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35546 small or large buffer itself. */
35547 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35548 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35549 - atomic_inc(&vcc->stats->rx_err);
35550 + atomic_inc_unchecked(&vcc->stats->rx_err);
35551 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35552 NS_MAX_IOVECS);
35553 NS_PRV_IOVCNT(iovb) = 0;
35554 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35555 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35556 card->index);
35557 which_list(card, skb);
35558 - atomic_inc(&vcc->stats->rx_err);
35559 + atomic_inc_unchecked(&vcc->stats->rx_err);
35560 recycle_rx_buf(card, skb);
35561 vc->rx_iov = NULL;
35562 recycle_iov_buf(card, iovb);
35563 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35564 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35565 card->index);
35566 which_list(card, skb);
35567 - atomic_inc(&vcc->stats->rx_err);
35568 + atomic_inc_unchecked(&vcc->stats->rx_err);
35569 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35570 NS_PRV_IOVCNT(iovb));
35571 vc->rx_iov = NULL;
35572 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35573 printk(" - PDU size mismatch.\n");
35574 else
35575 printk(".\n");
35576 - atomic_inc(&vcc->stats->rx_err);
35577 + atomic_inc_unchecked(&vcc->stats->rx_err);
35578 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35579 NS_PRV_IOVCNT(iovb));
35580 vc->rx_iov = NULL;
35581 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35582 /* skb points to a small buffer */
35583 if (!atm_charge(vcc, skb->truesize)) {
35584 push_rxbufs(card, skb);
35585 - atomic_inc(&vcc->stats->rx_drop);
35586 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35587 } else {
35588 skb_put(skb, len);
35589 dequeue_sm_buf(card, skb);
35590 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35591 ATM_SKB(skb)->vcc = vcc;
35592 __net_timestamp(skb);
35593 vcc->push(vcc, skb);
35594 - atomic_inc(&vcc->stats->rx);
35595 + atomic_inc_unchecked(&vcc->stats->rx);
35596 }
35597 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35598 struct sk_buff *sb;
35599 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35600 if (len <= NS_SMBUFSIZE) {
35601 if (!atm_charge(vcc, sb->truesize)) {
35602 push_rxbufs(card, sb);
35603 - atomic_inc(&vcc->stats->rx_drop);
35604 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35605 } else {
35606 skb_put(sb, len);
35607 dequeue_sm_buf(card, sb);
35608 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35609 ATM_SKB(sb)->vcc = vcc;
35610 __net_timestamp(sb);
35611 vcc->push(vcc, sb);
35612 - atomic_inc(&vcc->stats->rx);
35613 + atomic_inc_unchecked(&vcc->stats->rx);
35614 }
35615
35616 push_rxbufs(card, skb);
35617 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35618
35619 if (!atm_charge(vcc, skb->truesize)) {
35620 push_rxbufs(card, skb);
35621 - atomic_inc(&vcc->stats->rx_drop);
35622 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35623 } else {
35624 dequeue_lg_buf(card, skb);
35625 #ifdef NS_USE_DESTRUCTORS
35626 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35627 ATM_SKB(skb)->vcc = vcc;
35628 __net_timestamp(skb);
35629 vcc->push(vcc, skb);
35630 - atomic_inc(&vcc->stats->rx);
35631 + atomic_inc_unchecked(&vcc->stats->rx);
35632 }
35633
35634 push_rxbufs(card, sb);
35635 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35636 printk
35637 ("nicstar%d: Out of huge buffers.\n",
35638 card->index);
35639 - atomic_inc(&vcc->stats->rx_drop);
35640 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35641 recycle_iovec_rx_bufs(card,
35642 (struct iovec *)
35643 iovb->data,
35644 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35645 card->hbpool.count++;
35646 } else
35647 dev_kfree_skb_any(hb);
35648 - atomic_inc(&vcc->stats->rx_drop);
35649 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35650 } else {
35651 /* Copy the small buffer to the huge buffer */
35652 sb = (struct sk_buff *)iov->iov_base;
35653 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35654 #endif /* NS_USE_DESTRUCTORS */
35655 __net_timestamp(hb);
35656 vcc->push(vcc, hb);
35657 - atomic_inc(&vcc->stats->rx);
35658 + atomic_inc_unchecked(&vcc->stats->rx);
35659 }
35660 }
35661
35662 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35663 index 32784d1..4a8434a 100644
35664 --- a/drivers/atm/solos-pci.c
35665 +++ b/drivers/atm/solos-pci.c
35666 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35667 }
35668 atm_charge(vcc, skb->truesize);
35669 vcc->push(vcc, skb);
35670 - atomic_inc(&vcc->stats->rx);
35671 + atomic_inc_unchecked(&vcc->stats->rx);
35672 break;
35673
35674 case PKT_STATUS:
35675 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35676 vcc = SKB_CB(oldskb)->vcc;
35677
35678 if (vcc) {
35679 - atomic_inc(&vcc->stats->tx);
35680 + atomic_inc_unchecked(&vcc->stats->tx);
35681 solos_pop(vcc, oldskb);
35682 } else {
35683 dev_kfree_skb_irq(oldskb);
35684 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35685 index 0215934..ce9f5b1 100644
35686 --- a/drivers/atm/suni.c
35687 +++ b/drivers/atm/suni.c
35688 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35689
35690
35691 #define ADD_LIMITED(s,v) \
35692 - atomic_add((v),&stats->s); \
35693 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35694 + atomic_add_unchecked((v),&stats->s); \
35695 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35696
35697
35698 static void suni_hz(unsigned long from_timer)
35699 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35700 index 5120a96..e2572bd 100644
35701 --- a/drivers/atm/uPD98402.c
35702 +++ b/drivers/atm/uPD98402.c
35703 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35704 struct sonet_stats tmp;
35705 int error = 0;
35706
35707 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35708 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35709 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35710 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35711 if (zero && !error) {
35712 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35713
35714
35715 #define ADD_LIMITED(s,v) \
35716 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35717 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35718 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35719 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35720 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35721 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35722
35723
35724 static void stat_event(struct atm_dev *dev)
35725 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35726 if (reason & uPD98402_INT_PFM) stat_event(dev);
35727 if (reason & uPD98402_INT_PCO) {
35728 (void) GET(PCOCR); /* clear interrupt cause */
35729 - atomic_add(GET(HECCT),
35730 + atomic_add_unchecked(GET(HECCT),
35731 &PRIV(dev)->sonet_stats.uncorr_hcs);
35732 }
35733 if ((reason & uPD98402_INT_RFO) &&
35734 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35735 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35736 uPD98402_INT_LOS),PIMR); /* enable them */
35737 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35738 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35739 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35740 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35741 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35742 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35743 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35744 return 0;
35745 }
35746
35747 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35748 index 969c3c2..9b72956 100644
35749 --- a/drivers/atm/zatm.c
35750 +++ b/drivers/atm/zatm.c
35751 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35752 }
35753 if (!size) {
35754 dev_kfree_skb_irq(skb);
35755 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35756 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35757 continue;
35758 }
35759 if (!atm_charge(vcc,skb->truesize)) {
35760 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35761 skb->len = size;
35762 ATM_SKB(skb)->vcc = vcc;
35763 vcc->push(vcc,skb);
35764 - atomic_inc(&vcc->stats->rx);
35765 + atomic_inc_unchecked(&vcc->stats->rx);
35766 }
35767 zout(pos & 0xffff,MTA(mbx));
35768 #if 0 /* probably a stupid idea */
35769 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35770 skb_queue_head(&zatm_vcc->backlog,skb);
35771 break;
35772 }
35773 - atomic_inc(&vcc->stats->tx);
35774 + atomic_inc_unchecked(&vcc->stats->tx);
35775 wake_up(&zatm_vcc->tx_wait);
35776 }
35777
35778 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35779 index d414331..b4dd4ba 100644
35780 --- a/drivers/base/bus.c
35781 +++ b/drivers/base/bus.c
35782 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35783 return -EINVAL;
35784
35785 mutex_lock(&subsys->p->mutex);
35786 - list_add_tail(&sif->node, &subsys->p->interfaces);
35787 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35788 if (sif->add_dev) {
35789 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35790 while ((dev = subsys_dev_iter_next(&iter)))
35791 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35792 subsys = sif->subsys;
35793
35794 mutex_lock(&subsys->p->mutex);
35795 - list_del_init(&sif->node);
35796 + pax_list_del_init((struct list_head *)&sif->node);
35797 if (sif->remove_dev) {
35798 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35799 while ((dev = subsys_dev_iter_next(&iter)))
35800 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35801 index 7413d06..79155fa 100644
35802 --- a/drivers/base/devtmpfs.c
35803 +++ b/drivers/base/devtmpfs.c
35804 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35805 if (!thread)
35806 return 0;
35807
35808 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35809 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35810 if (err)
35811 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35812 else
35813 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35814 *err = sys_unshare(CLONE_NEWNS);
35815 if (*err)
35816 goto out;
35817 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35818 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35819 if (*err)
35820 goto out;
35821 - sys_chdir("/.."); /* will traverse into overmounted root */
35822 - sys_chroot(".");
35823 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35824 + sys_chroot((char __force_user *)".");
35825 complete(&setup_done);
35826 while (1) {
35827 spin_lock(&req_lock);
35828 diff --git a/drivers/base/node.c b/drivers/base/node.c
35829 index 7616a77c..8f57f51 100644
35830 --- a/drivers/base/node.c
35831 +++ b/drivers/base/node.c
35832 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35833 struct node_attr {
35834 struct device_attribute attr;
35835 enum node_states state;
35836 -};
35837 +} __do_const;
35838
35839 static ssize_t show_node_state(struct device *dev,
35840 struct device_attribute *attr, char *buf)
35841 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35842 index bfb8955..42c9b9a 100644
35843 --- a/drivers/base/power/domain.c
35844 +++ b/drivers/base/power/domain.c
35845 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35846 {
35847 struct cpuidle_driver *cpuidle_drv;
35848 struct gpd_cpu_data *cpu_data;
35849 - struct cpuidle_state *idle_state;
35850 + cpuidle_state_no_const *idle_state;
35851 int ret = 0;
35852
35853 if (IS_ERR_OR_NULL(genpd) || state < 0)
35854 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35855 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35856 {
35857 struct gpd_cpu_data *cpu_data;
35858 - struct cpuidle_state *idle_state;
35859 + cpuidle_state_no_const *idle_state;
35860 int ret = 0;
35861
35862 if (IS_ERR_OR_NULL(genpd))
35863 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35864 index a53ebd2..8f73eeb 100644
35865 --- a/drivers/base/power/sysfs.c
35866 +++ b/drivers/base/power/sysfs.c
35867 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35868 return -EIO;
35869 }
35870 }
35871 - return sprintf(buf, p);
35872 + return sprintf(buf, "%s", p);
35873 }
35874
35875 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35876 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35877 index 2d56f41..8830f19 100644
35878 --- a/drivers/base/power/wakeup.c
35879 +++ b/drivers/base/power/wakeup.c
35880 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35881 * They need to be modified together atomically, so it's better to use one
35882 * atomic variable to hold them both.
35883 */
35884 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35885 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35886
35887 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35888 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35889
35890 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35891 {
35892 - unsigned int comb = atomic_read(&combined_event_count);
35893 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35894
35895 *cnt = (comb >> IN_PROGRESS_BITS);
35896 *inpr = comb & MAX_IN_PROGRESS;
35897 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35898 ws->start_prevent_time = ws->last_time;
35899
35900 /* Increment the counter of events in progress. */
35901 - cec = atomic_inc_return(&combined_event_count);
35902 + cec = atomic_inc_return_unchecked(&combined_event_count);
35903
35904 trace_wakeup_source_activate(ws->name, cec);
35905 }
35906 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35907 * Increment the counter of registered wakeup events and decrement the
35908 * couter of wakeup events in progress simultaneously.
35909 */
35910 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35911 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35912 trace_wakeup_source_deactivate(ws->name, cec);
35913
35914 split_counters(&cnt, &inpr);
35915 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35916 index e8d11b6..7b1b36f 100644
35917 --- a/drivers/base/syscore.c
35918 +++ b/drivers/base/syscore.c
35919 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35920 void register_syscore_ops(struct syscore_ops *ops)
35921 {
35922 mutex_lock(&syscore_ops_lock);
35923 - list_add_tail(&ops->node, &syscore_ops_list);
35924 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35925 mutex_unlock(&syscore_ops_lock);
35926 }
35927 EXPORT_SYMBOL_GPL(register_syscore_ops);
35928 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35929 void unregister_syscore_ops(struct syscore_ops *ops)
35930 {
35931 mutex_lock(&syscore_ops_lock);
35932 - list_del(&ops->node);
35933 + pax_list_del((struct list_head *)&ops->node);
35934 mutex_unlock(&syscore_ops_lock);
35935 }
35936 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35937 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35938 index 62b6c2c..002d10f 100644
35939 --- a/drivers/block/cciss.c
35940 +++ b/drivers/block/cciss.c
35941 @@ -1189,6 +1189,7 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
35942 int err;
35943 u32 cp;
35944
35945 + memset(&arg64, 0, sizeof(arg64));
35946 err = 0;
35947 err |=
35948 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
35949 @@ -3010,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35950 while (!list_empty(&h->reqQ)) {
35951 c = list_entry(h->reqQ.next, CommandList_struct, list);
35952 /* can't do anything if fifo is full */
35953 - if ((h->access.fifo_full(h))) {
35954 + if ((h->access->fifo_full(h))) {
35955 dev_warn(&h->pdev->dev, "fifo full\n");
35956 break;
35957 }
35958 @@ -3020,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35959 h->Qdepth--;
35960
35961 /* Tell the controller execute command */
35962 - h->access.submit_command(h, c);
35963 + h->access->submit_command(h, c);
35964
35965 /* Put job onto the completed Q */
35966 addQ(&h->cmpQ, c);
35967 @@ -3446,17 +3447,17 @@ startio:
35968
35969 static inline unsigned long get_next_completion(ctlr_info_t *h)
35970 {
35971 - return h->access.command_completed(h);
35972 + return h->access->command_completed(h);
35973 }
35974
35975 static inline int interrupt_pending(ctlr_info_t *h)
35976 {
35977 - return h->access.intr_pending(h);
35978 + return h->access->intr_pending(h);
35979 }
35980
35981 static inline long interrupt_not_for_us(ctlr_info_t *h)
35982 {
35983 - return ((h->access.intr_pending(h) == 0) ||
35984 + return ((h->access->intr_pending(h) == 0) ||
35985 (h->interrupts_enabled == 0));
35986 }
35987
35988 @@ -3489,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
35989 u32 a;
35990
35991 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35992 - return h->access.command_completed(h);
35993 + return h->access->command_completed(h);
35994
35995 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35996 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35997 @@ -4046,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35998 trans_support & CFGTBL_Trans_use_short_tags);
35999
36000 /* Change the access methods to the performant access methods */
36001 - h->access = SA5_performant_access;
36002 + h->access = &SA5_performant_access;
36003 h->transMethod = CFGTBL_Trans_Performant;
36004
36005 return;
36006 @@ -4319,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36007 if (prod_index < 0)
36008 return -ENODEV;
36009 h->product_name = products[prod_index].product_name;
36010 - h->access = *(products[prod_index].access);
36011 + h->access = products[prod_index].access;
36012
36013 if (cciss_board_disabled(h)) {
36014 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36015 @@ -5051,7 +5052,7 @@ reinit_after_soft_reset:
36016 }
36017
36018 /* make sure the board interrupts are off */
36019 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36020 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36021 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36022 if (rc)
36023 goto clean2;
36024 @@ -5101,7 +5102,7 @@ reinit_after_soft_reset:
36025 * fake ones to scoop up any residual completions.
36026 */
36027 spin_lock_irqsave(&h->lock, flags);
36028 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36029 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36030 spin_unlock_irqrestore(&h->lock, flags);
36031 free_irq(h->intr[h->intr_mode], h);
36032 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36033 @@ -5121,9 +5122,9 @@ reinit_after_soft_reset:
36034 dev_info(&h->pdev->dev, "Board READY.\n");
36035 dev_info(&h->pdev->dev,
36036 "Waiting for stale completions to drain.\n");
36037 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36038 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36039 msleep(10000);
36040 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36041 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36042
36043 rc = controller_reset_failed(h->cfgtable);
36044 if (rc)
36045 @@ -5146,7 +5147,7 @@ reinit_after_soft_reset:
36046 cciss_scsi_setup(h);
36047
36048 /* Turn the interrupts on so we can service requests */
36049 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36050 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36051
36052 /* Get the firmware version */
36053 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36054 @@ -5218,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36055 kfree(flush_buf);
36056 if (return_code != IO_OK)
36057 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36058 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36059 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36060 free_irq(h->intr[h->intr_mode], h);
36061 }
36062
36063 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36064 index 7fda30e..eb5dfe0 100644
36065 --- a/drivers/block/cciss.h
36066 +++ b/drivers/block/cciss.h
36067 @@ -101,7 +101,7 @@ struct ctlr_info
36068 /* information about each logical volume */
36069 drive_info_struct *drv[CISS_MAX_LUN];
36070
36071 - struct access_method access;
36072 + struct access_method *access;
36073
36074 /* queue and queue Info */
36075 struct list_head reqQ;
36076 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36077 index 639d26b..fd6ad1f 100644
36078 --- a/drivers/block/cpqarray.c
36079 +++ b/drivers/block/cpqarray.c
36080 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36081 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36082 goto Enomem4;
36083 }
36084 - hba[i]->access.set_intr_mask(hba[i], 0);
36085 + hba[i]->access->set_intr_mask(hba[i], 0);
36086 if (request_irq(hba[i]->intr, do_ida_intr,
36087 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36088 {
36089 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36090 add_timer(&hba[i]->timer);
36091
36092 /* Enable IRQ now that spinlock and rate limit timer are set up */
36093 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36094 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36095
36096 for(j=0; j<NWD; j++) {
36097 struct gendisk *disk = ida_gendisk[i][j];
36098 @@ -694,7 +694,7 @@ DBGINFO(
36099 for(i=0; i<NR_PRODUCTS; i++) {
36100 if (board_id == products[i].board_id) {
36101 c->product_name = products[i].product_name;
36102 - c->access = *(products[i].access);
36103 + c->access = products[i].access;
36104 break;
36105 }
36106 }
36107 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36108 hba[ctlr]->intr = intr;
36109 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36110 hba[ctlr]->product_name = products[j].product_name;
36111 - hba[ctlr]->access = *(products[j].access);
36112 + hba[ctlr]->access = products[j].access;
36113 hba[ctlr]->ctlr = ctlr;
36114 hba[ctlr]->board_id = board_id;
36115 hba[ctlr]->pci_dev = NULL; /* not PCI */
36116 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36117
36118 while((c = h->reqQ) != NULL) {
36119 /* Can't do anything if we're busy */
36120 - if (h->access.fifo_full(h) == 0)
36121 + if (h->access->fifo_full(h) == 0)
36122 return;
36123
36124 /* Get the first entry from the request Q */
36125 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36126 h->Qdepth--;
36127
36128 /* Tell the controller to do our bidding */
36129 - h->access.submit_command(h, c);
36130 + h->access->submit_command(h, c);
36131
36132 /* Get onto the completion Q */
36133 addQ(&h->cmpQ, c);
36134 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36135 unsigned long flags;
36136 __u32 a,a1;
36137
36138 - istat = h->access.intr_pending(h);
36139 + istat = h->access->intr_pending(h);
36140 /* Is this interrupt for us? */
36141 if (istat == 0)
36142 return IRQ_NONE;
36143 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36144 */
36145 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36146 if (istat & FIFO_NOT_EMPTY) {
36147 - while((a = h->access.command_completed(h))) {
36148 + while((a = h->access->command_completed(h))) {
36149 a1 = a; a &= ~3;
36150 if ((c = h->cmpQ) == NULL)
36151 {
36152 @@ -1193,6 +1193,7 @@ out_passthru:
36153 ida_pci_info_struct pciinfo;
36154
36155 if (!arg) return -EINVAL;
36156 + memset(&pciinfo, 0, sizeof(pciinfo));
36157 pciinfo.bus = host->pci_dev->bus->number;
36158 pciinfo.dev_fn = host->pci_dev->devfn;
36159 pciinfo.board_id = host->board_id;
36160 @@ -1447,11 +1448,11 @@ static int sendcmd(
36161 /*
36162 * Disable interrupt
36163 */
36164 - info_p->access.set_intr_mask(info_p, 0);
36165 + info_p->access->set_intr_mask(info_p, 0);
36166 /* Make sure there is room in the command FIFO */
36167 /* Actually it should be completely empty at this time. */
36168 for (i = 200000; i > 0; i--) {
36169 - temp = info_p->access.fifo_full(info_p);
36170 + temp = info_p->access->fifo_full(info_p);
36171 if (temp != 0) {
36172 break;
36173 }
36174 @@ -1464,7 +1465,7 @@ DBG(
36175 /*
36176 * Send the cmd
36177 */
36178 - info_p->access.submit_command(info_p, c);
36179 + info_p->access->submit_command(info_p, c);
36180 complete = pollcomplete(ctlr);
36181
36182 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36183 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36184 * we check the new geometry. Then turn interrupts back on when
36185 * we're done.
36186 */
36187 - host->access.set_intr_mask(host, 0);
36188 + host->access->set_intr_mask(host, 0);
36189 getgeometry(ctlr);
36190 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36191 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36192
36193 for(i=0; i<NWD; i++) {
36194 struct gendisk *disk = ida_gendisk[ctlr][i];
36195 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
36196 /* Wait (up to 2 seconds) for a command to complete */
36197
36198 for (i = 200000; i > 0; i--) {
36199 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36200 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36201 if (done == 0) {
36202 udelay(10); /* a short fixed delay */
36203 } else
36204 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36205 index be73e9d..7fbf140 100644
36206 --- a/drivers/block/cpqarray.h
36207 +++ b/drivers/block/cpqarray.h
36208 @@ -99,7 +99,7 @@ struct ctlr_info {
36209 drv_info_t drv[NWD];
36210 struct proc_dir_entry *proc;
36211
36212 - struct access_method access;
36213 + struct access_method *access;
36214
36215 cmdlist_t *reqQ;
36216 cmdlist_t *cmpQ;
36217 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36218 index 2d7f608..11245fe 100644
36219 --- a/drivers/block/drbd/drbd_int.h
36220 +++ b/drivers/block/drbd/drbd_int.h
36221 @@ -582,7 +582,7 @@ struct drbd_epoch {
36222 struct drbd_tconn *tconn;
36223 struct list_head list;
36224 unsigned int barrier_nr;
36225 - atomic_t epoch_size; /* increased on every request added. */
36226 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36227 atomic_t active; /* increased on every req. added, and dec on every finished. */
36228 unsigned long flags;
36229 };
36230 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36231 unsigned int al_tr_number;
36232 int al_tr_cycle;
36233 wait_queue_head_t seq_wait;
36234 - atomic_t packet_seq;
36235 + atomic_unchecked_t packet_seq;
36236 unsigned int peer_seq;
36237 spinlock_t peer_seq_lock;
36238 unsigned int minor;
36239 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36240 char __user *uoptval;
36241 int err;
36242
36243 - uoptval = (char __user __force *)optval;
36244 + uoptval = (char __force_user *)optval;
36245
36246 set_fs(KERNEL_DS);
36247 if (level == SOL_SOCKET)
36248 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36249 index 55635ed..40e837c 100644
36250 --- a/drivers/block/drbd/drbd_main.c
36251 +++ b/drivers/block/drbd/drbd_main.c
36252 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36253 p->sector = sector;
36254 p->block_id = block_id;
36255 p->blksize = blksize;
36256 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36257 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36258 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36259 }
36260
36261 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36262 return -EIO;
36263 p->sector = cpu_to_be64(req->i.sector);
36264 p->block_id = (unsigned long)req;
36265 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36266 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36267 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36268 if (mdev->state.conn >= C_SYNC_SOURCE &&
36269 mdev->state.conn <= C_PAUSED_SYNC_T)
36270 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36271 {
36272 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36273
36274 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36275 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36276 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36277 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36278 kfree(tconn->current_epoch);
36279
36280 idr_destroy(&tconn->volumes);
36281 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36282 index 8cc1e64..ba7ffa9 100644
36283 --- a/drivers/block/drbd/drbd_nl.c
36284 +++ b/drivers/block/drbd/drbd_nl.c
36285 @@ -3440,7 +3440,7 @@ out:
36286
36287 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36288 {
36289 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36290 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36291 struct sk_buff *msg;
36292 struct drbd_genlmsghdr *d_out;
36293 unsigned seq;
36294 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36295 return;
36296 }
36297
36298 - seq = atomic_inc_return(&drbd_genl_seq);
36299 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36300 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36301 if (!msg)
36302 goto failed;
36303 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36304 index cc29cd3..d4b058b 100644
36305 --- a/drivers/block/drbd/drbd_receiver.c
36306 +++ b/drivers/block/drbd/drbd_receiver.c
36307 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36308 {
36309 int err;
36310
36311 - atomic_set(&mdev->packet_seq, 0);
36312 + atomic_set_unchecked(&mdev->packet_seq, 0);
36313 mdev->peer_seq = 0;
36314
36315 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36316 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36317 do {
36318 next_epoch = NULL;
36319
36320 - epoch_size = atomic_read(&epoch->epoch_size);
36321 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36322
36323 switch (ev & ~EV_CLEANUP) {
36324 case EV_PUT:
36325 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36326 rv = FE_DESTROYED;
36327 } else {
36328 epoch->flags = 0;
36329 - atomic_set(&epoch->epoch_size, 0);
36330 + atomic_set_unchecked(&epoch->epoch_size, 0);
36331 /* atomic_set(&epoch->active, 0); is already zero */
36332 if (rv == FE_STILL_LIVE)
36333 rv = FE_RECYCLED;
36334 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36335 conn_wait_active_ee_empty(tconn);
36336 drbd_flush(tconn);
36337
36338 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36339 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36340 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36341 if (epoch)
36342 break;
36343 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36344 }
36345
36346 epoch->flags = 0;
36347 - atomic_set(&epoch->epoch_size, 0);
36348 + atomic_set_unchecked(&epoch->epoch_size, 0);
36349 atomic_set(&epoch->active, 0);
36350
36351 spin_lock(&tconn->epoch_lock);
36352 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36353 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36354 list_add(&epoch->list, &tconn->current_epoch->list);
36355 tconn->current_epoch = epoch;
36356 tconn->epochs++;
36357 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36358
36359 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36360 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36361 - atomic_inc(&tconn->current_epoch->epoch_size);
36362 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36363 err2 = drbd_drain_block(mdev, pi->size);
36364 if (!err)
36365 err = err2;
36366 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36367
36368 spin_lock(&tconn->epoch_lock);
36369 peer_req->epoch = tconn->current_epoch;
36370 - atomic_inc(&peer_req->epoch->epoch_size);
36371 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36372 atomic_inc(&peer_req->epoch->active);
36373 spin_unlock(&tconn->epoch_lock);
36374
36375 @@ -4347,7 +4347,7 @@ struct data_cmd {
36376 int expect_payload;
36377 size_t pkt_size;
36378 int (*fn)(struct drbd_tconn *, struct packet_info *);
36379 -};
36380 +} __do_const;
36381
36382 static struct data_cmd drbd_cmd_handler[] = {
36383 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36384 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36385 if (!list_empty(&tconn->current_epoch->list))
36386 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36387 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36388 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36389 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36390 tconn->send.seen_any_write_yet = false;
36391
36392 conn_info(tconn, "Connection closed\n");
36393 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36394 struct asender_cmd {
36395 size_t pkt_size;
36396 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36397 -};
36398 +} __do_const;
36399
36400 static struct asender_cmd asender_tbl[] = {
36401 [P_PING] = { 0, got_Ping },
36402 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36403 index 40e7155..df5c79a 100644
36404 --- a/drivers/block/loop.c
36405 +++ b/drivers/block/loop.c
36406 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36407
36408 file_start_write(file);
36409 set_fs(get_ds());
36410 - bw = file->f_op->write(file, buf, len, &pos);
36411 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36412 set_fs(old_fs);
36413 file_end_write(file);
36414 if (likely(bw == len))
36415 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36416 index f5d0ea1..c62380a 100644
36417 --- a/drivers/block/pktcdvd.c
36418 +++ b/drivers/block/pktcdvd.c
36419 @@ -84,7 +84,7 @@
36420 #define MAX_SPEED 0xffff
36421
36422 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36423 - ~(sector_t)((pd)->settings.size - 1))
36424 + ~(sector_t)((pd)->settings.size - 1UL))
36425
36426 static DEFINE_MUTEX(pktcdvd_mutex);
36427 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36428 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36429 index 7332889..9ece19e 100644
36430 --- a/drivers/bus/arm-cci.c
36431 +++ b/drivers/bus/arm-cci.c
36432 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36433
36434 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36435
36436 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36437 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36438 if (!ports)
36439 return -ENOMEM;
36440
36441 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36442 index 8a3aff7..d7538c2 100644
36443 --- a/drivers/cdrom/cdrom.c
36444 +++ b/drivers/cdrom/cdrom.c
36445 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36446 ENSURE(reset, CDC_RESET);
36447 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36448 cdi->mc_flags = 0;
36449 - cdo->n_minors = 0;
36450 cdi->options = CDO_USE_FFLAGS;
36451
36452 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36453 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36454 else
36455 cdi->cdda_method = CDDA_OLD;
36456
36457 - if (!cdo->generic_packet)
36458 - cdo->generic_packet = cdrom_dummy_generic_packet;
36459 + if (!cdo->generic_packet) {
36460 + pax_open_kernel();
36461 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36462 + pax_close_kernel();
36463 + }
36464
36465 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36466 mutex_lock(&cdrom_mutex);
36467 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36468 if (cdi->exit)
36469 cdi->exit(cdi);
36470
36471 - cdi->ops->n_minors--;
36472 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36473 }
36474
36475 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36476 */
36477 nr = nframes;
36478 do {
36479 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36480 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36481 if (cgc.buffer)
36482 break;
36483
36484 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36485 struct cdrom_device_info *cdi;
36486 int ret;
36487
36488 - ret = scnprintf(info + *pos, max_size - *pos, header);
36489 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36490 if (!ret)
36491 return 1;
36492
36493 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36494 index 5980cb9..6d7bd7e 100644
36495 --- a/drivers/cdrom/gdrom.c
36496 +++ b/drivers/cdrom/gdrom.c
36497 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36498 .audio_ioctl = gdrom_audio_ioctl,
36499 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36500 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36501 - .n_minors = 1,
36502 };
36503
36504 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36505 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36506 index 1421997..33f5d6d 100644
36507 --- a/drivers/char/Kconfig
36508 +++ b/drivers/char/Kconfig
36509 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36510
36511 config DEVKMEM
36512 bool "/dev/kmem virtual device support"
36513 - default y
36514 + default n
36515 + depends on !GRKERNSEC_KMEM
36516 help
36517 Say Y here if you want to support the /dev/kmem device. The
36518 /dev/kmem device is rarely used, but can be used for certain
36519 @@ -570,6 +571,7 @@ config DEVPORT
36520 bool
36521 depends on !M68K
36522 depends on ISA || PCI
36523 + depends on !GRKERNSEC_KMEM
36524 default y
36525
36526 source "drivers/s390/char/Kconfig"
36527 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36528 index a48e05b..6bac831 100644
36529 --- a/drivers/char/agp/compat_ioctl.c
36530 +++ b/drivers/char/agp/compat_ioctl.c
36531 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36532 return -ENOMEM;
36533 }
36534
36535 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36536 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36537 sizeof(*usegment) * ureserve.seg_count)) {
36538 kfree(usegment);
36539 kfree(ksegment);
36540 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36541 index 1b19239..b87b143 100644
36542 --- a/drivers/char/agp/frontend.c
36543 +++ b/drivers/char/agp/frontend.c
36544 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36545 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36546 return -EFAULT;
36547
36548 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36549 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36550 return -EFAULT;
36551
36552 client = agp_find_client_by_pid(reserve.pid);
36553 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36554 if (segment == NULL)
36555 return -ENOMEM;
36556
36557 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36558 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36559 sizeof(struct agp_segment) * reserve.seg_count)) {
36560 kfree(segment);
36561 return -EFAULT;
36562 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36563 index 4f94375..413694e 100644
36564 --- a/drivers/char/genrtc.c
36565 +++ b/drivers/char/genrtc.c
36566 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36567 switch (cmd) {
36568
36569 case RTC_PLL_GET:
36570 + memset(&pll, 0, sizeof(pll));
36571 if (get_rtc_pll(&pll))
36572 return -EINVAL;
36573 else
36574 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36575 index 448ce5e..3a76625 100644
36576 --- a/drivers/char/hpet.c
36577 +++ b/drivers/char/hpet.c
36578 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36579 }
36580
36581 static int
36582 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36583 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36584 struct hpet_info *info)
36585 {
36586 struct hpet_timer __iomem *timer;
36587 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36588 index 86fe45c..c0ea948 100644
36589 --- a/drivers/char/hw_random/intel-rng.c
36590 +++ b/drivers/char/hw_random/intel-rng.c
36591 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36592
36593 if (no_fwh_detect)
36594 return -ENODEV;
36595 - printk(warning);
36596 + printk("%s", warning);
36597 return -EBUSY;
36598 }
36599
36600 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36601 index 4445fa1..7c6de37 100644
36602 --- a/drivers/char/ipmi/ipmi_msghandler.c
36603 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36604 @@ -420,7 +420,7 @@ struct ipmi_smi {
36605 struct proc_dir_entry *proc_dir;
36606 char proc_dir_name[10];
36607
36608 - atomic_t stats[IPMI_NUM_STATS];
36609 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36610
36611 /*
36612 * run_to_completion duplicate of smb_info, smi_info
36613 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36614
36615
36616 #define ipmi_inc_stat(intf, stat) \
36617 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36618 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36619 #define ipmi_get_stat(intf, stat) \
36620 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36621 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36622
36623 static int is_lan_addr(struct ipmi_addr *addr)
36624 {
36625 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36626 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36627 init_waitqueue_head(&intf->waitq);
36628 for (i = 0; i < IPMI_NUM_STATS; i++)
36629 - atomic_set(&intf->stats[i], 0);
36630 + atomic_set_unchecked(&intf->stats[i], 0);
36631
36632 intf->proc_dir = NULL;
36633
36634 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36635 index af4b23f..79806fc 100644
36636 --- a/drivers/char/ipmi/ipmi_si_intf.c
36637 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36638 @@ -275,7 +275,7 @@ struct smi_info {
36639 unsigned char slave_addr;
36640
36641 /* Counters and things for the proc filesystem. */
36642 - atomic_t stats[SI_NUM_STATS];
36643 + atomic_unchecked_t stats[SI_NUM_STATS];
36644
36645 struct task_struct *thread;
36646
36647 @@ -284,9 +284,9 @@ struct smi_info {
36648 };
36649
36650 #define smi_inc_stat(smi, stat) \
36651 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36652 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36653 #define smi_get_stat(smi, stat) \
36654 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36655 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36656
36657 #define SI_MAX_PARMS 4
36658
36659 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36660 atomic_set(&new_smi->req_events, 0);
36661 new_smi->run_to_completion = 0;
36662 for (i = 0; i < SI_NUM_STATS; i++)
36663 - atomic_set(&new_smi->stats[i], 0);
36664 + atomic_set_unchecked(&new_smi->stats[i], 0);
36665
36666 new_smi->interrupt_disabled = 1;
36667 atomic_set(&new_smi->stop_operation, 0);
36668 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36669 index f895a8c..2bc9147 100644
36670 --- a/drivers/char/mem.c
36671 +++ b/drivers/char/mem.c
36672 @@ -18,6 +18,7 @@
36673 #include <linux/raw.h>
36674 #include <linux/tty.h>
36675 #include <linux/capability.h>
36676 +#include <linux/security.h>
36677 #include <linux/ptrace.h>
36678 #include <linux/device.h>
36679 #include <linux/highmem.h>
36680 @@ -37,6 +38,10 @@
36681
36682 #define DEVPORT_MINOR 4
36683
36684 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36685 +extern const struct file_operations grsec_fops;
36686 +#endif
36687 +
36688 static inline unsigned long size_inside_page(unsigned long start,
36689 unsigned long size)
36690 {
36691 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36692
36693 while (cursor < to) {
36694 if (!devmem_is_allowed(pfn)) {
36695 +#ifdef CONFIG_GRKERNSEC_KMEM
36696 + gr_handle_mem_readwrite(from, to);
36697 +#else
36698 printk(KERN_INFO
36699 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36700 current->comm, from, to);
36701 +#endif
36702 return 0;
36703 }
36704 cursor += PAGE_SIZE;
36705 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36706 }
36707 return 1;
36708 }
36709 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36710 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36711 +{
36712 + return 0;
36713 +}
36714 #else
36715 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36716 {
36717 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36718
36719 while (count > 0) {
36720 unsigned long remaining;
36721 + char *temp;
36722
36723 sz = size_inside_page(p, count);
36724
36725 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36726 if (!ptr)
36727 return -EFAULT;
36728
36729 - remaining = copy_to_user(buf, ptr, sz);
36730 +#ifdef CONFIG_PAX_USERCOPY
36731 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36732 + if (!temp) {
36733 + unxlate_dev_mem_ptr(p, ptr);
36734 + return -ENOMEM;
36735 + }
36736 + memcpy(temp, ptr, sz);
36737 +#else
36738 + temp = ptr;
36739 +#endif
36740 +
36741 + remaining = copy_to_user(buf, temp, sz);
36742 +
36743 +#ifdef CONFIG_PAX_USERCOPY
36744 + kfree(temp);
36745 +#endif
36746 +
36747 unxlate_dev_mem_ptr(p, ptr);
36748 if (remaining)
36749 return -EFAULT;
36750 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36751 size_t count, loff_t *ppos)
36752 {
36753 unsigned long p = *ppos;
36754 - ssize_t low_count, read, sz;
36755 + ssize_t low_count, read, sz, err = 0;
36756 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36757 - int err = 0;
36758
36759 read = 0;
36760 if (p < (unsigned long) high_memory) {
36761 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36762 }
36763 #endif
36764 while (low_count > 0) {
36765 + char *temp;
36766 +
36767 sz = size_inside_page(p, low_count);
36768
36769 /*
36770 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36771 */
36772 kbuf = xlate_dev_kmem_ptr((char *)p);
36773
36774 - if (copy_to_user(buf, kbuf, sz))
36775 +#ifdef CONFIG_PAX_USERCOPY
36776 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36777 + if (!temp)
36778 + return -ENOMEM;
36779 + memcpy(temp, kbuf, sz);
36780 +#else
36781 + temp = kbuf;
36782 +#endif
36783 +
36784 + err = copy_to_user(buf, temp, sz);
36785 +
36786 +#ifdef CONFIG_PAX_USERCOPY
36787 + kfree(temp);
36788 +#endif
36789 +
36790 + if (err)
36791 return -EFAULT;
36792 buf += sz;
36793 p += sz;
36794 @@ -822,6 +869,9 @@ static const struct memdev {
36795 #ifdef CONFIG_PRINTK
36796 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36797 #endif
36798 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36799 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36800 +#endif
36801 };
36802
36803 static int memory_open(struct inode *inode, struct file *filp)
36804 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36805 continue;
36806
36807 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36808 - NULL, devlist[minor].name);
36809 + NULL, "%s", devlist[minor].name);
36810 }
36811
36812 return tty_init();
36813 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36814 index 9df78e2..01ba9ae 100644
36815 --- a/drivers/char/nvram.c
36816 +++ b/drivers/char/nvram.c
36817 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36818
36819 spin_unlock_irq(&rtc_lock);
36820
36821 - if (copy_to_user(buf, contents, tmp - contents))
36822 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36823 return -EFAULT;
36824
36825 *ppos = i;
36826 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36827 index 5c5cc00..ac9edb7 100644
36828 --- a/drivers/char/pcmcia/synclink_cs.c
36829 +++ b/drivers/char/pcmcia/synclink_cs.c
36830 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36831
36832 if (debug_level >= DEBUG_LEVEL_INFO)
36833 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36834 - __FILE__, __LINE__, info->device_name, port->count);
36835 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36836
36837 - WARN_ON(!port->count);
36838 + WARN_ON(!atomic_read(&port->count));
36839
36840 if (tty_port_close_start(port, tty, filp) == 0)
36841 goto cleanup;
36842 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36843 cleanup:
36844 if (debug_level >= DEBUG_LEVEL_INFO)
36845 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36846 - tty->driver->name, port->count);
36847 + tty->driver->name, atomic_read(&port->count));
36848 }
36849
36850 /* Wait until the transmitter is empty.
36851 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36852
36853 if (debug_level >= DEBUG_LEVEL_INFO)
36854 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36855 - __FILE__, __LINE__, tty->driver->name, port->count);
36856 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36857
36858 /* If port is closing, signal caller to try again */
36859 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36860 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36861 goto cleanup;
36862 }
36863 spin_lock(&port->lock);
36864 - port->count++;
36865 + atomic_inc(&port->count);
36866 spin_unlock(&port->lock);
36867 spin_unlock_irqrestore(&info->netlock, flags);
36868
36869 - if (port->count == 1) {
36870 + if (atomic_read(&port->count) == 1) {
36871 /* 1st open on this device, init hardware */
36872 retval = startup(info, tty);
36873 if (retval < 0)
36874 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36875 unsigned short new_crctype;
36876
36877 /* return error if TTY interface open */
36878 - if (info->port.count)
36879 + if (atomic_read(&info->port.count))
36880 return -EBUSY;
36881
36882 switch (encoding)
36883 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36884
36885 /* arbitrate between network and tty opens */
36886 spin_lock_irqsave(&info->netlock, flags);
36887 - if (info->port.count != 0 || info->netcount != 0) {
36888 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36889 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36890 spin_unlock_irqrestore(&info->netlock, flags);
36891 return -EBUSY;
36892 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36893 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36894
36895 /* return error if TTY interface open */
36896 - if (info->port.count)
36897 + if (atomic_read(&info->port.count))
36898 return -EBUSY;
36899
36900 if (cmd != SIOCWANDEV)
36901 diff --git a/drivers/char/random.c b/drivers/char/random.c
36902 index 0d91fe5..f8e37b0 100644
36903 --- a/drivers/char/random.c
36904 +++ b/drivers/char/random.c
36905 @@ -272,8 +272,13 @@
36906 /*
36907 * Configuration information
36908 */
36909 +#ifdef CONFIG_GRKERNSEC_RANDNET
36910 +#define INPUT_POOL_WORDS 512
36911 +#define OUTPUT_POOL_WORDS 128
36912 +#else
36913 #define INPUT_POOL_WORDS 128
36914 #define OUTPUT_POOL_WORDS 32
36915 +#endif
36916 #define SEC_XFER_SIZE 512
36917 #define EXTRACT_SIZE 10
36918
36919 @@ -313,10 +318,17 @@ static struct poolinfo {
36920 int poolwords;
36921 int tap1, tap2, tap3, tap4, tap5;
36922 } poolinfo_table[] = {
36923 +#ifdef CONFIG_GRKERNSEC_RANDNET
36924 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36925 + { 512, 411, 308, 208, 104, 1 },
36926 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36927 + { 128, 103, 76, 51, 25, 1 },
36928 +#else
36929 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36930 { 128, 103, 76, 51, 25, 1 },
36931 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36932 { 32, 26, 20, 14, 7, 1 },
36933 +#endif
36934 #if 0
36935 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36936 { 2048, 1638, 1231, 819, 411, 1 },
36937 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36938 input_rotate += i ? 7 : 14;
36939 }
36940
36941 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36942 - ACCESS_ONCE(r->add_ptr) = i;
36943 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36944 + ACCESS_ONCE_RW(r->add_ptr) = i;
36945 smp_wmb();
36946
36947 if (out)
36948 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36949
36950 extract_buf(r, tmp);
36951 i = min_t(int, nbytes, EXTRACT_SIZE);
36952 - if (copy_to_user(buf, tmp, i)) {
36953 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36954 ret = -EFAULT;
36955 break;
36956 }
36957 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36958 #include <linux/sysctl.h>
36959
36960 static int min_read_thresh = 8, min_write_thresh;
36961 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36962 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36963 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36964 static char sysctl_bootid[16];
36965
36966 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36967 static int proc_do_uuid(struct ctl_table *table, int write,
36968 void __user *buffer, size_t *lenp, loff_t *ppos)
36969 {
36970 - struct ctl_table fake_table;
36971 + ctl_table_no_const fake_table;
36972 unsigned char buf[64], tmp_uuid[16], *uuid;
36973
36974 uuid = table->data;
36975 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36976 index bf2349db..5456d53 100644
36977 --- a/drivers/char/sonypi.c
36978 +++ b/drivers/char/sonypi.c
36979 @@ -54,6 +54,7 @@
36980
36981 #include <asm/uaccess.h>
36982 #include <asm/io.h>
36983 +#include <asm/local.h>
36984
36985 #include <linux/sonypi.h>
36986
36987 @@ -490,7 +491,7 @@ static struct sonypi_device {
36988 spinlock_t fifo_lock;
36989 wait_queue_head_t fifo_proc_list;
36990 struct fasync_struct *fifo_async;
36991 - int open_count;
36992 + local_t open_count;
36993 int model;
36994 struct input_dev *input_jog_dev;
36995 struct input_dev *input_key_dev;
36996 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36997 static int sonypi_misc_release(struct inode *inode, struct file *file)
36998 {
36999 mutex_lock(&sonypi_device.lock);
37000 - sonypi_device.open_count--;
37001 + local_dec(&sonypi_device.open_count);
37002 mutex_unlock(&sonypi_device.lock);
37003 return 0;
37004 }
37005 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37006 {
37007 mutex_lock(&sonypi_device.lock);
37008 /* Flush input queue on first open */
37009 - if (!sonypi_device.open_count)
37010 + if (!local_read(&sonypi_device.open_count))
37011 kfifo_reset(&sonypi_device.fifo);
37012 - sonypi_device.open_count++;
37013 + local_inc(&sonypi_device.open_count);
37014 mutex_unlock(&sonypi_device.lock);
37015
37016 return 0;
37017 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37018 index 64420b3..5c40b56 100644
37019 --- a/drivers/char/tpm/tpm_acpi.c
37020 +++ b/drivers/char/tpm/tpm_acpi.c
37021 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37022 virt = acpi_os_map_memory(start, len);
37023 if (!virt) {
37024 kfree(log->bios_event_log);
37025 + log->bios_event_log = NULL;
37026 printk("%s: ERROR - Unable to map memory\n", __func__);
37027 return -EIO;
37028 }
37029
37030 - memcpy_fromio(log->bios_event_log, virt, len);
37031 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37032
37033 acpi_os_unmap_memory(virt, len);
37034 return 0;
37035 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37036 index 84ddc55..1d32f1e 100644
37037 --- a/drivers/char/tpm/tpm_eventlog.c
37038 +++ b/drivers/char/tpm/tpm_eventlog.c
37039 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37040 event = addr;
37041
37042 if ((event->event_type == 0 && event->event_size == 0) ||
37043 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37044 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37045 return NULL;
37046
37047 return addr;
37048 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37049 return NULL;
37050
37051 if ((event->event_type == 0 && event->event_size == 0) ||
37052 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37053 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37054 return NULL;
37055
37056 (*pos)++;
37057 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37058 int i;
37059
37060 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37061 - seq_putc(m, data[i]);
37062 + if (!seq_putc(m, data[i]))
37063 + return -EFAULT;
37064
37065 return 0;
37066 }
37067 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37068 index fc45567..fa2a590 100644
37069 --- a/drivers/char/virtio_console.c
37070 +++ b/drivers/char/virtio_console.c
37071 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37072 if (to_user) {
37073 ssize_t ret;
37074
37075 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37076 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37077 if (ret)
37078 return -EFAULT;
37079 } else {
37080 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37081 if (!port_has_data(port) && !port->host_connected)
37082 return 0;
37083
37084 - return fill_readbuf(port, ubuf, count, true);
37085 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37086 }
37087
37088 static int wait_port_writable(struct port *port, bool nonblock)
37089 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37090 index a33f46f..a720eed 100644
37091 --- a/drivers/clk/clk-composite.c
37092 +++ b/drivers/clk/clk-composite.c
37093 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37094 struct clk *clk;
37095 struct clk_init_data init;
37096 struct clk_composite *composite;
37097 - struct clk_ops *clk_composite_ops;
37098 + clk_ops_no_const *clk_composite_ops;
37099
37100 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37101 if (!composite) {
37102 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37103 index 5bb848c..f1d4fc9 100644
37104 --- a/drivers/clk/socfpga/clk.c
37105 +++ b/drivers/clk/socfpga/clk.c
37106 @@ -22,6 +22,7 @@
37107 #include <linux/clk-provider.h>
37108 #include <linux/io.h>
37109 #include <linux/of.h>
37110 +#include <asm/pgtable.h>
37111
37112 /* Clock Manager offsets */
37113 #define CLKMGR_CTRL 0x0
37114 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37115 streq(clk_name, "periph_pll") ||
37116 streq(clk_name, "sdram_pll")) {
37117 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37118 - clk_pll_ops.enable = clk_gate_ops.enable;
37119 - clk_pll_ops.disable = clk_gate_ops.disable;
37120 + pax_open_kernel();
37121 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37122 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37123 + pax_close_kernel();
37124 }
37125
37126 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37127 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37128 return parent_rate / div;
37129 }
37130
37131 -static struct clk_ops gateclk_ops = {
37132 +static clk_ops_no_const gateclk_ops __read_only = {
37133 .recalc_rate = socfpga_clk_recalc_rate,
37134 .get_parent = socfpga_clk_get_parent,
37135 .set_parent = socfpga_clk_set_parent,
37136 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37137 index 3926402..37b580d 100644
37138 --- a/drivers/cpufreq/acpi-cpufreq.c
37139 +++ b/drivers/cpufreq/acpi-cpufreq.c
37140 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37141 return sprintf(buf, "%u\n", boost_enabled);
37142 }
37143
37144 -static struct global_attr global_boost = __ATTR(boost, 0644,
37145 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37146 show_global_boost,
37147 store_global_boost);
37148
37149 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37150 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37151 per_cpu(acfreq_data, cpu) = data;
37152
37153 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37154 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37155 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37156 + pax_open_kernel();
37157 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37158 + pax_close_kernel();
37159 + }
37160
37161 result = acpi_processor_register_performance(data->acpi_data, cpu);
37162 if (result)
37163 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37164 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37165 break;
37166 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37167 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37168 + pax_open_kernel();
37169 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37170 + pax_close_kernel();
37171 policy->cur = get_cur_freq_on_cpu(cpu);
37172 break;
37173 default:
37174 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37175 acpi_processor_notify_smm(THIS_MODULE);
37176
37177 /* Check for APERF/MPERF support in hardware */
37178 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37179 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37180 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37181 + pax_open_kernel();
37182 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37183 + pax_close_kernel();
37184 + }
37185
37186 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37187 for (i = 0; i < perf->state_count; i++)
37188 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37189 index f0a5e2b..0a7ee46 100644
37190 --- a/drivers/cpufreq/cpufreq.c
37191 +++ b/drivers/cpufreq/cpufreq.c
37192 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37193 return NOTIFY_OK;
37194 }
37195
37196 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37197 +static struct notifier_block cpufreq_cpu_notifier = {
37198 .notifier_call = cpufreq_cpu_callback,
37199 };
37200
37201 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37202
37203 pr_debug("trying to register driver %s\n", driver_data->name);
37204
37205 - if (driver_data->setpolicy)
37206 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37207 + if (driver_data->setpolicy) {
37208 + pax_open_kernel();
37209 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37210 + pax_close_kernel();
37211 + }
37212
37213 write_lock_irqsave(&cpufreq_driver_lock, flags);
37214 if (cpufreq_driver) {
37215 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37216 index e59afaa..a53a3ff 100644
37217 --- a/drivers/cpufreq/cpufreq_governor.c
37218 +++ b/drivers/cpufreq/cpufreq_governor.c
37219 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37220 struct dbs_data *dbs_data;
37221 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37222 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37223 - struct od_ops *od_ops = NULL;
37224 + const struct od_ops *od_ops = NULL;
37225 struct od_dbs_tuners *od_tuners = NULL;
37226 struct cs_dbs_tuners *cs_tuners = NULL;
37227 struct cpu_dbs_common_info *cpu_cdbs;
37228 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37229
37230 if ((cdata->governor == GOV_CONSERVATIVE) &&
37231 (!policy->governor->initialized)) {
37232 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37233 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37234
37235 cpufreq_register_notifier(cs_ops->notifier_block,
37236 CPUFREQ_TRANSITION_NOTIFIER);
37237 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37238
37239 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37240 (policy->governor->initialized == 1)) {
37241 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37242 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37243
37244 cpufreq_unregister_notifier(cs_ops->notifier_block,
37245 CPUFREQ_TRANSITION_NOTIFIER);
37246 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37247 index d5f12b4..eb30af1 100644
37248 --- a/drivers/cpufreq/cpufreq_governor.h
37249 +++ b/drivers/cpufreq/cpufreq_governor.h
37250 @@ -204,7 +204,7 @@ struct common_dbs_data {
37251 void (*exit)(struct dbs_data *dbs_data);
37252
37253 /* Governor specific ops, see below */
37254 - void *gov_ops;
37255 + const void *gov_ops;
37256 };
37257
37258 /* Governer Per policy data */
37259 @@ -224,7 +224,7 @@ struct od_ops {
37260 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37261 unsigned int freq_next, unsigned int relation);
37262 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37263 -};
37264 +} __no_const;
37265
37266 struct cs_ops {
37267 struct notifier_block *notifier_block;
37268 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37269 index c087347..989aa2e 100644
37270 --- a/drivers/cpufreq/cpufreq_ondemand.c
37271 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37272 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37273
37274 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37275
37276 -static struct od_ops od_ops = {
37277 +static struct od_ops od_ops __read_only = {
37278 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37279 .powersave_bias_target = generic_powersave_bias_target,
37280 .freq_increase = dbs_freq_increase,
37281 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37282 (struct cpufreq_policy *, unsigned int, unsigned int),
37283 unsigned int powersave_bias)
37284 {
37285 - od_ops.powersave_bias_target = f;
37286 + pax_open_kernel();
37287 + *(void **)&od_ops.powersave_bias_target = f;
37288 + pax_close_kernel();
37289 od_set_powersave_bias(powersave_bias);
37290 }
37291 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37292
37293 void od_unregister_powersave_bias_handler(void)
37294 {
37295 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37296 + pax_open_kernel();
37297 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37298 + pax_close_kernel();
37299 od_set_powersave_bias(0);
37300 }
37301 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37302 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37303 index d37568c..fbb19a1 100644
37304 --- a/drivers/cpufreq/cpufreq_stats.c
37305 +++ b/drivers/cpufreq/cpufreq_stats.c
37306 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37307 }
37308
37309 /* priority=1 so this will get called before cpufreq_remove_dev */
37310 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37311 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37312 .notifier_call = cpufreq_stat_cpu_callback,
37313 .priority = 1,
37314 };
37315 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37316 index 9ee7817..17b658e 100644
37317 --- a/drivers/cpufreq/p4-clockmod.c
37318 +++ b/drivers/cpufreq/p4-clockmod.c
37319 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37320 case 0x0F: /* Core Duo */
37321 case 0x16: /* Celeron Core */
37322 case 0x1C: /* Atom */
37323 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37324 + pax_open_kernel();
37325 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37326 + pax_close_kernel();
37327 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37328 case 0x0D: /* Pentium M (Dothan) */
37329 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37330 + pax_open_kernel();
37331 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37332 + pax_close_kernel();
37333 /* fall through */
37334 case 0x09: /* Pentium M (Banias) */
37335 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37336 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37337
37338 /* on P-4s, the TSC runs with constant frequency independent whether
37339 * throttling is active or not. */
37340 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37341 + pax_open_kernel();
37342 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37343 + pax_close_kernel();
37344
37345 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37346 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37347 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37348 index 880ee29..2445bc6 100644
37349 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37350 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37351 @@ -18,14 +18,12 @@
37352 #include <asm/head.h>
37353 #include <asm/timer.h>
37354
37355 -static struct cpufreq_driver *cpufreq_us3_driver;
37356 -
37357 struct us3_freq_percpu_info {
37358 struct cpufreq_frequency_table table[4];
37359 };
37360
37361 /* Indexed by cpu number. */
37362 -static struct us3_freq_percpu_info *us3_freq_table;
37363 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37364
37365 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37366 * in the Safari config register.
37367 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37368
37369 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37370 {
37371 - if (cpufreq_us3_driver)
37372 - us3_set_cpu_divider_index(policy, 0);
37373 + us3_set_cpu_divider_index(policy->cpu, 0);
37374
37375 return 0;
37376 }
37377
37378 +static int __init us3_freq_init(void);
37379 +static void __exit us3_freq_exit(void);
37380 +
37381 +static struct cpufreq_driver cpufreq_us3_driver = {
37382 + .init = us3_freq_cpu_init,
37383 + .verify = us3_freq_verify,
37384 + .target = us3_freq_target,
37385 + .get = us3_freq_get,
37386 + .exit = us3_freq_cpu_exit,
37387 + .owner = THIS_MODULE,
37388 + .name = "UltraSPARC-III",
37389 +
37390 +};
37391 +
37392 static int __init us3_freq_init(void)
37393 {
37394 unsigned long manuf, impl, ver;
37395 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37396 (impl == CHEETAH_IMPL ||
37397 impl == CHEETAH_PLUS_IMPL ||
37398 impl == JAGUAR_IMPL ||
37399 - impl == PANTHER_IMPL)) {
37400 - struct cpufreq_driver *driver;
37401 -
37402 - ret = -ENOMEM;
37403 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37404 - if (!driver)
37405 - goto err_out;
37406 -
37407 - us3_freq_table = kzalloc(
37408 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37409 - GFP_KERNEL);
37410 - if (!us3_freq_table)
37411 - goto err_out;
37412 -
37413 - driver->init = us3_freq_cpu_init;
37414 - driver->verify = us3_freq_verify;
37415 - driver->target = us3_freq_target;
37416 - driver->get = us3_freq_get;
37417 - driver->exit = us3_freq_cpu_exit;
37418 - driver->owner = THIS_MODULE,
37419 - strcpy(driver->name, "UltraSPARC-III");
37420 -
37421 - cpufreq_us3_driver = driver;
37422 - ret = cpufreq_register_driver(driver);
37423 - if (ret)
37424 - goto err_out;
37425 -
37426 - return 0;
37427 -
37428 -err_out:
37429 - if (driver) {
37430 - kfree(driver);
37431 - cpufreq_us3_driver = NULL;
37432 - }
37433 - kfree(us3_freq_table);
37434 - us3_freq_table = NULL;
37435 - return ret;
37436 - }
37437 + impl == PANTHER_IMPL))
37438 + return cpufreq_register_driver(&cpufreq_us3_driver);
37439
37440 return -ENODEV;
37441 }
37442
37443 static void __exit us3_freq_exit(void)
37444 {
37445 - if (cpufreq_us3_driver) {
37446 - cpufreq_unregister_driver(cpufreq_us3_driver);
37447 - kfree(cpufreq_us3_driver);
37448 - cpufreq_us3_driver = NULL;
37449 - kfree(us3_freq_table);
37450 - us3_freq_table = NULL;
37451 - }
37452 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37453 }
37454
37455 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37456 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37457 index 0915e71..53376ed 100644
37458 --- a/drivers/cpufreq/speedstep-centrino.c
37459 +++ b/drivers/cpufreq/speedstep-centrino.c
37460 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37461 !cpu_has(cpu, X86_FEATURE_EST))
37462 return -ENODEV;
37463
37464 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37465 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37466 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37467 + pax_open_kernel();
37468 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37469 + pax_close_kernel();
37470 + }
37471
37472 if (policy->cpu != 0)
37473 return -ENODEV;
37474 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37475 index fdc432f..98e64e2 100644
37476 --- a/drivers/cpuidle/cpuidle.c
37477 +++ b/drivers/cpuidle/cpuidle.c
37478 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37479
37480 static void poll_idle_init(struct cpuidle_driver *drv)
37481 {
37482 - struct cpuidle_state *state = &drv->states[0];
37483 + cpuidle_state_no_const *state = &drv->states[0];
37484
37485 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37486 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37487 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37488 index ea2f8e7..70ac501 100644
37489 --- a/drivers/cpuidle/governor.c
37490 +++ b/drivers/cpuidle/governor.c
37491 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37492 mutex_lock(&cpuidle_lock);
37493 if (__cpuidle_find_governor(gov->name) == NULL) {
37494 ret = 0;
37495 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37496 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37497 if (!cpuidle_curr_governor ||
37498 cpuidle_curr_governor->rating < gov->rating)
37499 cpuidle_switch_governor(gov);
37500 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37501 new_gov = cpuidle_replace_governor(gov->rating);
37502 cpuidle_switch_governor(new_gov);
37503 }
37504 - list_del(&gov->governor_list);
37505 + pax_list_del((struct list_head *)&gov->governor_list);
37506 mutex_unlock(&cpuidle_lock);
37507 }
37508
37509 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37510 index 428754a..8bdf9cc 100644
37511 --- a/drivers/cpuidle/sysfs.c
37512 +++ b/drivers/cpuidle/sysfs.c
37513 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37514 NULL
37515 };
37516
37517 -static struct attribute_group cpuidle_attr_group = {
37518 +static attribute_group_no_const cpuidle_attr_group = {
37519 .attrs = cpuidle_default_attrs,
37520 .name = "cpuidle",
37521 };
37522 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37523 index 12fea3e..1e28f47 100644
37524 --- a/drivers/crypto/hifn_795x.c
37525 +++ b/drivers/crypto/hifn_795x.c
37526 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37527 MODULE_PARM_DESC(hifn_pll_ref,
37528 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37529
37530 -static atomic_t hifn_dev_number;
37531 +static atomic_unchecked_t hifn_dev_number;
37532
37533 #define ACRYPTO_OP_DECRYPT 0
37534 #define ACRYPTO_OP_ENCRYPT 1
37535 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37536 goto err_out_disable_pci_device;
37537
37538 snprintf(name, sizeof(name), "hifn%d",
37539 - atomic_inc_return(&hifn_dev_number)-1);
37540 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37541
37542 err = pci_request_regions(pdev, name);
37543 if (err)
37544 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37545 index e94e619..f7e249c 100644
37546 --- a/drivers/devfreq/devfreq.c
37547 +++ b/drivers/devfreq/devfreq.c
37548 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37549 goto err_out;
37550 }
37551
37552 - list_add(&governor->node, &devfreq_governor_list);
37553 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37554
37555 list_for_each_entry(devfreq, &devfreq_list, node) {
37556 int ret = 0;
37557 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37558 }
37559 }
37560
37561 - list_del(&governor->node);
37562 + pax_list_del((struct list_head *)&governor->node);
37563 err_out:
37564 mutex_unlock(&devfreq_list_lock);
37565
37566 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37567 index 5039fbc..841169f 100644
37568 --- a/drivers/dma/sh/shdma.c
37569 +++ b/drivers/dma/sh/shdma.c
37570 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37571 return ret;
37572 }
37573
37574 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37575 +static struct notifier_block sh_dmae_nmi_notifier = {
37576 .notifier_call = sh_dmae_nmi_handler,
37577
37578 /* Run before NMI debug handler and KGDB */
37579 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37580 index 211021d..201d47f 100644
37581 --- a/drivers/edac/edac_device.c
37582 +++ b/drivers/edac/edac_device.c
37583 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37584 */
37585 int edac_device_alloc_index(void)
37586 {
37587 - static atomic_t device_indexes = ATOMIC_INIT(0);
37588 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37589
37590 - return atomic_inc_return(&device_indexes) - 1;
37591 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37592 }
37593 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37594
37595 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37596 index e7c32c4..6397af1 100644
37597 --- a/drivers/edac/edac_mc_sysfs.c
37598 +++ b/drivers/edac/edac_mc_sysfs.c
37599 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37600 struct dev_ch_attribute {
37601 struct device_attribute attr;
37602 int channel;
37603 -};
37604 +} __do_const;
37605
37606 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37607 struct dev_ch_attribute dev_attr_legacy_##_name = \
37608 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37609 }
37610
37611 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37612 + pax_open_kernel();
37613 if (mci->get_sdram_scrub_rate) {
37614 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37615 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37616 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37617 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37618 }
37619 if (mci->set_sdram_scrub_rate) {
37620 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37621 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37622 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37623 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37624 }
37625 + pax_close_kernel();
37626 err = device_create_file(&mci->dev,
37627 &dev_attr_sdram_scrub_rate);
37628 if (err) {
37629 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37630 index dd370f9..0281629 100644
37631 --- a/drivers/edac/edac_pci.c
37632 +++ b/drivers/edac/edac_pci.c
37633 @@ -29,7 +29,7 @@
37634
37635 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37636 static LIST_HEAD(edac_pci_list);
37637 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37638 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37639
37640 /*
37641 * edac_pci_alloc_ctl_info
37642 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37643 */
37644 int edac_pci_alloc_index(void)
37645 {
37646 - return atomic_inc_return(&pci_indexes) - 1;
37647 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37648 }
37649 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37650
37651 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37652 index e8658e4..22746d6 100644
37653 --- a/drivers/edac/edac_pci_sysfs.c
37654 +++ b/drivers/edac/edac_pci_sysfs.c
37655 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37656 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37657 static int edac_pci_poll_msec = 1000; /* one second workq period */
37658
37659 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37660 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37661 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37662 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37663
37664 static struct kobject *edac_pci_top_main_kobj;
37665 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37666 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37667 void *value;
37668 ssize_t(*show) (void *, char *);
37669 ssize_t(*store) (void *, const char *, size_t);
37670 -};
37671 +} __do_const;
37672
37673 /* Set of show/store abstract level functions for PCI Parity object */
37674 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37675 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37676 edac_printk(KERN_CRIT, EDAC_PCI,
37677 "Signaled System Error on %s\n",
37678 pci_name(dev));
37679 - atomic_inc(&pci_nonparity_count);
37680 + atomic_inc_unchecked(&pci_nonparity_count);
37681 }
37682
37683 if (status & (PCI_STATUS_PARITY)) {
37684 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37685 "Master Data Parity Error on %s\n",
37686 pci_name(dev));
37687
37688 - atomic_inc(&pci_parity_count);
37689 + atomic_inc_unchecked(&pci_parity_count);
37690 }
37691
37692 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37693 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37694 "Detected Parity Error on %s\n",
37695 pci_name(dev));
37696
37697 - atomic_inc(&pci_parity_count);
37698 + atomic_inc_unchecked(&pci_parity_count);
37699 }
37700 }
37701
37702 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37703 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37704 "Signaled System Error on %s\n",
37705 pci_name(dev));
37706 - atomic_inc(&pci_nonparity_count);
37707 + atomic_inc_unchecked(&pci_nonparity_count);
37708 }
37709
37710 if (status & (PCI_STATUS_PARITY)) {
37711 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37712 "Master Data Parity Error on "
37713 "%s\n", pci_name(dev));
37714
37715 - atomic_inc(&pci_parity_count);
37716 + atomic_inc_unchecked(&pci_parity_count);
37717 }
37718
37719 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37720 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37721 "Detected Parity Error on %s\n",
37722 pci_name(dev));
37723
37724 - atomic_inc(&pci_parity_count);
37725 + atomic_inc_unchecked(&pci_parity_count);
37726 }
37727 }
37728 }
37729 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37730 if (!check_pci_errors)
37731 return;
37732
37733 - before_count = atomic_read(&pci_parity_count);
37734 + before_count = atomic_read_unchecked(&pci_parity_count);
37735
37736 /* scan all PCI devices looking for a Parity Error on devices and
37737 * bridges.
37738 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37739 /* Only if operator has selected panic on PCI Error */
37740 if (edac_pci_get_panic_on_pe()) {
37741 /* If the count is different 'after' from 'before' */
37742 - if (before_count != atomic_read(&pci_parity_count))
37743 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37744 panic("EDAC: PCI Parity Error");
37745 }
37746 }
37747 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37748 index 51b7e3a..aa8a3e8 100644
37749 --- a/drivers/edac/mce_amd.h
37750 +++ b/drivers/edac/mce_amd.h
37751 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37752 bool (*mc0_mce)(u16, u8);
37753 bool (*mc1_mce)(u16, u8);
37754 bool (*mc2_mce)(u16, u8);
37755 -};
37756 +} __no_const;
37757
37758 void amd_report_gart_errors(bool);
37759 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37760 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37761 index 57ea7f4..af06b76 100644
37762 --- a/drivers/firewire/core-card.c
37763 +++ b/drivers/firewire/core-card.c
37764 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37765 const struct fw_card_driver *driver,
37766 struct device *device)
37767 {
37768 - static atomic_t index = ATOMIC_INIT(-1);
37769 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37770
37771 - card->index = atomic_inc_return(&index);
37772 + card->index = atomic_inc_return_unchecked(&index);
37773 card->driver = driver;
37774 card->device = device;
37775 card->current_tlabel = 0;
37776 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37777
37778 void fw_core_remove_card(struct fw_card *card)
37779 {
37780 - struct fw_card_driver dummy_driver = dummy_driver_template;
37781 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37782
37783 card->driver->update_phy_reg(card, 4,
37784 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37785 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37786 index de4aa40..49ab1f2 100644
37787 --- a/drivers/firewire/core-device.c
37788 +++ b/drivers/firewire/core-device.c
37789 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37790 struct config_rom_attribute {
37791 struct device_attribute attr;
37792 u32 key;
37793 -};
37794 +} __do_const;
37795
37796 static ssize_t show_immediate(struct device *dev,
37797 struct device_attribute *dattr, char *buf)
37798 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37799 index 28a94c7..58da63a 100644
37800 --- a/drivers/firewire/core-transaction.c
37801 +++ b/drivers/firewire/core-transaction.c
37802 @@ -38,6 +38,7 @@
37803 #include <linux/timer.h>
37804 #include <linux/types.h>
37805 #include <linux/workqueue.h>
37806 +#include <linux/sched.h>
37807
37808 #include <asm/byteorder.h>
37809
37810 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37811 index 515a42c..5ecf3ba 100644
37812 --- a/drivers/firewire/core.h
37813 +++ b/drivers/firewire/core.h
37814 @@ -111,6 +111,7 @@ struct fw_card_driver {
37815
37816 int (*stop_iso)(struct fw_iso_context *ctx);
37817 };
37818 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37819
37820 void fw_card_initialize(struct fw_card *card,
37821 const struct fw_card_driver *driver, struct device *device);
37822 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37823 index 94a58a0..f5eba42 100644
37824 --- a/drivers/firmware/dmi-id.c
37825 +++ b/drivers/firmware/dmi-id.c
37826 @@ -16,7 +16,7 @@
37827 struct dmi_device_attribute{
37828 struct device_attribute dev_attr;
37829 int field;
37830 -};
37831 +} __do_const;
37832 #define to_dmi_dev_attr(_dev_attr) \
37833 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37834
37835 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37836 index 232fa8f..386c255 100644
37837 --- a/drivers/firmware/dmi_scan.c
37838 +++ b/drivers/firmware/dmi_scan.c
37839 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37840 }
37841 }
37842 else {
37843 - /*
37844 - * no iounmap() for that ioremap(); it would be a no-op, but
37845 - * it's so early in setup that sucker gets confused into doing
37846 - * what it shouldn't if we actually call it.
37847 - */
37848 p = dmi_ioremap(0xF0000, 0x10000);
37849 if (p == NULL)
37850 goto error;
37851 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37852 if (buf == NULL)
37853 return -1;
37854
37855 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37856 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37857
37858 iounmap(buf);
37859 return 0;
37860 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37861 index 5145fa3..0d3babd 100644
37862 --- a/drivers/firmware/efi/efi.c
37863 +++ b/drivers/firmware/efi/efi.c
37864 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37865 };
37866
37867 static struct efivars generic_efivars;
37868 -static struct efivar_operations generic_ops;
37869 +static efivar_operations_no_const generic_ops __read_only;
37870
37871 static int generic_ops_register(void)
37872 {
37873 - generic_ops.get_variable = efi.get_variable;
37874 - generic_ops.set_variable = efi.set_variable;
37875 - generic_ops.get_next_variable = efi.get_next_variable;
37876 - generic_ops.query_variable_store = efi_query_variable_store;
37877 + pax_open_kernel();
37878 + *(void **)&generic_ops.get_variable = efi.get_variable;
37879 + *(void **)&generic_ops.set_variable = efi.set_variable;
37880 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37881 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37882 + pax_close_kernel();
37883
37884 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37885 }
37886 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37887 index 8a7432a..28fb839 100644
37888 --- a/drivers/firmware/efi/efivars.c
37889 +++ b/drivers/firmware/efi/efivars.c
37890 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37891 static int
37892 create_efivars_bin_attributes(void)
37893 {
37894 - struct bin_attribute *attr;
37895 + bin_attribute_no_const *attr;
37896 int error;
37897
37898 /* new_var */
37899 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37900 index 2a90ba6..07f3733 100644
37901 --- a/drivers/firmware/google/memconsole.c
37902 +++ b/drivers/firmware/google/memconsole.c
37903 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37904 if (!found_memconsole())
37905 return -ENODEV;
37906
37907 - memconsole_bin_attr.size = memconsole_length;
37908 + pax_open_kernel();
37909 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37910 + pax_close_kernel();
37911
37912 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37913
37914 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37915 index 2729e3d..f9deca1 100644
37916 --- a/drivers/gpio/gpio-ich.c
37917 +++ b/drivers/gpio/gpio-ich.c
37918 @@ -71,7 +71,7 @@ struct ichx_desc {
37919 /* Some chipsets have quirks, let these use their own request/get */
37920 int (*request)(struct gpio_chip *chip, unsigned offset);
37921 int (*get)(struct gpio_chip *chip, unsigned offset);
37922 -};
37923 +} __do_const;
37924
37925 static struct {
37926 spinlock_t lock;
37927 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37928 index 9902732..64b62dd 100644
37929 --- a/drivers/gpio/gpio-vr41xx.c
37930 +++ b/drivers/gpio/gpio-vr41xx.c
37931 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37932 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37933 maskl, pendl, maskh, pendh);
37934
37935 - atomic_inc(&irq_err_count);
37936 + atomic_inc_unchecked(&irq_err_count);
37937
37938 return -EINVAL;
37939 }
37940 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37941 index 6a64749..0767a9f 100644
37942 --- a/drivers/gpu/drm/drm_crtc_helper.c
37943 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37944 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37945 struct drm_crtc *tmp;
37946 int crtc_mask = 1;
37947
37948 - WARN(!crtc, "checking null crtc?\n");
37949 + BUG_ON(!crtc);
37950
37951 dev = crtc->dev;
37952
37953 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37954 index 99fcd7c..13cf6c5 100644
37955 --- a/drivers/gpu/drm/drm_drv.c
37956 +++ b/drivers/gpu/drm/drm_drv.c
37957 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37958 /**
37959 * Copy and IOCTL return string to user space
37960 */
37961 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37962 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37963 {
37964 int len;
37965
37966 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37967 struct drm_file *file_priv = filp->private_data;
37968 struct drm_device *dev;
37969 const struct drm_ioctl_desc *ioctl = NULL;
37970 - drm_ioctl_t *func;
37971 + drm_ioctl_no_const_t func;
37972 unsigned int nr = DRM_IOCTL_NR(cmd);
37973 int retcode = -EINVAL;
37974 char stack_kdata[128];
37975 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37976 return -ENODEV;
37977
37978 atomic_inc(&dev->ioctl_count);
37979 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37980 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37981 ++file_priv->ioctl_count;
37982
37983 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37984 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37985 index 3a24385..4e426e0 100644
37986 --- a/drivers/gpu/drm/drm_fops.c
37987 +++ b/drivers/gpu/drm/drm_fops.c
37988 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37989 }
37990
37991 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37992 - atomic_set(&dev->counts[i], 0);
37993 + atomic_set_unchecked(&dev->counts[i], 0);
37994
37995 dev->sigdata.lock = NULL;
37996
37997 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37998 if (drm_device_is_unplugged(dev))
37999 return -ENODEV;
38000
38001 - if (!dev->open_count++)
38002 + if (local_inc_return(&dev->open_count) == 1)
38003 need_setup = 1;
38004 mutex_lock(&dev->struct_mutex);
38005 old_imapping = inode->i_mapping;
38006 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38007 retcode = drm_open_helper(inode, filp, dev);
38008 if (retcode)
38009 goto err_undo;
38010 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38011 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38012 if (need_setup) {
38013 retcode = drm_setup(dev);
38014 if (retcode)
38015 @@ -166,7 +166,7 @@ err_undo:
38016 iput(container_of(dev->dev_mapping, struct inode, i_data));
38017 dev->dev_mapping = old_mapping;
38018 mutex_unlock(&dev->struct_mutex);
38019 - dev->open_count--;
38020 + local_dec(&dev->open_count);
38021 return retcode;
38022 }
38023 EXPORT_SYMBOL(drm_open);
38024 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38025
38026 mutex_lock(&drm_global_mutex);
38027
38028 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38029 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38030
38031 if (dev->driver->preclose)
38032 dev->driver->preclose(dev, file_priv);
38033 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38034 * Begin inline drm_release
38035 */
38036
38037 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38038 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38039 task_pid_nr(current),
38040 (long)old_encode_dev(file_priv->minor->device),
38041 - dev->open_count);
38042 + local_read(&dev->open_count));
38043
38044 /* Release any auth tokens that might point to this file_priv,
38045 (do that under the drm_global_mutex) */
38046 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38047 * End inline drm_release
38048 */
38049
38050 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38051 - if (!--dev->open_count) {
38052 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38053 + if (local_dec_and_test(&dev->open_count)) {
38054 if (atomic_read(&dev->ioctl_count)) {
38055 DRM_ERROR("Device busy: %d\n",
38056 atomic_read(&dev->ioctl_count));
38057 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38058 index f731116..629842c 100644
38059 --- a/drivers/gpu/drm/drm_global.c
38060 +++ b/drivers/gpu/drm/drm_global.c
38061 @@ -36,7 +36,7 @@
38062 struct drm_global_item {
38063 struct mutex mutex;
38064 void *object;
38065 - int refcount;
38066 + atomic_t refcount;
38067 };
38068
38069 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38070 @@ -49,7 +49,7 @@ void drm_global_init(void)
38071 struct drm_global_item *item = &glob[i];
38072 mutex_init(&item->mutex);
38073 item->object = NULL;
38074 - item->refcount = 0;
38075 + atomic_set(&item->refcount, 0);
38076 }
38077 }
38078
38079 @@ -59,7 +59,7 @@ void drm_global_release(void)
38080 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38081 struct drm_global_item *item = &glob[i];
38082 BUG_ON(item->object != NULL);
38083 - BUG_ON(item->refcount != 0);
38084 + BUG_ON(atomic_read(&item->refcount) != 0);
38085 }
38086 }
38087
38088 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38089 void *object;
38090
38091 mutex_lock(&item->mutex);
38092 - if (item->refcount == 0) {
38093 + if (atomic_read(&item->refcount) == 0) {
38094 item->object = kzalloc(ref->size, GFP_KERNEL);
38095 if (unlikely(item->object == NULL)) {
38096 ret = -ENOMEM;
38097 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38098 goto out_err;
38099
38100 }
38101 - ++item->refcount;
38102 + atomic_inc(&item->refcount);
38103 ref->object = item->object;
38104 object = item->object;
38105 mutex_unlock(&item->mutex);
38106 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38107 struct drm_global_item *item = &glob[ref->global_type];
38108
38109 mutex_lock(&item->mutex);
38110 - BUG_ON(item->refcount == 0);
38111 + BUG_ON(atomic_read(&item->refcount) == 0);
38112 BUG_ON(ref->object != item->object);
38113 - if (--item->refcount == 0) {
38114 + if (atomic_dec_and_test(&item->refcount)) {
38115 ref->release(ref);
38116 item->object = NULL;
38117 }
38118 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38119 index d4b20ce..77a8d41 100644
38120 --- a/drivers/gpu/drm/drm_info.c
38121 +++ b/drivers/gpu/drm/drm_info.c
38122 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38123 struct drm_local_map *map;
38124 struct drm_map_list *r_list;
38125
38126 - /* Hardcoded from _DRM_FRAME_BUFFER,
38127 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38128 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38129 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38130 + static const char * const types[] = {
38131 + [_DRM_FRAME_BUFFER] = "FB",
38132 + [_DRM_REGISTERS] = "REG",
38133 + [_DRM_SHM] = "SHM",
38134 + [_DRM_AGP] = "AGP",
38135 + [_DRM_SCATTER_GATHER] = "SG",
38136 + [_DRM_CONSISTENT] = "PCI",
38137 + [_DRM_GEM] = "GEM" };
38138 const char *type;
38139 int i;
38140
38141 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38142 map = r_list->map;
38143 if (!map)
38144 continue;
38145 - if (map->type < 0 || map->type > 5)
38146 + if (map->type >= ARRAY_SIZE(types))
38147 type = "??";
38148 else
38149 type = types[map->type];
38150 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38151 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38152 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38153 vma->vm_flags & VM_IO ? 'i' : '-',
38154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38155 + 0);
38156 +#else
38157 vma->vm_pgoff);
38158 +#endif
38159
38160 #if defined(__i386__)
38161 pgprot = pgprot_val(vma->vm_page_prot);
38162 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38163 index 2f4c434..dd12cd2 100644
38164 --- a/drivers/gpu/drm/drm_ioc32.c
38165 +++ b/drivers/gpu/drm/drm_ioc32.c
38166 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38167 request = compat_alloc_user_space(nbytes);
38168 if (!access_ok(VERIFY_WRITE, request, nbytes))
38169 return -EFAULT;
38170 - list = (struct drm_buf_desc *) (request + 1);
38171 + list = (struct drm_buf_desc __user *) (request + 1);
38172
38173 if (__put_user(count, &request->count)
38174 || __put_user(list, &request->list))
38175 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38176 request = compat_alloc_user_space(nbytes);
38177 if (!access_ok(VERIFY_WRITE, request, nbytes))
38178 return -EFAULT;
38179 - list = (struct drm_buf_pub *) (request + 1);
38180 + list = (struct drm_buf_pub __user *) (request + 1);
38181
38182 if (__put_user(count, &request->count)
38183 || __put_user(list, &request->list))
38184 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38185 return 0;
38186 }
38187
38188 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38189 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38190 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38191 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38192 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38193 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38194 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 {
38196 unsigned int nr = DRM_IOCTL_NR(cmd);
38197 - drm_ioctl_compat_t *fn;
38198 int ret;
38199
38200 /* Assume that ioctls without an explicit compat routine will just
38201 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38202 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38203 return drm_ioctl(filp, cmd, arg);
38204
38205 - fn = drm_compat_ioctls[nr];
38206 -
38207 - if (fn != NULL)
38208 - ret = (*fn) (filp, cmd, arg);
38209 + if (drm_compat_ioctls[nr] != NULL)
38210 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38211 else
38212 ret = drm_ioctl(filp, cmd, arg);
38213
38214 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38215 index ffd7a7b..a64643e 100644
38216 --- a/drivers/gpu/drm/drm_ioctl.c
38217 +++ b/drivers/gpu/drm/drm_ioctl.c
38218 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38219 stats->data[i].value =
38220 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38221 else
38222 - stats->data[i].value = atomic_read(&dev->counts[i]);
38223 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38224 stats->data[i].type = dev->types[i];
38225 }
38226
38227 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38228 index d752c96..fe08455 100644
38229 --- a/drivers/gpu/drm/drm_lock.c
38230 +++ b/drivers/gpu/drm/drm_lock.c
38231 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38232 if (drm_lock_take(&master->lock, lock->context)) {
38233 master->lock.file_priv = file_priv;
38234 master->lock.lock_time = jiffies;
38235 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38236 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38237 break; /* Got lock */
38238 }
38239
38240 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38241 return -EINVAL;
38242 }
38243
38244 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38245 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38246
38247 if (drm_lock_free(&master->lock, lock->context)) {
38248 /* FIXME: Should really bail out here. */
38249 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38250 index 327ca19..684d3c0 100644
38251 --- a/drivers/gpu/drm/drm_stub.c
38252 +++ b/drivers/gpu/drm/drm_stub.c
38253 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38254
38255 drm_device_set_unplugged(dev);
38256
38257 - if (dev->open_count == 0) {
38258 + if (local_read(&dev->open_count) == 0) {
38259 drm_put_dev(dev);
38260 }
38261 mutex_unlock(&drm_global_mutex);
38262 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38263 index 2290b3b..22056a1 100644
38264 --- a/drivers/gpu/drm/drm_sysfs.c
38265 +++ b/drivers/gpu/drm/drm_sysfs.c
38266 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38267 int drm_sysfs_device_add(struct drm_minor *minor)
38268 {
38269 int err;
38270 - char *minor_str;
38271 + const char *minor_str;
38272
38273 minor->kdev.parent = minor->dev->dev;
38274
38275 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38276 index ada49ed..29275a0 100644
38277 --- a/drivers/gpu/drm/i810/i810_dma.c
38278 +++ b/drivers/gpu/drm/i810/i810_dma.c
38279 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38280 dma->buflist[vertex->idx],
38281 vertex->discard, vertex->used);
38282
38283 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38284 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38285 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38286 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38287 sarea_priv->last_enqueue = dev_priv->counter - 1;
38288 sarea_priv->last_dispatch = (int)hw_status[5];
38289
38290 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38291 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38292 mc->last_render);
38293
38294 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38295 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38296 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38297 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38298 sarea_priv->last_enqueue = dev_priv->counter - 1;
38299 sarea_priv->last_dispatch = (int)hw_status[5];
38300
38301 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38302 index 6e0acad..93c8289 100644
38303 --- a/drivers/gpu/drm/i810/i810_drv.h
38304 +++ b/drivers/gpu/drm/i810/i810_drv.h
38305 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38306 int page_flipping;
38307
38308 wait_queue_head_t irq_queue;
38309 - atomic_t irq_received;
38310 - atomic_t irq_emitted;
38311 + atomic_unchecked_t irq_received;
38312 + atomic_unchecked_t irq_emitted;
38313
38314 int front_offset;
38315 } drm_i810_private_t;
38316 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38317 index 47d6c74..279123f 100644
38318 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38319 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38320 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38321 I915_READ(GTIMR));
38322 }
38323 seq_printf(m, "Interrupts received: %d\n",
38324 - atomic_read(&dev_priv->irq_received));
38325 + atomic_read_unchecked(&dev_priv->irq_received));
38326 for_each_ring(ring, dev_priv, i) {
38327 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38328 seq_printf(m,
38329 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38330 index f466980..8f2883f 100644
38331 --- a/drivers/gpu/drm/i915/i915_dma.c
38332 +++ b/drivers/gpu/drm/i915/i915_dma.c
38333 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38334 bool can_switch;
38335
38336 spin_lock(&dev->count_lock);
38337 - can_switch = (dev->open_count == 0);
38338 + can_switch = (local_read(&dev->open_count) == 0);
38339 spin_unlock(&dev->count_lock);
38340 return can_switch;
38341 }
38342 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38343 index 1929bff..dab130d 100644
38344 --- a/drivers/gpu/drm/i915/i915_drv.h
38345 +++ b/drivers/gpu/drm/i915/i915_drv.h
38346 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38347 drm_dma_handle_t *status_page_dmah;
38348 struct resource mch_res;
38349
38350 - atomic_t irq_received;
38351 + atomic_unchecked_t irq_received;
38352
38353 /* protects the irq masks */
38354 spinlock_t irq_lock;
38355 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38356 index 87a3227..cd13d8f 100644
38357 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38358 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38359 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38360
38361 static int
38362 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38363 - int count)
38364 + unsigned int count)
38365 {
38366 - int i;
38367 + unsigned int i;
38368 int relocs_total = 0;
38369 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38370
38371 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38372 index 3c59584..500f2e9 100644
38373 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38374 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38375 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38376 (unsigned long)request);
38377 }
38378
38379 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38380 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38381 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38382 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38383 [DRM_I915_GETPARAM] = compat_i915_getparam,
38384 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38385 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38386 {
38387 unsigned int nr = DRM_IOCTL_NR(cmd);
38388 - drm_ioctl_compat_t *fn = NULL;
38389 int ret;
38390
38391 if (nr < DRM_COMMAND_BASE)
38392 return drm_compat_ioctl(filp, cmd, arg);
38393
38394 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38395 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38396 -
38397 - if (fn != NULL)
38398 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38399 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38400 ret = (*fn) (filp, cmd, arg);
38401 - else
38402 + } else
38403 ret = drm_ioctl(filp, cmd, arg);
38404
38405 return ret;
38406 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38407 index 3d92a7c..9a9cfd7 100644
38408 --- a/drivers/gpu/drm/i915/i915_irq.c
38409 +++ b/drivers/gpu/drm/i915/i915_irq.c
38410 @@ -970,7 +970,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38411 int pipe;
38412 u32 pipe_stats[I915_MAX_PIPES];
38413
38414 - atomic_inc(&dev_priv->irq_received);
38415 + atomic_inc_unchecked(&dev_priv->irq_received);
38416
38417 while (true) {
38418 iir = I915_READ(VLV_IIR);
38419 @@ -1187,7 +1187,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38420 irqreturn_t ret = IRQ_NONE;
38421 int i;
38422
38423 - atomic_inc(&dev_priv->irq_received);
38424 + atomic_inc_unchecked(&dev_priv->irq_received);
38425
38426 /* We get interrupts on unclaimed registers, so check for this before we
38427 * do any I915_{READ,WRITE}. */
38428 @@ -1307,7 +1307,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38429 int ret = IRQ_NONE;
38430 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38431
38432 - atomic_inc(&dev_priv->irq_received);
38433 + atomic_inc_unchecked(&dev_priv->irq_received);
38434
38435 /* disable master interrupt before clearing iir */
38436 de_ier = I915_READ(DEIER);
38437 @@ -2566,7 +2566,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38438 {
38439 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38440
38441 - atomic_set(&dev_priv->irq_received, 0);
38442 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38443
38444 I915_WRITE(HWSTAM, 0xeffe);
38445
38446 @@ -2588,7 +2588,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38447 {
38448 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38449
38450 - atomic_set(&dev_priv->irq_received, 0);
38451 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38452
38453 I915_WRITE(HWSTAM, 0xeffe);
38454
38455 @@ -2616,7 +2616,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38456 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38457 int pipe;
38458
38459 - atomic_set(&dev_priv->irq_received, 0);
38460 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38461
38462 /* VLV magic */
38463 I915_WRITE(VLV_IMR, 0);
38464 @@ -2928,7 +2928,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38465 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38466 int pipe;
38467
38468 - atomic_set(&dev_priv->irq_received, 0);
38469 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38470
38471 for_each_pipe(pipe)
38472 I915_WRITE(PIPESTAT(pipe), 0);
38473 @@ -3007,7 +3007,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38474 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38475 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38476
38477 - atomic_inc(&dev_priv->irq_received);
38478 + atomic_inc_unchecked(&dev_priv->irq_received);
38479
38480 iir = I915_READ16(IIR);
38481 if (iir == 0)
38482 @@ -3082,7 +3082,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38483 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38484 int pipe;
38485
38486 - atomic_set(&dev_priv->irq_received, 0);
38487 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38488
38489 if (I915_HAS_HOTPLUG(dev)) {
38490 I915_WRITE(PORT_HOTPLUG_EN, 0);
38491 @@ -3181,7 +3181,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38492 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38493 int pipe, ret = IRQ_NONE;
38494
38495 - atomic_inc(&dev_priv->irq_received);
38496 + atomic_inc_unchecked(&dev_priv->irq_received);
38497
38498 iir = I915_READ(IIR);
38499 do {
38500 @@ -3305,7 +3305,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38501 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38502 int pipe;
38503
38504 - atomic_set(&dev_priv->irq_received, 0);
38505 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38506
38507 I915_WRITE(PORT_HOTPLUG_EN, 0);
38508 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38509 @@ -3414,7 +3414,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38510 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38511 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38512
38513 - atomic_inc(&dev_priv->irq_received);
38514 + atomic_inc_unchecked(&dev_priv->irq_received);
38515
38516 iir = I915_READ(IIR);
38517
38518 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38519 index ca40d1b..6baacfd 100644
38520 --- a/drivers/gpu/drm/i915/intel_display.c
38521 +++ b/drivers/gpu/drm/i915/intel_display.c
38522 @@ -9431,13 +9431,13 @@ struct intel_quirk {
38523 int subsystem_vendor;
38524 int subsystem_device;
38525 void (*hook)(struct drm_device *dev);
38526 -};
38527 +} __do_const;
38528
38529 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38530 struct intel_dmi_quirk {
38531 void (*hook)(struct drm_device *dev);
38532 const struct dmi_system_id (*dmi_id_list)[];
38533 -};
38534 +} __do_const;
38535
38536 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38537 {
38538 @@ -9445,18 +9445,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38539 return 1;
38540 }
38541
38542 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38543 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38544 {
38545 - .dmi_id_list = &(const struct dmi_system_id[]) {
38546 - {
38547 - .callback = intel_dmi_reverse_brightness,
38548 - .ident = "NCR Corporation",
38549 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38550 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38551 - },
38552 - },
38553 - { } /* terminating entry */
38554 + .callback = intel_dmi_reverse_brightness,
38555 + .ident = "NCR Corporation",
38556 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38557 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38558 },
38559 + },
38560 + { } /* terminating entry */
38561 +};
38562 +
38563 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38564 + {
38565 + .dmi_id_list = &intel_dmi_quirks_table,
38566 .hook = quirk_invert_brightness,
38567 },
38568 };
38569 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38570 index 54558a0..2d97005 100644
38571 --- a/drivers/gpu/drm/mga/mga_drv.h
38572 +++ b/drivers/gpu/drm/mga/mga_drv.h
38573 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38574 u32 clear_cmd;
38575 u32 maccess;
38576
38577 - atomic_t vbl_received; /**< Number of vblanks received. */
38578 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38579 wait_queue_head_t fence_queue;
38580 - atomic_t last_fence_retired;
38581 + atomic_unchecked_t last_fence_retired;
38582 u32 next_fence_to_post;
38583
38584 unsigned int fb_cpp;
38585 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38586 index 709e90d..89a1c0d 100644
38587 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38588 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38589 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38590 return 0;
38591 }
38592
38593 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38594 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38595 [DRM_MGA_INIT] = compat_mga_init,
38596 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38597 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38598 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38599 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38600 {
38601 unsigned int nr = DRM_IOCTL_NR(cmd);
38602 - drm_ioctl_compat_t *fn = NULL;
38603 int ret;
38604
38605 if (nr < DRM_COMMAND_BASE)
38606 return drm_compat_ioctl(filp, cmd, arg);
38607
38608 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38609 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38610 -
38611 - if (fn != NULL)
38612 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38613 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38614 ret = (*fn) (filp, cmd, arg);
38615 - else
38616 + } else
38617 ret = drm_ioctl(filp, cmd, arg);
38618
38619 return ret;
38620 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38621 index 598c281..60d590e 100644
38622 --- a/drivers/gpu/drm/mga/mga_irq.c
38623 +++ b/drivers/gpu/drm/mga/mga_irq.c
38624 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38625 if (crtc != 0)
38626 return 0;
38627
38628 - return atomic_read(&dev_priv->vbl_received);
38629 + return atomic_read_unchecked(&dev_priv->vbl_received);
38630 }
38631
38632
38633 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38634 /* VBLANK interrupt */
38635 if (status & MGA_VLINEPEN) {
38636 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38637 - atomic_inc(&dev_priv->vbl_received);
38638 + atomic_inc_unchecked(&dev_priv->vbl_received);
38639 drm_handle_vblank(dev, 0);
38640 handled = 1;
38641 }
38642 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38643 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38644 MGA_WRITE(MGA_PRIMEND, prim_end);
38645
38646 - atomic_inc(&dev_priv->last_fence_retired);
38647 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38648 DRM_WAKEUP(&dev_priv->fence_queue);
38649 handled = 1;
38650 }
38651 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38652 * using fences.
38653 */
38654 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38655 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38656 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38657 - *sequence) <= (1 << 23)));
38658
38659 *sequence = cur_fence;
38660 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38661 index 3e72876..d1c15ad 100644
38662 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38663 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38664 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38665 struct bit_table {
38666 const char id;
38667 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38668 -};
38669 +} __no_const;
38670
38671 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38672
38673 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38674 index 41ff7e0..fa854ef 100644
38675 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38676 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38677 @@ -92,7 +92,6 @@ struct nouveau_drm {
38678 struct drm_global_reference mem_global_ref;
38679 struct ttm_bo_global_ref bo_global_ref;
38680 struct ttm_bo_device bdev;
38681 - atomic_t validate_sequence;
38682 int (*move)(struct nouveau_channel *,
38683 struct ttm_buffer_object *,
38684 struct ttm_mem_reg *, struct ttm_mem_reg *);
38685 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38686 index 08214bc..9208577 100644
38687 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38688 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38689 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38690 unsigned long arg)
38691 {
38692 unsigned int nr = DRM_IOCTL_NR(cmd);
38693 - drm_ioctl_compat_t *fn = NULL;
38694 + drm_ioctl_compat_t fn = NULL;
38695 int ret;
38696
38697 if (nr < DRM_COMMAND_BASE)
38698 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38699 index 25d3495..d81aaf6 100644
38700 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38701 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38702 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38703 bool can_switch;
38704
38705 spin_lock(&dev->count_lock);
38706 - can_switch = (dev->open_count == 0);
38707 + can_switch = (local_read(&dev->open_count) == 0);
38708 spin_unlock(&dev->count_lock);
38709 return can_switch;
38710 }
38711 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38712 index 1dfd84c..104896c 100644
38713 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38714 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38715 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38716 }
38717 }
38718
38719 -static struct vm_operations_struct qxl_ttm_vm_ops;
38720 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38721 static const struct vm_operations_struct *ttm_vm_ops;
38722
38723 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38724 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38725 return r;
38726 if (unlikely(ttm_vm_ops == NULL)) {
38727 ttm_vm_ops = vma->vm_ops;
38728 + pax_open_kernel();
38729 qxl_ttm_vm_ops = *ttm_vm_ops;
38730 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38731 + pax_close_kernel();
38732 }
38733 vma->vm_ops = &qxl_ttm_vm_ops;
38734 return 0;
38735 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38736 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38737 {
38738 #if defined(CONFIG_DEBUG_FS)
38739 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38740 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38741 - unsigned i;
38742 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38743 + {
38744 + .name = "qxl_mem_mm",
38745 + .show = &qxl_mm_dump_table,
38746 + },
38747 + {
38748 + .name = "qxl_surf_mm",
38749 + .show = &qxl_mm_dump_table,
38750 + }
38751 + };
38752
38753 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38754 - if (i == 0)
38755 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38756 - else
38757 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38758 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38759 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38760 - qxl_mem_types_list[i].driver_features = 0;
38761 - if (i == 0)
38762 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38763 - else
38764 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38765 + pax_open_kernel();
38766 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38767 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38768 + pax_close_kernel();
38769
38770 - }
38771 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38772 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38773 #else
38774 return 0;
38775 #endif
38776 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38777 index d4660cf..70dbe65 100644
38778 --- a/drivers/gpu/drm/r128/r128_cce.c
38779 +++ b/drivers/gpu/drm/r128/r128_cce.c
38780 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38781
38782 /* GH: Simple idle check.
38783 */
38784 - atomic_set(&dev_priv->idle_count, 0);
38785 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38786
38787 /* We don't support anything other than bus-mastering ring mode,
38788 * but the ring can be in either AGP or PCI space for the ring
38789 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38790 index 930c71b..499aded 100644
38791 --- a/drivers/gpu/drm/r128/r128_drv.h
38792 +++ b/drivers/gpu/drm/r128/r128_drv.h
38793 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38794 int is_pci;
38795 unsigned long cce_buffers_offset;
38796
38797 - atomic_t idle_count;
38798 + atomic_unchecked_t idle_count;
38799
38800 int page_flipping;
38801 int current_page;
38802 u32 crtc_offset;
38803 u32 crtc_offset_cntl;
38804
38805 - atomic_t vbl_received;
38806 + atomic_unchecked_t vbl_received;
38807
38808 u32 color_fmt;
38809 unsigned int front_offset;
38810 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38811 index a954c54..9cc595c 100644
38812 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38813 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38814 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38815 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38816 }
38817
38818 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38819 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38820 [DRM_R128_INIT] = compat_r128_init,
38821 [DRM_R128_DEPTH] = compat_r128_depth,
38822 [DRM_R128_STIPPLE] = compat_r128_stipple,
38823 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38824 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38825 {
38826 unsigned int nr = DRM_IOCTL_NR(cmd);
38827 - drm_ioctl_compat_t *fn = NULL;
38828 int ret;
38829
38830 if (nr < DRM_COMMAND_BASE)
38831 return drm_compat_ioctl(filp, cmd, arg);
38832
38833 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38834 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38835 -
38836 - if (fn != NULL)
38837 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38838 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38839 ret = (*fn) (filp, cmd, arg);
38840 - else
38841 + } else
38842 ret = drm_ioctl(filp, cmd, arg);
38843
38844 return ret;
38845 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38846 index 2ea4f09..d391371 100644
38847 --- a/drivers/gpu/drm/r128/r128_irq.c
38848 +++ b/drivers/gpu/drm/r128/r128_irq.c
38849 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38850 if (crtc != 0)
38851 return 0;
38852
38853 - return atomic_read(&dev_priv->vbl_received);
38854 + return atomic_read_unchecked(&dev_priv->vbl_received);
38855 }
38856
38857 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38858 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38859 /* VBLANK interrupt */
38860 if (status & R128_CRTC_VBLANK_INT) {
38861 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38862 - atomic_inc(&dev_priv->vbl_received);
38863 + atomic_inc_unchecked(&dev_priv->vbl_received);
38864 drm_handle_vblank(dev, 0);
38865 return IRQ_HANDLED;
38866 }
38867 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38868 index 19bb7e6..de7e2a2 100644
38869 --- a/drivers/gpu/drm/r128/r128_state.c
38870 +++ b/drivers/gpu/drm/r128/r128_state.c
38871 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38872
38873 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38874 {
38875 - if (atomic_read(&dev_priv->idle_count) == 0)
38876 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38877 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38878 else
38879 - atomic_set(&dev_priv->idle_count, 0);
38880 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38881 }
38882
38883 #endif
38884 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38885 index af85299..ed9ac8d 100644
38886 --- a/drivers/gpu/drm/radeon/mkregtable.c
38887 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38888 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38889 regex_t mask_rex;
38890 regmatch_t match[4];
38891 char buf[1024];
38892 - size_t end;
38893 + long end;
38894 int len;
38895 int done = 0;
38896 int r;
38897 unsigned o;
38898 struct offset *offset;
38899 char last_reg_s[10];
38900 - int last_reg;
38901 + unsigned long last_reg;
38902
38903 if (regcomp
38904 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38905 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38906 index 63398ae..669e045 100644
38907 --- a/drivers/gpu/drm/radeon/radeon_device.c
38908 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38909 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38910 bool can_switch;
38911
38912 spin_lock(&dev->count_lock);
38913 - can_switch = (dev->open_count == 0);
38914 + can_switch = (local_read(&dev->open_count) == 0);
38915 spin_unlock(&dev->count_lock);
38916 return can_switch;
38917 }
38918 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38919 index b369d42..8dd04eb 100644
38920 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38921 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38922 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38923
38924 /* SW interrupt */
38925 wait_queue_head_t swi_queue;
38926 - atomic_t swi_emitted;
38927 + atomic_unchecked_t swi_emitted;
38928 int vblank_crtc;
38929 uint32_t irq_enable_reg;
38930 uint32_t r500_disp_irq_reg;
38931 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38932 index c180df8..5fd8186 100644
38933 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38934 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38935 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38936 request = compat_alloc_user_space(sizeof(*request));
38937 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38938 || __put_user(req32.param, &request->param)
38939 - || __put_user((void __user *)(unsigned long)req32.value,
38940 + || __put_user((unsigned long)req32.value,
38941 &request->value))
38942 return -EFAULT;
38943
38944 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38945 #define compat_radeon_cp_setparam NULL
38946 #endif /* X86_64 || IA64 */
38947
38948 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38949 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38950 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38951 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38952 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38953 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38954 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38955 {
38956 unsigned int nr = DRM_IOCTL_NR(cmd);
38957 - drm_ioctl_compat_t *fn = NULL;
38958 int ret;
38959
38960 if (nr < DRM_COMMAND_BASE)
38961 return drm_compat_ioctl(filp, cmd, arg);
38962
38963 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38964 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38965 -
38966 - if (fn != NULL)
38967 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38968 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38969 ret = (*fn) (filp, cmd, arg);
38970 - else
38971 + } else
38972 ret = drm_ioctl(filp, cmd, arg);
38973
38974 return ret;
38975 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38976 index 8d68e97..9dcfed8 100644
38977 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38978 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38979 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38980 unsigned int ret;
38981 RING_LOCALS;
38982
38983 - atomic_inc(&dev_priv->swi_emitted);
38984 - ret = atomic_read(&dev_priv->swi_emitted);
38985 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38986 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38987
38988 BEGIN_RING(4);
38989 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38990 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38991 drm_radeon_private_t *dev_priv =
38992 (drm_radeon_private_t *) dev->dev_private;
38993
38994 - atomic_set(&dev_priv->swi_emitted, 0);
38995 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38996 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38997
38998 dev->max_vblank_count = 0x001fffff;
38999 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39000 index 4d20910..6726b6d 100644
39001 --- a/drivers/gpu/drm/radeon/radeon_state.c
39002 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39003 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39004 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39005 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39006
39007 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39008 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39009 sarea_priv->nbox * sizeof(depth_boxes[0])))
39010 return -EFAULT;
39011
39012 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39013 {
39014 drm_radeon_private_t *dev_priv = dev->dev_private;
39015 drm_radeon_getparam_t *param = data;
39016 - int value;
39017 + int value = 0;
39018
39019 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39020
39021 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39022 index 6c0ce89..57a2529 100644
39023 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39024 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39025 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39026 man->size = size >> PAGE_SHIFT;
39027 }
39028
39029 -static struct vm_operations_struct radeon_ttm_vm_ops;
39030 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39031 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39032
39033 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39034 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39035 }
39036 if (unlikely(ttm_vm_ops == NULL)) {
39037 ttm_vm_ops = vma->vm_ops;
39038 + pax_open_kernel();
39039 radeon_ttm_vm_ops = *ttm_vm_ops;
39040 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39041 + pax_close_kernel();
39042 }
39043 vma->vm_ops = &radeon_ttm_vm_ops;
39044 return 0;
39045 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39046 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39047 {
39048 #if defined(CONFIG_DEBUG_FS)
39049 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39050 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39051 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39052 + {
39053 + .name = "radeon_vram_mm",
39054 + .show = &radeon_mm_dump_table,
39055 + },
39056 + {
39057 + .name = "radeon_gtt_mm",
39058 + .show = &radeon_mm_dump_table,
39059 + },
39060 + {
39061 + .name = "ttm_page_pool",
39062 + .show = &ttm_page_alloc_debugfs,
39063 + },
39064 + {
39065 + .name = "ttm_dma_page_pool",
39066 + .show = &ttm_dma_page_alloc_debugfs,
39067 + },
39068 + };
39069 unsigned i;
39070
39071 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39072 - if (i == 0)
39073 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39074 - else
39075 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39076 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39077 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39078 - radeon_mem_types_list[i].driver_features = 0;
39079 - if (i == 0)
39080 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39081 - else
39082 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39083 -
39084 - }
39085 - /* Add ttm page pool to debugfs */
39086 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39087 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39088 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39089 - radeon_mem_types_list[i].driver_features = 0;
39090 - radeon_mem_types_list[i++].data = NULL;
39091 + pax_open_kernel();
39092 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39093 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39094 + pax_close_kernel();
39095 #ifdef CONFIG_SWIOTLB
39096 - if (swiotlb_nr_tbl()) {
39097 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39098 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39099 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39100 - radeon_mem_types_list[i].driver_features = 0;
39101 - radeon_mem_types_list[i++].data = NULL;
39102 - }
39103 + if (swiotlb_nr_tbl())
39104 + i++;
39105 #endif
39106 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39107
39108 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39109 index d8ddfb3..609de1d 100644
39110 --- a/drivers/gpu/drm/radeon/rs690.c
39111 +++ b/drivers/gpu/drm/radeon/rs690.c
39112 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39113 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39114 rdev->pm.sideport_bandwidth.full)
39115 max_bandwidth = rdev->pm.sideport_bandwidth;
39116 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39117 + read_delay_latency.full = dfixed_const(800 * 1000);
39118 read_delay_latency.full = dfixed_div(read_delay_latency,
39119 rdev->pm.igp_sideport_mclk);
39120 + a.full = dfixed_const(370);
39121 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39122 } else {
39123 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39124 rdev->pm.k8_bandwidth.full)
39125 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39126 index dbc2def..0a9f710 100644
39127 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39128 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39129 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39130 zone->glob = glob;
39131 glob->zone_kernel = zone;
39132 ret = kobject_init_and_add(
39133 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39134 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39135 if (unlikely(ret != 0)) {
39136 kobject_put(&zone->kobj);
39137 return ret;
39138 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39139 zone->glob = glob;
39140 glob->zone_dma32 = zone;
39141 ret = kobject_init_and_add(
39142 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39143 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39144 if (unlikely(ret != 0)) {
39145 kobject_put(&zone->kobj);
39146 return ret;
39147 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39148 index bd2a3b4..122d9ad 100644
39149 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39150 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39151 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39152 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39153 struct shrink_control *sc)
39154 {
39155 - static atomic_t start_pool = ATOMIC_INIT(0);
39156 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39157 unsigned i;
39158 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39159 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39160 struct ttm_page_pool *pool;
39161 int shrink_pages = sc->nr_to_scan;
39162
39163 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39164 index 97e9d61..bf23c461 100644
39165 --- a/drivers/gpu/drm/udl/udl_fb.c
39166 +++ b/drivers/gpu/drm/udl/udl_fb.c
39167 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39168 fb_deferred_io_cleanup(info);
39169 kfree(info->fbdefio);
39170 info->fbdefio = NULL;
39171 - info->fbops->fb_mmap = udl_fb_mmap;
39172 }
39173
39174 pr_warn("released /dev/fb%d user=%d count=%d\n",
39175 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39176 index 893a650..6190d3b 100644
39177 --- a/drivers/gpu/drm/via/via_drv.h
39178 +++ b/drivers/gpu/drm/via/via_drv.h
39179 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39180 typedef uint32_t maskarray_t[5];
39181
39182 typedef struct drm_via_irq {
39183 - atomic_t irq_received;
39184 + atomic_unchecked_t irq_received;
39185 uint32_t pending_mask;
39186 uint32_t enable_mask;
39187 wait_queue_head_t irq_queue;
39188 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39189 struct timeval last_vblank;
39190 int last_vblank_valid;
39191 unsigned usec_per_vblank;
39192 - atomic_t vbl_received;
39193 + atomic_unchecked_t vbl_received;
39194 drm_via_state_t hc_state;
39195 char pci_buf[VIA_PCI_BUF_SIZE];
39196 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39197 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39198 index ac98964..5dbf512 100644
39199 --- a/drivers/gpu/drm/via/via_irq.c
39200 +++ b/drivers/gpu/drm/via/via_irq.c
39201 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39202 if (crtc != 0)
39203 return 0;
39204
39205 - return atomic_read(&dev_priv->vbl_received);
39206 + return atomic_read_unchecked(&dev_priv->vbl_received);
39207 }
39208
39209 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39210 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39211
39212 status = VIA_READ(VIA_REG_INTERRUPT);
39213 if (status & VIA_IRQ_VBLANK_PENDING) {
39214 - atomic_inc(&dev_priv->vbl_received);
39215 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39216 + atomic_inc_unchecked(&dev_priv->vbl_received);
39217 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39218 do_gettimeofday(&cur_vblank);
39219 if (dev_priv->last_vblank_valid) {
39220 dev_priv->usec_per_vblank =
39221 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39222 dev_priv->last_vblank = cur_vblank;
39223 dev_priv->last_vblank_valid = 1;
39224 }
39225 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39226 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39227 DRM_DEBUG("US per vblank is: %u\n",
39228 dev_priv->usec_per_vblank);
39229 }
39230 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39231
39232 for (i = 0; i < dev_priv->num_irqs; ++i) {
39233 if (status & cur_irq->pending_mask) {
39234 - atomic_inc(&cur_irq->irq_received);
39235 + atomic_inc_unchecked(&cur_irq->irq_received);
39236 DRM_WAKEUP(&cur_irq->irq_queue);
39237 handled = 1;
39238 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39239 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39240 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39241 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39242 masks[irq][4]));
39243 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39244 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39245 } else {
39246 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39247 (((cur_irq_sequence =
39248 - atomic_read(&cur_irq->irq_received)) -
39249 + atomic_read_unchecked(&cur_irq->irq_received)) -
39250 *sequence) <= (1 << 23)));
39251 }
39252 *sequence = cur_irq_sequence;
39253 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39254 }
39255
39256 for (i = 0; i < dev_priv->num_irqs; ++i) {
39257 - atomic_set(&cur_irq->irq_received, 0);
39258 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39259 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39260 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39261 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39262 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39263 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39264 case VIA_IRQ_RELATIVE:
39265 irqwait->request.sequence +=
39266 - atomic_read(&cur_irq->irq_received);
39267 + atomic_read_unchecked(&cur_irq->irq_received);
39268 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39269 case VIA_IRQ_ABSOLUTE:
39270 break;
39271 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39272 index 13aeda7..4a952d1 100644
39273 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39274 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39275 @@ -290,7 +290,7 @@ struct vmw_private {
39276 * Fencing and IRQs.
39277 */
39278
39279 - atomic_t marker_seq;
39280 + atomic_unchecked_t marker_seq;
39281 wait_queue_head_t fence_queue;
39282 wait_queue_head_t fifo_queue;
39283 int fence_queue_waiters; /* Protected by hw_mutex */
39284 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39285 index 3eb1486..0a47ee9 100644
39286 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39287 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39288 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39289 (unsigned int) min,
39290 (unsigned int) fifo->capabilities);
39291
39292 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39293 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39294 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39295 vmw_marker_queue_init(&fifo->marker_queue);
39296 return vmw_fifo_send_fence(dev_priv, &dummy);
39297 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39298 if (reserveable)
39299 iowrite32(bytes, fifo_mem +
39300 SVGA_FIFO_RESERVED);
39301 - return fifo_mem + (next_cmd >> 2);
39302 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39303 } else {
39304 need_bounce = true;
39305 }
39306 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39307
39308 fm = vmw_fifo_reserve(dev_priv, bytes);
39309 if (unlikely(fm == NULL)) {
39310 - *seqno = atomic_read(&dev_priv->marker_seq);
39311 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39312 ret = -ENOMEM;
39313 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39314 false, 3*HZ);
39315 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39316 }
39317
39318 do {
39319 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39320 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39321 } while (*seqno == 0);
39322
39323 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39324 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39325 index c509d40..3b640c3 100644
39326 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39327 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39328 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39329 int ret;
39330
39331 num_clips = arg->num_clips;
39332 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39333 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39334
39335 if (unlikely(num_clips == 0))
39336 return 0;
39337 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39338 int ret;
39339
39340 num_clips = arg->num_clips;
39341 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39342 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39343
39344 if (unlikely(num_clips == 0))
39345 return 0;
39346 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39347 index 4640adb..e1384ed 100644
39348 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39349 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39350 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39351 * emitted. Then the fence is stale and signaled.
39352 */
39353
39354 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39355 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39356 > VMW_FENCE_WRAP);
39357
39358 return ret;
39359 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39360
39361 if (fifo_idle)
39362 down_read(&fifo_state->rwsem);
39363 - signal_seq = atomic_read(&dev_priv->marker_seq);
39364 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39365 ret = 0;
39366
39367 for (;;) {
39368 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39369 index 8a8725c2..afed796 100644
39370 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39371 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39372 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39373 while (!vmw_lag_lt(queue, us)) {
39374 spin_lock(&queue->lock);
39375 if (list_empty(&queue->head))
39376 - seqno = atomic_read(&dev_priv->marker_seq);
39377 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39378 else {
39379 marker = list_first_entry(&queue->head,
39380 struct vmw_marker, head);
39381 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39382 index 5360e5a..c2c0d26 100644
39383 --- a/drivers/gpu/host1x/drm/dc.c
39384 +++ b/drivers/gpu/host1x/drm/dc.c
39385 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39386 }
39387
39388 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39389 - dc->debugfs_files[i].data = dc;
39390 + *(void **)&dc->debugfs_files[i].data = dc;
39391
39392 err = drm_debugfs_create_files(dc->debugfs_files,
39393 ARRAY_SIZE(debugfs_files),
39394 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39395 index 5956445..1d30d7e 100644
39396 --- a/drivers/hid/hid-core.c
39397 +++ b/drivers/hid/hid-core.c
39398 @@ -759,6 +759,56 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
39399 }
39400 EXPORT_SYMBOL_GPL(hid_parse_report);
39401
39402 +static const char * const hid_report_names[] = {
39403 + "HID_INPUT_REPORT",
39404 + "HID_OUTPUT_REPORT",
39405 + "HID_FEATURE_REPORT",
39406 +};
39407 +/**
39408 + * hid_validate_report - validate existing device report
39409 + *
39410 + * @device: hid device
39411 + * @type: which report type to examine
39412 + * @id: which report ID to examine (0 for first)
39413 + * @fields: expected number of fields
39414 + * @report_counts: expected number of values per field
39415 + *
39416 + * Validate the report details after parsing.
39417 + */
39418 +struct hid_report *hid_validate_report(struct hid_device *hid,
39419 + unsigned int type, unsigned int id,
39420 + unsigned int fields,
39421 + unsigned int report_counts)
39422 +{
39423 + struct hid_report *report;
39424 + unsigned int i;
39425 +
39426 + if (type > HID_FEATURE_REPORT) {
39427 + hid_err(hid, "invalid HID report %u\n", type);
39428 + return NULL;
39429 + }
39430 +
39431 + report = hid->report_enum[type].report_id_hash[id];
39432 + if (!report) {
39433 + hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
39434 + return NULL;
39435 + }
39436 + if (report->maxfield < fields) {
39437 + hid_err(hid, "not enough fields in %s %u\n",
39438 + hid_report_names[type], id);
39439 + return NULL;
39440 + }
39441 + for (i = 0; i < fields; i++) {
39442 + if (report->field[i]->report_count < report_counts) {
39443 + hid_err(hid, "not enough values in %s %u fields\n",
39444 + hid_report_names[type], id);
39445 + return NULL;
39446 + }
39447 + }
39448 + return report;
39449 +}
39450 +EXPORT_SYMBOL_GPL(hid_validate_report);
39451 +
39452 /**
39453 * hid_open_report - open a driver-specific device report
39454 *
39455 @@ -2295,7 +2345,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39456
39457 int hid_add_device(struct hid_device *hdev)
39458 {
39459 - static atomic_t id = ATOMIC_INIT(0);
39460 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39461 int ret;
39462
39463 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39464 @@ -2329,7 +2379,7 @@ int hid_add_device(struct hid_device *hdev)
39465 /* XXX hack, any other cleaner solution after the driver core
39466 * is converted to allow more than 20 bytes as the device name? */
39467 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39468 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39469 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39470
39471 hid_debug_register(hdev, dev_name(&hdev->dev));
39472 ret = device_add(&hdev->dev);
39473 diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
39474 index 07837f5..b697ada 100644
39475 --- a/drivers/hid/hid-lenovo-tpkbd.c
39476 +++ b/drivers/hid/hid-lenovo-tpkbd.c
39477 @@ -341,6 +341,11 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
39478 char *name_mute, *name_micmute;
39479 int ret;
39480
39481 + /* Validate required reports. */
39482 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 4, 4, 1) ||
39483 + !hid_validate_report(hdev, HID_OUTPUT_REPORT, 3, 1, 2))
39484 + return -ENODEV;
39485 +
39486 if (sysfs_create_group(&hdev->dev.kobj,
39487 &tpkbd_attr_group_pointer)) {
39488 hid_warn(hdev, "Could not create sysfs group\n");
39489 diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
39490 index b3cd150..9805197 100644
39491 --- a/drivers/hid/hid-lg2ff.c
39492 +++ b/drivers/hid/hid-lg2ff.c
39493 @@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid)
39494 struct hid_report *report;
39495 struct hid_input *hidinput = list_entry(hid->inputs.next,
39496 struct hid_input, list);
39497 - struct list_head *report_list =
39498 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39499 struct input_dev *dev = hidinput->input;
39500 int error;
39501
39502 - if (list_empty(report_list)) {
39503 - hid_err(hid, "no output report found\n");
39504 + /* Check that the report looks ok */
39505 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7);
39506 + if (!report)
39507 return -ENODEV;
39508 - }
39509 -
39510 - report = list_entry(report_list->next, struct hid_report, list);
39511 -
39512 - if (report->maxfield < 1) {
39513 - hid_err(hid, "output report is empty\n");
39514 - return -ENODEV;
39515 - }
39516 - if (report->field[0]->report_count < 7) {
39517 - hid_err(hid, "not enough values in the field\n");
39518 - return -ENODEV;
39519 - }
39520
39521 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
39522 if (!lg2ff)
39523 diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
39524 index e52f181..53ac79b 100644
39525 --- a/drivers/hid/hid-lg3ff.c
39526 +++ b/drivers/hid/hid-lg3ff.c
39527 @@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
39528 int x, y;
39529
39530 /*
39531 - * Maxusage should always be 63 (maximum fields)
39532 - * likely a better way to ensure this data is clean
39533 + * Available values in the field should always be 63, but we only use up to
39534 + * 35. Instead, clear the entire area, however big it is.
39535 */
39536 - memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
39537 + memset(report->field[0]->value, 0,
39538 + sizeof(__s32) * report->field[0]->report_count);
39539
39540 switch (effect->type) {
39541 case FF_CONSTANT:
39542 @@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = {
39543 int lg3ff_init(struct hid_device *hid)
39544 {
39545 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39546 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39547 struct input_dev *dev = hidinput->input;
39548 - struct hid_report *report;
39549 - struct hid_field *field;
39550 const signed short *ff_bits = ff3_joystick_ac;
39551 int error;
39552 int i;
39553
39554 - /* Find the report to use */
39555 - if (list_empty(report_list)) {
39556 - hid_err(hid, "No output report found\n");
39557 - return -1;
39558 - }
39559 -
39560 /* Check that the report looks ok */
39561 - report = list_entry(report_list->next, struct hid_report, list);
39562 - if (!report) {
39563 - hid_err(hid, "NULL output report\n");
39564 - return -1;
39565 - }
39566 -
39567 - field = report->field[0];
39568 - if (!field) {
39569 - hid_err(hid, "NULL field\n");
39570 - return -1;
39571 - }
39572 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 35))
39573 + return -ENODEV;
39574
39575 /* Assume single fixed device G940 */
39576 for (i = 0; ff_bits[i] >= 0; i++)
39577 diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
39578 index 0ddae2a..8b89f0f 100644
39579 --- a/drivers/hid/hid-lg4ff.c
39580 +++ b/drivers/hid/hid-lg4ff.c
39581 @@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
39582 int lg4ff_init(struct hid_device *hid)
39583 {
39584 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39585 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39586 struct input_dev *dev = hidinput->input;
39587 - struct hid_report *report;
39588 - struct hid_field *field;
39589 struct lg4ff_device_entry *entry;
39590 struct lg_drv_data *drv_data;
39591 struct usb_device_descriptor *udesc;
39592 int error, i, j;
39593 __u16 bcdDevice, rev_maj, rev_min;
39594
39595 - /* Find the report to use */
39596 - if (list_empty(report_list)) {
39597 - hid_err(hid, "No output report found\n");
39598 - return -1;
39599 - }
39600 -
39601 /* Check that the report looks ok */
39602 - report = list_entry(report_list->next, struct hid_report, list);
39603 - if (!report) {
39604 - hid_err(hid, "NULL output report\n");
39605 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
39606 return -1;
39607 - }
39608 -
39609 - field = report->field[0];
39610 - if (!field) {
39611 - hid_err(hid, "NULL field\n");
39612 - return -1;
39613 - }
39614
39615 /* Check what wheel has been connected */
39616 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
39617 diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
39618 index d7ea8c8..a84fb40 100644
39619 --- a/drivers/hid/hid-lgff.c
39620 +++ b/drivers/hid/hid-lgff.c
39621 @@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
39622 int lgff_init(struct hid_device* hid)
39623 {
39624 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
39625 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39626 struct input_dev *dev = hidinput->input;
39627 - struct hid_report *report;
39628 - struct hid_field *field;
39629 const signed short *ff_bits = ff_joystick;
39630 int error;
39631 int i;
39632
39633 - /* Find the report to use */
39634 - if (list_empty(report_list)) {
39635 - hid_err(hid, "No output report found\n");
39636 - return -1;
39637 - }
39638 -
39639 /* Check that the report looks ok */
39640 - report = list_entry(report_list->next, struct hid_report, list);
39641 - field = report->field[0];
39642 - if (!field) {
39643 - hid_err(hid, "NULL field\n");
39644 - return -1;
39645 - }
39646 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
39647 + return -ENODEV;
39648
39649 for (i = 0; i < ARRAY_SIZE(devices); i++) {
39650 if (dev->id.vendor == devices[i].idVendor &&
39651 diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
39652 index cd33084..7b99c2a 100644
39653 --- a/drivers/hid/hid-logitech-dj.c
39654 +++ b/drivers/hid/hid-logitech-dj.c
39655 @@ -461,7 +461,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
39656 struct hid_report *report;
39657 struct hid_report_enum *output_report_enum;
39658 u8 *data = (u8 *)(&dj_report->device_index);
39659 - int i;
39660 + unsigned int i, length;
39661
39662 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
39663 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
39664 @@ -471,7 +471,9 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
39665 return -ENODEV;
39666 }
39667
39668 - for (i = 0; i < report->field[0]->report_count; i++)
39669 + length = min_t(size_t, sizeof(*dj_report) - 1,
39670 + report->field[0]->report_count);
39671 + for (i = 0; i < length; i++)
39672 report->field[0]->value[i] = data[i];
39673
39674 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
39675 @@ -783,6 +785,12 @@ static int logi_dj_probe(struct hid_device *hdev,
39676 goto hid_parse_fail;
39677 }
39678
39679 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
39680 + 1, 3)) {
39681 + retval = -ENODEV;
39682 + goto hid_parse_fail;
39683 + }
39684 +
39685 /* Starts the usb device and connects to upper interfaces hiddev and
39686 * hidraw */
39687 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
39688 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
39689 index cb0e361..2aa275e 100644
39690 --- a/drivers/hid/hid-multitouch.c
39691 +++ b/drivers/hid/hid-multitouch.c
39692 @@ -330,9 +330,18 @@ static void mt_feature_mapping(struct hid_device *hdev,
39693 break;
39694 }
39695 }
39696 + /* Ignore if value index is out of bounds. */
39697 + if (td->inputmode_index < 0 ||
39698 + td->inputmode_index >= field->report_count) {
39699 + dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
39700 + td->inputmode = -1;
39701 + }
39702
39703 break;
39704 case HID_DG_CONTACTMAX:
39705 + /* Ignore if value count is out of bounds. */
39706 + if (field->report_count < 1)
39707 + break;
39708 td->maxcontact_report_id = field->report->id;
39709 td->maxcontacts = field->value[0];
39710 if (!td->maxcontacts &&
39711 @@ -743,15 +752,21 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
39712 unsigned count;
39713 int r, n;
39714
39715 + if (report->maxfield == 0)
39716 + return;
39717 +
39718 /*
39719 * Includes multi-packet support where subsequent
39720 * packets are sent with zero contactcount.
39721 */
39722 - if (td->cc_index >= 0) {
39723 - struct hid_field *field = report->field[td->cc_index];
39724 - int value = field->value[td->cc_value_index];
39725 - if (value)
39726 - td->num_expected = value;
39727 + if (td->cc_index >= 0 && td->cc_index < report->maxfield) {
39728 + field = report->field[td->cc_index];
39729 + if (td->cc_value_index >= 0 &&
39730 + td->cc_value_index < field->report_count) {
39731 + int value = field->value[td->cc_value_index];
39732 + if (value)
39733 + td->num_expected = value;
39734 + }
39735 }
39736
39737 for (r = 0; r < report->maxfield; r++) {
39738 diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
39739 index d164911..ef42e86 100644
39740 --- a/drivers/hid/hid-steelseries.c
39741 +++ b/drivers/hid/hid-steelseries.c
39742 @@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev,
39743 goto err_free;
39744 }
39745
39746 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 0, 1, 16)) {
39747 + ret = -ENODEV;
39748 + goto err_free;
39749 + }
39750 +
39751 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
39752 if (ret) {
39753 hid_err(hdev, "hw start failed\n");
39754 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39755 index c13fb5b..55a3802 100644
39756 --- a/drivers/hid/hid-wiimote-debug.c
39757 +++ b/drivers/hid/hid-wiimote-debug.c
39758 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39759 else if (size == 0)
39760 return -EIO;
39761
39762 - if (copy_to_user(u, buf, size))
39763 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39764 return -EFAULT;
39765
39766 *off += size;
39767 diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
39768 index 6ec28a3..b124991 100644
39769 --- a/drivers/hid/hid-zpff.c
39770 +++ b/drivers/hid/hid-zpff.c
39771 @@ -68,22 +68,12 @@ static int zpff_init(struct hid_device *hid)
39772 struct hid_report *report;
39773 struct hid_input *hidinput = list_entry(hid->inputs.next,
39774 struct hid_input, list);
39775 - struct list_head *report_list =
39776 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
39777 struct input_dev *dev = hidinput->input;
39778 int error;
39779
39780 - if (list_empty(report_list)) {
39781 - hid_err(hid, "no output report found\n");
39782 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 4, 1);
39783 + if (!report)
39784 return -ENODEV;
39785 - }
39786 -
39787 - report = list_entry(report_list->next, struct hid_report, list);
39788 -
39789 - if (report->maxfield < 4) {
39790 - hid_err(hid, "not enough fields in report\n");
39791 - return -ENODEV;
39792 - }
39793
39794 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
39795 if (!zpff)
39796 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39797 index fc307e0..2b255e8 100644
39798 --- a/drivers/hid/uhid.c
39799 +++ b/drivers/hid/uhid.c
39800 @@ -47,7 +47,7 @@ struct uhid_device {
39801 struct mutex report_lock;
39802 wait_queue_head_t report_wait;
39803 atomic_t report_done;
39804 - atomic_t report_id;
39805 + atomic_unchecked_t report_id;
39806 struct uhid_event report_buf;
39807 };
39808
39809 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39810
39811 spin_lock_irqsave(&uhid->qlock, flags);
39812 ev->type = UHID_FEATURE;
39813 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39814 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39815 ev->u.feature.rnum = rnum;
39816 ev->u.feature.rtype = report_type;
39817
39818 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39819 spin_lock_irqsave(&uhid->qlock, flags);
39820
39821 /* id for old report; drop it silently */
39822 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39823 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39824 goto unlock;
39825 if (atomic_read(&uhid->report_done))
39826 goto unlock;
39827 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39828 index 6de6c98..18319e9 100644
39829 --- a/drivers/hv/channel.c
39830 +++ b/drivers/hv/channel.c
39831 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39832 int ret = 0;
39833 int t;
39834
39835 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39836 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39837 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39838 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39839
39840 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39841 if (ret)
39842 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39843 index 88f4096..e50452e 100644
39844 --- a/drivers/hv/hv.c
39845 +++ b/drivers/hv/hv.c
39846 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39847 u64 output_address = (output) ? virt_to_phys(output) : 0;
39848 u32 output_address_hi = output_address >> 32;
39849 u32 output_address_lo = output_address & 0xFFFFFFFF;
39850 - void *hypercall_page = hv_context.hypercall_page;
39851 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39852
39853 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39854 "=a"(hv_status_lo) : "d" (control_hi),
39855 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39856 index deb5c25..ed2d4fd 100644
39857 --- a/drivers/hv/hv_balloon.c
39858 +++ b/drivers/hv/hv_balloon.c
39859 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39860
39861 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39862 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39863 -static atomic_t trans_id = ATOMIC_INIT(0);
39864 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39865
39866 static int dm_ring_size = (5 * PAGE_SIZE);
39867
39868 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39869 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39870 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39871 resp.hdr.size = sizeof(struct dm_hot_add_response);
39872 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39873 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39874
39875 #ifdef CONFIG_MEMORY_HOTPLUG
39876 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39877 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39878 memset(&status, 0, sizeof(struct dm_status));
39879 status.hdr.type = DM_STATUS_REPORT;
39880 status.hdr.size = sizeof(struct dm_status);
39881 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39882 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39883
39884 /*
39885 * The host expects the guest to report free memory.
39886 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39887 * send the status. This can happen if we were interrupted
39888 * after we picked our transaction ID.
39889 */
39890 - if (status.hdr.trans_id != atomic_read(&trans_id))
39891 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39892 return;
39893
39894 vmbus_sendpacket(dm->dev->channel, &status,
39895 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39896 bl_resp = (struct dm_balloon_response *)send_buffer;
39897 memset(send_buffer, 0, PAGE_SIZE);
39898 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39899 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39900 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39901 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39902 bl_resp->more_pages = 1;
39903
39904 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39905
39906 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39907 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39908 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39909 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39910 resp.hdr.size = sizeof(struct dm_unballoon_response);
39911
39912 vmbus_sendpacket(dm_device.dev->channel, &resp,
39913 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39914 memset(&version_req, 0, sizeof(struct dm_version_request));
39915 version_req.hdr.type = DM_VERSION_REQUEST;
39916 version_req.hdr.size = sizeof(struct dm_version_request);
39917 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39918 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39919 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39920 version_req.is_last_attempt = 1;
39921
39922 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39923 memset(&version_req, 0, sizeof(struct dm_version_request));
39924 version_req.hdr.type = DM_VERSION_REQUEST;
39925 version_req.hdr.size = sizeof(struct dm_version_request);
39926 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39927 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39928 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39929 version_req.is_last_attempt = 0;
39930
39931 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39932 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39933 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39934 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39935 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39936 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39937
39938 cap_msg.caps.cap_bits.balloon = 1;
39939 cap_msg.caps.cap_bits.hot_add = 1;
39940 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39941 index d84918f..7f38f9f 100644
39942 --- a/drivers/hv/hyperv_vmbus.h
39943 +++ b/drivers/hv/hyperv_vmbus.h
39944 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39945 struct vmbus_connection {
39946 enum vmbus_connect_state conn_state;
39947
39948 - atomic_t next_gpadl_handle;
39949 + atomic_unchecked_t next_gpadl_handle;
39950
39951 /*
39952 * Represents channel interrupts. Each bit position represents a
39953 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39954 index e8e071f..5b4b245 100644
39955 --- a/drivers/hv/vmbus_drv.c
39956 +++ b/drivers/hv/vmbus_drv.c
39957 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39958 {
39959 int ret = 0;
39960
39961 - static atomic_t device_num = ATOMIC_INIT(0);
39962 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39963
39964 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39965 - atomic_inc_return(&device_num));
39966 + atomic_inc_return_unchecked(&device_num));
39967
39968 child_device_obj->device.bus = &hv_bus;
39969 child_device_obj->device.parent = &hv_acpi_dev->dev;
39970 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39971 index 6351aba..dc4aaf4 100644
39972 --- a/drivers/hwmon/acpi_power_meter.c
39973 +++ b/drivers/hwmon/acpi_power_meter.c
39974 @@ -117,7 +117,7 @@ struct sensor_template {
39975 struct device_attribute *devattr,
39976 const char *buf, size_t count);
39977 int index;
39978 -};
39979 +} __do_const;
39980
39981 /* Averaging interval */
39982 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39983 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39984 struct sensor_template *attrs)
39985 {
39986 struct device *dev = &resource->acpi_dev->dev;
39987 - struct sensor_device_attribute *sensors =
39988 + sensor_device_attribute_no_const *sensors =
39989 &resource->sensors[resource->num_sensors];
39990 int res = 0;
39991
39992 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39993 index 62c2e32..8f2859a 100644
39994 --- a/drivers/hwmon/applesmc.c
39995 +++ b/drivers/hwmon/applesmc.c
39996 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39997 {
39998 struct applesmc_node_group *grp;
39999 struct applesmc_dev_attr *node;
40000 - struct attribute *attr;
40001 + attribute_no_const *attr;
40002 int ret, i;
40003
40004 for (grp = groups; grp->format; grp++) {
40005 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40006 index b25c643..a13460d 100644
40007 --- a/drivers/hwmon/asus_atk0110.c
40008 +++ b/drivers/hwmon/asus_atk0110.c
40009 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40010 struct atk_sensor_data {
40011 struct list_head list;
40012 struct atk_data *data;
40013 - struct device_attribute label_attr;
40014 - struct device_attribute input_attr;
40015 - struct device_attribute limit1_attr;
40016 - struct device_attribute limit2_attr;
40017 + device_attribute_no_const label_attr;
40018 + device_attribute_no_const input_attr;
40019 + device_attribute_no_const limit1_attr;
40020 + device_attribute_no_const limit2_attr;
40021 char label_attr_name[ATTR_NAME_SIZE];
40022 char input_attr_name[ATTR_NAME_SIZE];
40023 char limit1_attr_name[ATTR_NAME_SIZE];
40024 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40025 static struct device_attribute atk_name_attr =
40026 __ATTR(name, 0444, atk_name_show, NULL);
40027
40028 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40029 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40030 sysfs_show_func show)
40031 {
40032 sysfs_attr_init(&attr->attr);
40033 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40034 index 2e5e2dc..5208b31 100644
40035 --- a/drivers/hwmon/coretemp.c
40036 +++ b/drivers/hwmon/coretemp.c
40037 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40038 return NOTIFY_OK;
40039 }
40040
40041 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40042 +static struct notifier_block coretemp_cpu_notifier = {
40043 .notifier_call = coretemp_cpu_callback,
40044 };
40045
40046 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40047 index 1429f6e..ee03d59 100644
40048 --- a/drivers/hwmon/ibmaem.c
40049 +++ b/drivers/hwmon/ibmaem.c
40050 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40051 struct aem_rw_sensor_template *rw)
40052 {
40053 struct device *dev = &data->pdev->dev;
40054 - struct sensor_device_attribute *sensors = data->sensors;
40055 + sensor_device_attribute_no_const *sensors = data->sensors;
40056 int err;
40057
40058 /* Set up read-only sensors */
40059 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40060 index 708081b..fe2d4ab 100644
40061 --- a/drivers/hwmon/iio_hwmon.c
40062 +++ b/drivers/hwmon/iio_hwmon.c
40063 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40064 {
40065 struct device *dev = &pdev->dev;
40066 struct iio_hwmon_state *st;
40067 - struct sensor_device_attribute *a;
40068 + sensor_device_attribute_no_const *a;
40069 int ret, i;
40070 int in_i = 1, temp_i = 1, curr_i = 1;
40071 enum iio_chan_type type;
40072 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40073 index 9add6092..ee7ba3f 100644
40074 --- a/drivers/hwmon/pmbus/pmbus_core.c
40075 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40076 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40077 return 0;
40078 }
40079
40080 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40081 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40082 const char *name,
40083 umode_t mode,
40084 ssize_t (*show)(struct device *dev,
40085 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40086 dev_attr->store = store;
40087 }
40088
40089 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40090 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40091 const char *name,
40092 umode_t mode,
40093 ssize_t (*show)(struct device *dev,
40094 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40095 u16 reg, u8 mask)
40096 {
40097 struct pmbus_boolean *boolean;
40098 - struct sensor_device_attribute *a;
40099 + sensor_device_attribute_no_const *a;
40100
40101 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40102 if (!boolean)
40103 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40104 bool update, bool readonly)
40105 {
40106 struct pmbus_sensor *sensor;
40107 - struct device_attribute *a;
40108 + device_attribute_no_const *a;
40109
40110 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40111 if (!sensor)
40112 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40113 const char *lstring, int index)
40114 {
40115 struct pmbus_label *label;
40116 - struct device_attribute *a;
40117 + device_attribute_no_const *a;
40118
40119 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40120 if (!label)
40121 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40122 index 2507f90..1645765 100644
40123 --- a/drivers/hwmon/sht15.c
40124 +++ b/drivers/hwmon/sht15.c
40125 @@ -169,7 +169,7 @@ struct sht15_data {
40126 int supply_uv;
40127 bool supply_uv_valid;
40128 struct work_struct update_supply_work;
40129 - atomic_t interrupt_handled;
40130 + atomic_unchecked_t interrupt_handled;
40131 };
40132
40133 /**
40134 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40135 ret = gpio_direction_input(data->pdata->gpio_data);
40136 if (ret)
40137 return ret;
40138 - atomic_set(&data->interrupt_handled, 0);
40139 + atomic_set_unchecked(&data->interrupt_handled, 0);
40140
40141 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40142 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40143 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40144 /* Only relevant if the interrupt hasn't occurred. */
40145 - if (!atomic_read(&data->interrupt_handled))
40146 + if (!atomic_read_unchecked(&data->interrupt_handled))
40147 schedule_work(&data->read_work);
40148 }
40149 ret = wait_event_timeout(data->wait_queue,
40150 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40151
40152 /* First disable the interrupt */
40153 disable_irq_nosync(irq);
40154 - atomic_inc(&data->interrupt_handled);
40155 + atomic_inc_unchecked(&data->interrupt_handled);
40156 /* Then schedule a reading work struct */
40157 if (data->state != SHT15_READING_NOTHING)
40158 schedule_work(&data->read_work);
40159 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40160 * If not, then start the interrupt again - care here as could
40161 * have gone low in meantime so verify it hasn't!
40162 */
40163 - atomic_set(&data->interrupt_handled, 0);
40164 + atomic_set_unchecked(&data->interrupt_handled, 0);
40165 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40166 /* If still not occurred or another handler was scheduled */
40167 if (gpio_get_value(data->pdata->gpio_data)
40168 - || atomic_read(&data->interrupt_handled))
40169 + || atomic_read_unchecked(&data->interrupt_handled))
40170 return;
40171 }
40172
40173 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40174 index 38944e9..ae9e5ed 100644
40175 --- a/drivers/hwmon/via-cputemp.c
40176 +++ b/drivers/hwmon/via-cputemp.c
40177 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40178 return NOTIFY_OK;
40179 }
40180
40181 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40182 +static struct notifier_block via_cputemp_cpu_notifier = {
40183 .notifier_call = via_cputemp_cpu_callback,
40184 };
40185
40186 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40187 index 07f01ac..d79ad3d 100644
40188 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40189 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40190 @@ -43,7 +43,7 @@
40191 extern struct i2c_adapter amd756_smbus;
40192
40193 static struct i2c_adapter *s4882_adapter;
40194 -static struct i2c_algorithm *s4882_algo;
40195 +static i2c_algorithm_no_const *s4882_algo;
40196
40197 /* Wrapper access functions for multiplexed SMBus */
40198 static DEFINE_MUTEX(amd756_lock);
40199 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40200 index 2ca268d..c6acbdf 100644
40201 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40202 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40203 @@ -41,7 +41,7 @@
40204 extern struct i2c_adapter *nforce2_smbus;
40205
40206 static struct i2c_adapter *s4985_adapter;
40207 -static struct i2c_algorithm *s4985_algo;
40208 +static i2c_algorithm_no_const *s4985_algo;
40209
40210 /* Wrapper access functions for multiplexed SMBus */
40211 static DEFINE_MUTEX(nforce2_lock);
40212 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40213 index c3ccdea..5b3dc1a 100644
40214 --- a/drivers/i2c/i2c-dev.c
40215 +++ b/drivers/i2c/i2c-dev.c
40216 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40217 break;
40218 }
40219
40220 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40221 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40222 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40223 if (IS_ERR(rdwr_pa[i].buf)) {
40224 res = PTR_ERR(rdwr_pa[i].buf);
40225 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40226 index 0b510ba..4fbb5085 100644
40227 --- a/drivers/ide/ide-cd.c
40228 +++ b/drivers/ide/ide-cd.c
40229 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40230 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40231 if ((unsigned long)buf & alignment
40232 || blk_rq_bytes(rq) & q->dma_pad_mask
40233 - || object_is_on_stack(buf))
40234 + || object_starts_on_stack(buf))
40235 drive->dma = 0;
40236 }
40237 }
40238 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40239 index e145931..08bfc59 100644
40240 --- a/drivers/iio/industrialio-core.c
40241 +++ b/drivers/iio/industrialio-core.c
40242 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40243 }
40244
40245 static
40246 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40247 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40248 const char *postfix,
40249 struct iio_chan_spec const *chan,
40250 ssize_t (*readfunc)(struct device *dev,
40251 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40252 index 784b97c..c9ceadf 100644
40253 --- a/drivers/infiniband/core/cm.c
40254 +++ b/drivers/infiniband/core/cm.c
40255 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40256
40257 struct cm_counter_group {
40258 struct kobject obj;
40259 - atomic_long_t counter[CM_ATTR_COUNT];
40260 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40261 };
40262
40263 struct cm_counter_attribute {
40264 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40265 struct ib_mad_send_buf *msg = NULL;
40266 int ret;
40267
40268 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40269 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40270 counter[CM_REQ_COUNTER]);
40271
40272 /* Quick state check to discard duplicate REQs. */
40273 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40274 if (!cm_id_priv)
40275 return;
40276
40277 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40278 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40279 counter[CM_REP_COUNTER]);
40280 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40281 if (ret)
40282 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40283 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40284 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40285 spin_unlock_irq(&cm_id_priv->lock);
40286 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40287 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40288 counter[CM_RTU_COUNTER]);
40289 goto out;
40290 }
40291 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40292 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40293 dreq_msg->local_comm_id);
40294 if (!cm_id_priv) {
40295 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40296 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40297 counter[CM_DREQ_COUNTER]);
40298 cm_issue_drep(work->port, work->mad_recv_wc);
40299 return -EINVAL;
40300 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40301 case IB_CM_MRA_REP_RCVD:
40302 break;
40303 case IB_CM_TIMEWAIT:
40304 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40305 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40306 counter[CM_DREQ_COUNTER]);
40307 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40308 goto unlock;
40309 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40310 cm_free_msg(msg);
40311 goto deref;
40312 case IB_CM_DREQ_RCVD:
40313 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40314 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40315 counter[CM_DREQ_COUNTER]);
40316 goto unlock;
40317 default:
40318 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40319 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40320 cm_id_priv->msg, timeout)) {
40321 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40322 - atomic_long_inc(&work->port->
40323 + atomic_long_inc_unchecked(&work->port->
40324 counter_group[CM_RECV_DUPLICATES].
40325 counter[CM_MRA_COUNTER]);
40326 goto out;
40327 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40328 break;
40329 case IB_CM_MRA_REQ_RCVD:
40330 case IB_CM_MRA_REP_RCVD:
40331 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40332 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40333 counter[CM_MRA_COUNTER]);
40334 /* fall through */
40335 default:
40336 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40337 case IB_CM_LAP_IDLE:
40338 break;
40339 case IB_CM_MRA_LAP_SENT:
40340 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40341 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40342 counter[CM_LAP_COUNTER]);
40343 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40344 goto unlock;
40345 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40346 cm_free_msg(msg);
40347 goto deref;
40348 case IB_CM_LAP_RCVD:
40349 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40350 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40351 counter[CM_LAP_COUNTER]);
40352 goto unlock;
40353 default:
40354 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40355 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40356 if (cur_cm_id_priv) {
40357 spin_unlock_irq(&cm.lock);
40358 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40359 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40360 counter[CM_SIDR_REQ_COUNTER]);
40361 goto out; /* Duplicate message. */
40362 }
40363 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40364 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40365 msg->retries = 1;
40366
40367 - atomic_long_add(1 + msg->retries,
40368 + atomic_long_add_unchecked(1 + msg->retries,
40369 &port->counter_group[CM_XMIT].counter[attr_index]);
40370 if (msg->retries)
40371 - atomic_long_add(msg->retries,
40372 + atomic_long_add_unchecked(msg->retries,
40373 &port->counter_group[CM_XMIT_RETRIES].
40374 counter[attr_index]);
40375
40376 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40377 }
40378
40379 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40380 - atomic_long_inc(&port->counter_group[CM_RECV].
40381 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40382 counter[attr_id - CM_ATTR_ID_OFFSET]);
40383
40384 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40385 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40386 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40387
40388 return sprintf(buf, "%ld\n",
40389 - atomic_long_read(&group->counter[cm_attr->index]));
40390 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40391 }
40392
40393 static const struct sysfs_ops cm_counter_ops = {
40394 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40395 index 9f5ad7c..588cd84 100644
40396 --- a/drivers/infiniband/core/fmr_pool.c
40397 +++ b/drivers/infiniband/core/fmr_pool.c
40398 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40399
40400 struct task_struct *thread;
40401
40402 - atomic_t req_ser;
40403 - atomic_t flush_ser;
40404 + atomic_unchecked_t req_ser;
40405 + atomic_unchecked_t flush_ser;
40406
40407 wait_queue_head_t force_wait;
40408 };
40409 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40410 struct ib_fmr_pool *pool = pool_ptr;
40411
40412 do {
40413 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40414 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40415 ib_fmr_batch_release(pool);
40416
40417 - atomic_inc(&pool->flush_ser);
40418 + atomic_inc_unchecked(&pool->flush_ser);
40419 wake_up_interruptible(&pool->force_wait);
40420
40421 if (pool->flush_function)
40422 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40423 }
40424
40425 set_current_state(TASK_INTERRUPTIBLE);
40426 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40427 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40428 !kthread_should_stop())
40429 schedule();
40430 __set_current_state(TASK_RUNNING);
40431 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40432 pool->dirty_watermark = params->dirty_watermark;
40433 pool->dirty_len = 0;
40434 spin_lock_init(&pool->pool_lock);
40435 - atomic_set(&pool->req_ser, 0);
40436 - atomic_set(&pool->flush_ser, 0);
40437 + atomic_set_unchecked(&pool->req_ser, 0);
40438 + atomic_set_unchecked(&pool->flush_ser, 0);
40439 init_waitqueue_head(&pool->force_wait);
40440
40441 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40442 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40443 }
40444 spin_unlock_irq(&pool->pool_lock);
40445
40446 - serial = atomic_inc_return(&pool->req_ser);
40447 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40448 wake_up_process(pool->thread);
40449
40450 if (wait_event_interruptible(pool->force_wait,
40451 - atomic_read(&pool->flush_ser) - serial >= 0))
40452 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40453 return -EINTR;
40454
40455 return 0;
40456 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40457 } else {
40458 list_add_tail(&fmr->list, &pool->dirty_list);
40459 if (++pool->dirty_len >= pool->dirty_watermark) {
40460 - atomic_inc(&pool->req_ser);
40461 + atomic_inc_unchecked(&pool->req_ser);
40462 wake_up_process(pool->thread);
40463 }
40464 }
40465 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40466 index 4cb8eb2..146bf60 100644
40467 --- a/drivers/infiniband/hw/cxgb4/mem.c
40468 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40469 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40470 int err;
40471 struct fw_ri_tpte tpt;
40472 u32 stag_idx;
40473 - static atomic_t key;
40474 + static atomic_unchecked_t key;
40475
40476 if (c4iw_fatal_error(rdev))
40477 return -EIO;
40478 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40479 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40480 rdev->stats.stag.max = rdev->stats.stag.cur;
40481 mutex_unlock(&rdev->stats.lock);
40482 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40483 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40484 }
40485 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40486 __func__, stag_state, type, pdid, stag_idx);
40487 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40488 index 79b3dbc..96e5fcc 100644
40489 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40490 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40491 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40492 struct ib_atomic_eth *ateth;
40493 struct ipath_ack_entry *e;
40494 u64 vaddr;
40495 - atomic64_t *maddr;
40496 + atomic64_unchecked_t *maddr;
40497 u64 sdata;
40498 u32 rkey;
40499 u8 next;
40500 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40501 IB_ACCESS_REMOTE_ATOMIC)))
40502 goto nack_acc_unlck;
40503 /* Perform atomic OP and save result. */
40504 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40505 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40506 sdata = be64_to_cpu(ateth->swap_data);
40507 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40508 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40509 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40510 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40511 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40512 be64_to_cpu(ateth->compare_data),
40513 sdata);
40514 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40515 index 1f95bba..9530f87 100644
40516 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40517 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40518 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40519 unsigned long flags;
40520 struct ib_wc wc;
40521 u64 sdata;
40522 - atomic64_t *maddr;
40523 + atomic64_unchecked_t *maddr;
40524 enum ib_wc_status send_status;
40525
40526 /*
40527 @@ -382,11 +382,11 @@ again:
40528 IB_ACCESS_REMOTE_ATOMIC)))
40529 goto acc_err;
40530 /* Perform atomic OP and save result. */
40531 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40532 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40533 sdata = wqe->wr.wr.atomic.compare_add;
40534 *(u64 *) sqp->s_sge.sge.vaddr =
40535 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40536 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40537 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40538 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40539 sdata, wqe->wr.wr.atomic.swap);
40540 goto send_comp;
40541 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40542 index f2a3f48..673ec79 100644
40543 --- a/drivers/infiniband/hw/mlx4/mad.c
40544 +++ b/drivers/infiniband/hw/mlx4/mad.c
40545 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40546
40547 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40548 {
40549 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40550 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40551 cpu_to_be64(0xff00000000000000LL);
40552 }
40553
40554 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40555 index 25b2cdf..099ff97 100644
40556 --- a/drivers/infiniband/hw/mlx4/mcg.c
40557 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40558 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40559 {
40560 char name[20];
40561
40562 - atomic_set(&ctx->tid, 0);
40563 + atomic_set_unchecked(&ctx->tid, 0);
40564 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40565 ctx->mcg_wq = create_singlethread_workqueue(name);
40566 if (!ctx->mcg_wq)
40567 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40568 index f61ec26..ebf72cf 100644
40569 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40570 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40571 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40572 struct list_head mcg_mgid0_list;
40573 struct workqueue_struct *mcg_wq;
40574 struct mlx4_ib_demux_pv_ctx **tun;
40575 - atomic_t tid;
40576 + atomic_unchecked_t tid;
40577 int flushing; /* flushing the work queue */
40578 };
40579
40580 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40581 index 9d3e5c1..d9afe4a 100644
40582 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40583 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40584 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40585 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40586 }
40587
40588 -int mthca_QUERY_FW(struct mthca_dev *dev)
40589 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40590 {
40591 struct mthca_mailbox *mailbox;
40592 u32 *outbox;
40593 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40594 index ed9a989..e0c5871 100644
40595 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40596 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40597 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40598 return key;
40599 }
40600
40601 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40602 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40603 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40604 {
40605 struct mthca_mailbox *mailbox;
40606 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40607 index 4291410..d2ab1fb 100644
40608 --- a/drivers/infiniband/hw/nes/nes.c
40609 +++ b/drivers/infiniband/hw/nes/nes.c
40610 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40611 LIST_HEAD(nes_adapter_list);
40612 static LIST_HEAD(nes_dev_list);
40613
40614 -atomic_t qps_destroyed;
40615 +atomic_unchecked_t qps_destroyed;
40616
40617 static unsigned int ee_flsh_adapter;
40618 static unsigned int sysfs_nonidx_addr;
40619 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40620 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40621 struct nes_adapter *nesadapter = nesdev->nesadapter;
40622
40623 - atomic_inc(&qps_destroyed);
40624 + atomic_inc_unchecked(&qps_destroyed);
40625
40626 /* Free the control structures */
40627
40628 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40629 index 33cc589..3bd6538 100644
40630 --- a/drivers/infiniband/hw/nes/nes.h
40631 +++ b/drivers/infiniband/hw/nes/nes.h
40632 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40633 extern unsigned int wqm_quanta;
40634 extern struct list_head nes_adapter_list;
40635
40636 -extern atomic_t cm_connects;
40637 -extern atomic_t cm_accepts;
40638 -extern atomic_t cm_disconnects;
40639 -extern atomic_t cm_closes;
40640 -extern atomic_t cm_connecteds;
40641 -extern atomic_t cm_connect_reqs;
40642 -extern atomic_t cm_rejects;
40643 -extern atomic_t mod_qp_timouts;
40644 -extern atomic_t qps_created;
40645 -extern atomic_t qps_destroyed;
40646 -extern atomic_t sw_qps_destroyed;
40647 +extern atomic_unchecked_t cm_connects;
40648 +extern atomic_unchecked_t cm_accepts;
40649 +extern atomic_unchecked_t cm_disconnects;
40650 +extern atomic_unchecked_t cm_closes;
40651 +extern atomic_unchecked_t cm_connecteds;
40652 +extern atomic_unchecked_t cm_connect_reqs;
40653 +extern atomic_unchecked_t cm_rejects;
40654 +extern atomic_unchecked_t mod_qp_timouts;
40655 +extern atomic_unchecked_t qps_created;
40656 +extern atomic_unchecked_t qps_destroyed;
40657 +extern atomic_unchecked_t sw_qps_destroyed;
40658 extern u32 mh_detected;
40659 extern u32 mh_pauses_sent;
40660 extern u32 cm_packets_sent;
40661 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40662 extern u32 cm_packets_received;
40663 extern u32 cm_packets_dropped;
40664 extern u32 cm_packets_retrans;
40665 -extern atomic_t cm_listens_created;
40666 -extern atomic_t cm_listens_destroyed;
40667 +extern atomic_unchecked_t cm_listens_created;
40668 +extern atomic_unchecked_t cm_listens_destroyed;
40669 extern u32 cm_backlog_drops;
40670 -extern atomic_t cm_loopbacks;
40671 -extern atomic_t cm_nodes_created;
40672 -extern atomic_t cm_nodes_destroyed;
40673 -extern atomic_t cm_accel_dropped_pkts;
40674 -extern atomic_t cm_resets_recvd;
40675 -extern atomic_t pau_qps_created;
40676 -extern atomic_t pau_qps_destroyed;
40677 +extern atomic_unchecked_t cm_loopbacks;
40678 +extern atomic_unchecked_t cm_nodes_created;
40679 +extern atomic_unchecked_t cm_nodes_destroyed;
40680 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40681 +extern atomic_unchecked_t cm_resets_recvd;
40682 +extern atomic_unchecked_t pau_qps_created;
40683 +extern atomic_unchecked_t pau_qps_destroyed;
40684
40685 extern u32 int_mod_timer_init;
40686 extern u32 int_mod_cq_depth_256;
40687 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40688 index 24b9f1a..00fd004 100644
40689 --- a/drivers/infiniband/hw/nes/nes_cm.c
40690 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40691 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40692 u32 cm_packets_retrans;
40693 u32 cm_packets_created;
40694 u32 cm_packets_received;
40695 -atomic_t cm_listens_created;
40696 -atomic_t cm_listens_destroyed;
40697 +atomic_unchecked_t cm_listens_created;
40698 +atomic_unchecked_t cm_listens_destroyed;
40699 u32 cm_backlog_drops;
40700 -atomic_t cm_loopbacks;
40701 -atomic_t cm_nodes_created;
40702 -atomic_t cm_nodes_destroyed;
40703 -atomic_t cm_accel_dropped_pkts;
40704 -atomic_t cm_resets_recvd;
40705 +atomic_unchecked_t cm_loopbacks;
40706 +atomic_unchecked_t cm_nodes_created;
40707 +atomic_unchecked_t cm_nodes_destroyed;
40708 +atomic_unchecked_t cm_accel_dropped_pkts;
40709 +atomic_unchecked_t cm_resets_recvd;
40710
40711 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40712 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40713 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40714
40715 static struct nes_cm_core *g_cm_core;
40716
40717 -atomic_t cm_connects;
40718 -atomic_t cm_accepts;
40719 -atomic_t cm_disconnects;
40720 -atomic_t cm_closes;
40721 -atomic_t cm_connecteds;
40722 -atomic_t cm_connect_reqs;
40723 -atomic_t cm_rejects;
40724 +atomic_unchecked_t cm_connects;
40725 +atomic_unchecked_t cm_accepts;
40726 +atomic_unchecked_t cm_disconnects;
40727 +atomic_unchecked_t cm_closes;
40728 +atomic_unchecked_t cm_connecteds;
40729 +atomic_unchecked_t cm_connect_reqs;
40730 +atomic_unchecked_t cm_rejects;
40731
40732 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40733 {
40734 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40735 kfree(listener);
40736 listener = NULL;
40737 ret = 0;
40738 - atomic_inc(&cm_listens_destroyed);
40739 + atomic_inc_unchecked(&cm_listens_destroyed);
40740 } else {
40741 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40742 }
40743 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40744 cm_node->rem_mac);
40745
40746 add_hte_node(cm_core, cm_node);
40747 - atomic_inc(&cm_nodes_created);
40748 + atomic_inc_unchecked(&cm_nodes_created);
40749
40750 return cm_node;
40751 }
40752 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40753 }
40754
40755 atomic_dec(&cm_core->node_cnt);
40756 - atomic_inc(&cm_nodes_destroyed);
40757 + atomic_inc_unchecked(&cm_nodes_destroyed);
40758 nesqp = cm_node->nesqp;
40759 if (nesqp) {
40760 nesqp->cm_node = NULL;
40761 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40762
40763 static void drop_packet(struct sk_buff *skb)
40764 {
40765 - atomic_inc(&cm_accel_dropped_pkts);
40766 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40767 dev_kfree_skb_any(skb);
40768 }
40769
40770 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40771 {
40772
40773 int reset = 0; /* whether to send reset in case of err.. */
40774 - atomic_inc(&cm_resets_recvd);
40775 + atomic_inc_unchecked(&cm_resets_recvd);
40776 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40777 " refcnt=%d\n", cm_node, cm_node->state,
40778 atomic_read(&cm_node->ref_count));
40779 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40780 rem_ref_cm_node(cm_node->cm_core, cm_node);
40781 return NULL;
40782 }
40783 - atomic_inc(&cm_loopbacks);
40784 + atomic_inc_unchecked(&cm_loopbacks);
40785 loopbackremotenode->loopbackpartner = cm_node;
40786 loopbackremotenode->tcp_cntxt.rcv_wscale =
40787 NES_CM_DEFAULT_RCV_WND_SCALE;
40788 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40789 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40790 else {
40791 rem_ref_cm_node(cm_core, cm_node);
40792 - atomic_inc(&cm_accel_dropped_pkts);
40793 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40794 dev_kfree_skb_any(skb);
40795 }
40796 break;
40797 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40798
40799 if ((cm_id) && (cm_id->event_handler)) {
40800 if (issue_disconn) {
40801 - atomic_inc(&cm_disconnects);
40802 + atomic_inc_unchecked(&cm_disconnects);
40803 cm_event.event = IW_CM_EVENT_DISCONNECT;
40804 cm_event.status = disconn_status;
40805 cm_event.local_addr = cm_id->local_addr;
40806 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40807 }
40808
40809 if (issue_close) {
40810 - atomic_inc(&cm_closes);
40811 + atomic_inc_unchecked(&cm_closes);
40812 nes_disconnect(nesqp, 1);
40813
40814 cm_id->provider_data = nesqp;
40815 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40816
40817 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40818 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40819 - atomic_inc(&cm_accepts);
40820 + atomic_inc_unchecked(&cm_accepts);
40821
40822 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40823 netdev_refcnt_read(nesvnic->netdev));
40824 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40825 struct nes_cm_core *cm_core;
40826 u8 *start_buff;
40827
40828 - atomic_inc(&cm_rejects);
40829 + atomic_inc_unchecked(&cm_rejects);
40830 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40831 loopback = cm_node->loopbackpartner;
40832 cm_core = cm_node->cm_core;
40833 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40834 ntohl(cm_id->local_addr.sin_addr.s_addr),
40835 ntohs(cm_id->local_addr.sin_port));
40836
40837 - atomic_inc(&cm_connects);
40838 + atomic_inc_unchecked(&cm_connects);
40839 nesqp->active_conn = 1;
40840
40841 /* cache the cm_id in the qp */
40842 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40843 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40844 return err;
40845 }
40846 - atomic_inc(&cm_listens_created);
40847 + atomic_inc_unchecked(&cm_listens_created);
40848 }
40849
40850 cm_id->add_ref(cm_id);
40851 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40852
40853 if (nesqp->destroyed)
40854 return;
40855 - atomic_inc(&cm_connecteds);
40856 + atomic_inc_unchecked(&cm_connecteds);
40857 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40858 " local port 0x%04X. jiffies = %lu.\n",
40859 nesqp->hwqp.qp_id,
40860 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40861
40862 cm_id->add_ref(cm_id);
40863 ret = cm_id->event_handler(cm_id, &cm_event);
40864 - atomic_inc(&cm_closes);
40865 + atomic_inc_unchecked(&cm_closes);
40866 cm_event.event = IW_CM_EVENT_CLOSE;
40867 cm_event.status = 0;
40868 cm_event.provider_data = cm_id->provider_data;
40869 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40870 return;
40871 cm_id = cm_node->cm_id;
40872
40873 - atomic_inc(&cm_connect_reqs);
40874 + atomic_inc_unchecked(&cm_connect_reqs);
40875 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40876 cm_node, cm_id, jiffies);
40877
40878 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40879 return;
40880 cm_id = cm_node->cm_id;
40881
40882 - atomic_inc(&cm_connect_reqs);
40883 + atomic_inc_unchecked(&cm_connect_reqs);
40884 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40885 cm_node, cm_id, jiffies);
40886
40887 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40888 index 4166452..fc952c3 100644
40889 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40890 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40891 @@ -40,8 +40,8 @@
40892 #include "nes.h"
40893 #include "nes_mgt.h"
40894
40895 -atomic_t pau_qps_created;
40896 -atomic_t pau_qps_destroyed;
40897 +atomic_unchecked_t pau_qps_created;
40898 +atomic_unchecked_t pau_qps_destroyed;
40899
40900 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40901 {
40902 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40903 {
40904 struct sk_buff *skb;
40905 unsigned long flags;
40906 - atomic_inc(&pau_qps_destroyed);
40907 + atomic_inc_unchecked(&pau_qps_destroyed);
40908
40909 /* Free packets that have not yet been forwarded */
40910 /* Lock is acquired by skb_dequeue when removing the skb */
40911 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40912 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40913 skb_queue_head_init(&nesqp->pau_list);
40914 spin_lock_init(&nesqp->pau_lock);
40915 - atomic_inc(&pau_qps_created);
40916 + atomic_inc_unchecked(&pau_qps_created);
40917 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40918 }
40919
40920 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40921 index 49eb511..a774366 100644
40922 --- a/drivers/infiniband/hw/nes/nes_nic.c
40923 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40924 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40925 target_stat_values[++index] = mh_detected;
40926 target_stat_values[++index] = mh_pauses_sent;
40927 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40928 - target_stat_values[++index] = atomic_read(&cm_connects);
40929 - target_stat_values[++index] = atomic_read(&cm_accepts);
40930 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40931 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40932 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40933 - target_stat_values[++index] = atomic_read(&cm_rejects);
40934 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40935 - target_stat_values[++index] = atomic_read(&qps_created);
40936 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40937 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40938 - target_stat_values[++index] = atomic_read(&cm_closes);
40939 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40940 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40941 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40942 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40943 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40944 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40945 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40946 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40947 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40948 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40949 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40950 target_stat_values[++index] = cm_packets_sent;
40951 target_stat_values[++index] = cm_packets_bounced;
40952 target_stat_values[++index] = cm_packets_created;
40953 target_stat_values[++index] = cm_packets_received;
40954 target_stat_values[++index] = cm_packets_dropped;
40955 target_stat_values[++index] = cm_packets_retrans;
40956 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40957 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40958 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40959 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40960 target_stat_values[++index] = cm_backlog_drops;
40961 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40962 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40963 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40964 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40965 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40966 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40967 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40968 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40969 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40970 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40971 target_stat_values[++index] = nesadapter->free_4kpbl;
40972 target_stat_values[++index] = nesadapter->free_256pbl;
40973 target_stat_values[++index] = int_mod_timer_init;
40974 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40975 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40976 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40977 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40978 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40979 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40980 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40981 }
40982
40983 /**
40984 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40985 index 5b53ca5..443da3c 100644
40986 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40987 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40988 @@ -46,9 +46,9 @@
40989
40990 #include <rdma/ib_umem.h>
40991
40992 -atomic_t mod_qp_timouts;
40993 -atomic_t qps_created;
40994 -atomic_t sw_qps_destroyed;
40995 +atomic_unchecked_t mod_qp_timouts;
40996 +atomic_unchecked_t qps_created;
40997 +atomic_unchecked_t sw_qps_destroyed;
40998
40999 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41000
41001 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41002 if (init_attr->create_flags)
41003 return ERR_PTR(-EINVAL);
41004
41005 - atomic_inc(&qps_created);
41006 + atomic_inc_unchecked(&qps_created);
41007 switch (init_attr->qp_type) {
41008 case IB_QPT_RC:
41009 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41010 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41011 struct iw_cm_event cm_event;
41012 int ret = 0;
41013
41014 - atomic_inc(&sw_qps_destroyed);
41015 + atomic_inc_unchecked(&sw_qps_destroyed);
41016 nesqp->destroyed = 1;
41017
41018 /* Blow away the connection if it exists. */
41019 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41020 index 4a9af79..b993f75 100644
41021 --- a/drivers/infiniband/hw/qib/qib.h
41022 +++ b/drivers/infiniband/hw/qib/qib.h
41023 @@ -52,6 +52,7 @@
41024 #include <linux/kref.h>
41025 #include <linux/sched.h>
41026 #include <linux/kthread.h>
41027 +#include <linux/slab.h>
41028
41029 #include "qib_common.h"
41030 #include "qib_verbs.h"
41031 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41032 index da739d9..da1c7f4 100644
41033 --- a/drivers/input/gameport/gameport.c
41034 +++ b/drivers/input/gameport/gameport.c
41035 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41036 */
41037 static void gameport_init_port(struct gameport *gameport)
41038 {
41039 - static atomic_t gameport_no = ATOMIC_INIT(0);
41040 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41041
41042 __module_get(THIS_MODULE);
41043
41044 mutex_init(&gameport->drv_mutex);
41045 device_initialize(&gameport->dev);
41046 dev_set_name(&gameport->dev, "gameport%lu",
41047 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41048 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41049 gameport->dev.bus = &gameport_bus;
41050 gameport->dev.release = gameport_release_port;
41051 if (gameport->parent)
41052 diff --git a/drivers/input/input.c b/drivers/input/input.c
41053 index c044699..174d71a 100644
41054 --- a/drivers/input/input.c
41055 +++ b/drivers/input/input.c
41056 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
41057 */
41058 int input_register_device(struct input_dev *dev)
41059 {
41060 - static atomic_t input_no = ATOMIC_INIT(0);
41061 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41062 struct input_devres *devres = NULL;
41063 struct input_handler *handler;
41064 unsigned int packet_size;
41065 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
41066 dev->setkeycode = input_default_setkeycode;
41067
41068 dev_set_name(&dev->dev, "input%ld",
41069 - (unsigned long) atomic_inc_return(&input_no) - 1);
41070 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41071
41072 error = device_add(&dev->dev);
41073 if (error)
41074 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41075 index 04c69af..5f92d00 100644
41076 --- a/drivers/input/joystick/sidewinder.c
41077 +++ b/drivers/input/joystick/sidewinder.c
41078 @@ -30,6 +30,7 @@
41079 #include <linux/kernel.h>
41080 #include <linux/module.h>
41081 #include <linux/slab.h>
41082 +#include <linux/sched.h>
41083 #include <linux/init.h>
41084 #include <linux/input.h>
41085 #include <linux/gameport.h>
41086 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41087 index 75e3b10..fb390fd 100644
41088 --- a/drivers/input/joystick/xpad.c
41089 +++ b/drivers/input/joystick/xpad.c
41090 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41091
41092 static int xpad_led_probe(struct usb_xpad *xpad)
41093 {
41094 - static atomic_t led_seq = ATOMIC_INIT(0);
41095 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41096 long led_no;
41097 struct xpad_led *led;
41098 struct led_classdev *led_cdev;
41099 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41100 if (!led)
41101 return -ENOMEM;
41102
41103 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41104 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41105
41106 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41107 led->xpad = xpad;
41108 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41109 index e204f26..8459f15 100644
41110 --- a/drivers/input/misc/ims-pcu.c
41111 +++ b/drivers/input/misc/ims-pcu.c
41112 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41113
41114 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41115 {
41116 - static atomic_t device_no = ATOMIC_INIT(0);
41117 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41118
41119 const struct ims_pcu_device_info *info;
41120 u8 device_id;
41121 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41122 }
41123
41124 /* Device appears to be operable, complete initialization */
41125 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41126 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41127
41128 error = ims_pcu_setup_backlight(pcu);
41129 if (error)
41130 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41131 index 2f0b39d..7370f13 100644
41132 --- a/drivers/input/mouse/psmouse.h
41133 +++ b/drivers/input/mouse/psmouse.h
41134 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41135 ssize_t (*set)(struct psmouse *psmouse, void *data,
41136 const char *buf, size_t count);
41137 bool protect;
41138 -};
41139 +} __do_const;
41140 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41141
41142 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41143 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41144 index 4c842c3..590b0bf 100644
41145 --- a/drivers/input/mousedev.c
41146 +++ b/drivers/input/mousedev.c
41147 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41148
41149 spin_unlock_irq(&client->packet_lock);
41150
41151 - if (copy_to_user(buffer, data, count))
41152 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41153 return -EFAULT;
41154
41155 return count;
41156 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41157 index 25fc597..558bf3b3 100644
41158 --- a/drivers/input/serio/serio.c
41159 +++ b/drivers/input/serio/serio.c
41160 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41161 */
41162 static void serio_init_port(struct serio *serio)
41163 {
41164 - static atomic_t serio_no = ATOMIC_INIT(0);
41165 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41166
41167 __module_get(THIS_MODULE);
41168
41169 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41170 mutex_init(&serio->drv_mutex);
41171 device_initialize(&serio->dev);
41172 dev_set_name(&serio->dev, "serio%ld",
41173 - (long)atomic_inc_return(&serio_no) - 1);
41174 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41175 serio->dev.bus = &serio_bus;
41176 serio->dev.release = serio_release_port;
41177 serio->dev.groups = serio_device_attr_groups;
41178 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41179 index 59df2e7..8f1cafb 100644
41180 --- a/drivers/input/serio/serio_raw.c
41181 +++ b/drivers/input/serio/serio_raw.c
41182 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41183
41184 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41185 {
41186 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41187 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41188 struct serio_raw *serio_raw;
41189 int err;
41190
41191 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41192 }
41193
41194 snprintf(serio_raw->name, sizeof(serio_raw->name),
41195 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41196 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41197 kref_init(&serio_raw->kref);
41198 INIT_LIST_HEAD(&serio_raw->client_list);
41199 init_waitqueue_head(&serio_raw->wait);
41200 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41201 index fbe9ca7..dbee61d 100644
41202 --- a/drivers/iommu/iommu.c
41203 +++ b/drivers/iommu/iommu.c
41204 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41205 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41206 {
41207 bus_register_notifier(bus, &iommu_bus_nb);
41208 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41209 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41210 }
41211
41212 /**
41213 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41214 index 39f81ae..2660096 100644
41215 --- a/drivers/iommu/irq_remapping.c
41216 +++ b/drivers/iommu/irq_remapping.c
41217 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41218 void panic_if_irq_remap(const char *msg)
41219 {
41220 if (irq_remapping_enabled)
41221 - panic(msg);
41222 + panic("%s", msg);
41223 }
41224
41225 static void ir_ack_apic_edge(struct irq_data *data)
41226 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41227
41228 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41229 {
41230 - chip->irq_print_chip = ir_print_prefix;
41231 - chip->irq_ack = ir_ack_apic_edge;
41232 - chip->irq_eoi = ir_ack_apic_level;
41233 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41234 + pax_open_kernel();
41235 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41236 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41237 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41238 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41239 + pax_close_kernel();
41240 }
41241
41242 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41243 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41244 index ee7c503..5d4ce08 100644
41245 --- a/drivers/irqchip/irq-gic.c
41246 +++ b/drivers/irqchip/irq-gic.c
41247 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41248 * Supported arch specific GIC irq extension.
41249 * Default make them NULL.
41250 */
41251 -struct irq_chip gic_arch_extn = {
41252 +irq_chip_no_const gic_arch_extn = {
41253 .irq_eoi = NULL,
41254 .irq_mask = NULL,
41255 .irq_unmask = NULL,
41256 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41257 chained_irq_exit(chip, desc);
41258 }
41259
41260 -static struct irq_chip gic_chip = {
41261 +static irq_chip_no_const gic_chip __read_only = {
41262 .name = "GIC",
41263 .irq_mask = gic_mask_irq,
41264 .irq_unmask = gic_unmask_irq,
41265 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41266 index ac6f72b..81150f2 100644
41267 --- a/drivers/isdn/capi/capi.c
41268 +++ b/drivers/isdn/capi/capi.c
41269 @@ -81,8 +81,8 @@ struct capiminor {
41270
41271 struct capi20_appl *ap;
41272 u32 ncci;
41273 - atomic_t datahandle;
41274 - atomic_t msgid;
41275 + atomic_unchecked_t datahandle;
41276 + atomic_unchecked_t msgid;
41277
41278 struct tty_port port;
41279 int ttyinstop;
41280 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41281 capimsg_setu16(s, 2, mp->ap->applid);
41282 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41283 capimsg_setu8 (s, 5, CAPI_RESP);
41284 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41285 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41286 capimsg_setu32(s, 8, mp->ncci);
41287 capimsg_setu16(s, 12, datahandle);
41288 }
41289 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41290 mp->outbytes -= len;
41291 spin_unlock_bh(&mp->outlock);
41292
41293 - datahandle = atomic_inc_return(&mp->datahandle);
41294 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41295 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41296 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41297 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41298 capimsg_setu16(skb->data, 2, mp->ap->applid);
41299 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41300 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41301 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41302 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41303 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41304 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41305 capimsg_setu16(skb->data, 16, len); /* Data length */
41306 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41307 index 600c79b..3752bab 100644
41308 --- a/drivers/isdn/gigaset/interface.c
41309 +++ b/drivers/isdn/gigaset/interface.c
41310 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41311 }
41312 tty->driver_data = cs;
41313
41314 - ++cs->port.count;
41315 + atomic_inc(&cs->port.count);
41316
41317 - if (cs->port.count == 1) {
41318 + if (atomic_read(&cs->port.count) == 1) {
41319 tty_port_tty_set(&cs->port, tty);
41320 cs->port.low_latency = 1;
41321 }
41322 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41323
41324 if (!cs->connected)
41325 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41326 - else if (!cs->port.count)
41327 + else if (!atomic_read(&cs->port.count))
41328 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41329 - else if (!--cs->port.count)
41330 + else if (!atomic_dec_return(&cs->port.count))
41331 tty_port_tty_set(&cs->port, NULL);
41332
41333 mutex_unlock(&cs->mutex);
41334 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41335 index d0a41cb..f0cdb8c 100644
41336 --- a/drivers/isdn/gigaset/usb-gigaset.c
41337 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41338 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41339 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41340 memcpy(cs->hw.usb->bchars, buf, 6);
41341 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41342 - 0, 0, &buf, 6, 2000);
41343 + 0, 0, buf, 6, 2000);
41344 }
41345
41346 static void gigaset_freebcshw(struct bc_state *bcs)
41347 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41348 index 4d9b195..455075c 100644
41349 --- a/drivers/isdn/hardware/avm/b1.c
41350 +++ b/drivers/isdn/hardware/avm/b1.c
41351 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41352 }
41353 if (left) {
41354 if (t4file->user) {
41355 - if (copy_from_user(buf, dp, left))
41356 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41357 return -EFAULT;
41358 } else {
41359 memcpy(buf, dp, left);
41360 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41361 }
41362 if (left) {
41363 if (config->user) {
41364 - if (copy_from_user(buf, dp, left))
41365 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41366 return -EFAULT;
41367 } else {
41368 memcpy(buf, dp, left);
41369 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41370 index 1063bab..36817e0 100644
41371 --- a/drivers/isdn/hisax/amd7930_fn.c
41372 +++ b/drivers/isdn/hisax/amd7930_fn.c
41373 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41374
41375 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41376 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41377 - debugl1(cs, cs->dlog);
41378 + debugl1(cs, "%s", cs->dlog);
41379 }
41380 /* moves received data in sk-buffer */
41381 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41382 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41383
41384 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41385 QuickHex(t, deb_ptr, count);
41386 - debugl1(cs, cs->dlog);
41387 + debugl1(cs, "%s", cs->dlog);
41388 }
41389 /* AMD interrupts on */
41390 AmdIrqOn(cs);
41391 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41392 index ee9b9a0..d1427bd 100644
41393 --- a/drivers/isdn/hisax/avm_pci.c
41394 +++ b/drivers/isdn/hisax/avm_pci.c
41395 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41396 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41397 bcs->channel ? 'B' : 'A', count);
41398 QuickHex(t, p, count);
41399 - debugl1(cs, bcs->blog);
41400 + debugl1(cs, "%s", bcs->blog);
41401 }
41402 }
41403
41404 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41405 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41406 bcs->channel ? 'B' : 'A', count);
41407 QuickHex(t, p, count);
41408 - debugl1(cs, bcs->blog);
41409 + debugl1(cs, "%s", bcs->blog);
41410 }
41411 }
41412
41413 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41414 index bf04d2a..b33f53b 100644
41415 --- a/drivers/isdn/hisax/config.c
41416 +++ b/drivers/isdn/hisax/config.c
41417 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41418 ptr--;
41419 *ptr++ = '\n';
41420 *ptr = 0;
41421 - HiSax_putstatus(cs, NULL, cs->dlog);
41422 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41423 } else
41424 HiSax_putstatus(cs, "LogEcho: ",
41425 "warning Frame too big (%d)",
41426 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41427 index 8d0cf6e..4fc90de 100644
41428 --- a/drivers/isdn/hisax/diva.c
41429 +++ b/drivers/isdn/hisax/diva.c
41430 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41431 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41432 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41433 QuickHex(t, ptr, count);
41434 - debugl1(cs, bcs->blog);
41435 + debugl1(cs, "%s", bcs->blog);
41436 }
41437 }
41438
41439 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41440 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41441 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41442 QuickHex(t, ptr, count);
41443 - debugl1(cs, bcs->blog);
41444 + debugl1(cs, "%s", bcs->blog);
41445 }
41446 }
41447
41448 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41449 index 1df6f9a..2be1c8a 100644
41450 --- a/drivers/isdn/hisax/elsa.c
41451 +++ b/drivers/isdn/hisax/elsa.c
41452 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41453 t = tmp;
41454 t += sprintf(tmp, "Arcofi data");
41455 QuickHex(t, p, cs->dc.isac.mon_rxp);
41456 - debugl1(cs, tmp);
41457 + debugl1(cs, "%s", tmp);
41458 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41459 switch (cs->dc.isac.mon_rx[1]) {
41460 case 0x80:
41461 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41462 index d4c98d3..3f84dd8 100644
41463 --- a/drivers/isdn/hisax/elsa_ser.c
41464 +++ b/drivers/isdn/hisax/elsa_ser.c
41465 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41466
41467 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41468 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41469 - debugl1(cs, tmp);
41470 + debugl1(cs, "%s", tmp);
41471 }
41472 cs->hw.elsa.rcvcnt = 0;
41473 }
41474 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41475 index 3ccd724..497bd02 100644
41476 --- a/drivers/isdn/hisax/hfc_pci.c
41477 +++ b/drivers/isdn/hisax/hfc_pci.c
41478 @@ -901,7 +901,7 @@ Begin:
41479 ptr--;
41480 *ptr++ = '\n';
41481 *ptr = 0;
41482 - HiSax_putstatus(cs, NULL, cs->dlog);
41483 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41484 } else
41485 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41486 }
41487 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41488 index dc4574f..fa1fefd 100644
41489 --- a/drivers/isdn/hisax/hfc_sx.c
41490 +++ b/drivers/isdn/hisax/hfc_sx.c
41491 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41492 ptr--;
41493 *ptr++ = '\n';
41494 *ptr = 0;
41495 - HiSax_putstatus(cs, NULL, cs->dlog);
41496 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41497 } else
41498 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41499 }
41500 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41501 index f398d48..a8d6188 100644
41502 --- a/drivers/isdn/hisax/hscx_irq.c
41503 +++ b/drivers/isdn/hisax/hscx_irq.c
41504 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41505 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41506 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41507 QuickHex(t, ptr, count);
41508 - debugl1(cs, bcs->blog);
41509 + debugl1(cs, "%s", bcs->blog);
41510 }
41511 }
41512
41513 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41514 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41515 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41516 QuickHex(t, ptr, count);
41517 - debugl1(cs, bcs->blog);
41518 + debugl1(cs, "%s", bcs->blog);
41519 }
41520 }
41521
41522 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41523 index db5321f..51dae91 100644
41524 --- a/drivers/isdn/hisax/icc.c
41525 +++ b/drivers/isdn/hisax/icc.c
41526 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41527
41528 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41529 QuickHex(t, ptr, count);
41530 - debugl1(cs, cs->dlog);
41531 + debugl1(cs, "%s", cs->dlog);
41532 }
41533 }
41534
41535 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41536
41537 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41538 QuickHex(t, ptr, count);
41539 - debugl1(cs, cs->dlog);
41540 + debugl1(cs, "%s", cs->dlog);
41541 }
41542 }
41543
41544 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41545 index 74feb5c..5faa5de 100644
41546 --- a/drivers/isdn/hisax/ipacx.c
41547 +++ b/drivers/isdn/hisax/ipacx.c
41548 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41549
41550 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41551 QuickHex(t, ptr, count);
41552 - debugl1(cs, cs->dlog);
41553 + debugl1(cs, "%s", cs->dlog);
41554 }
41555 }
41556
41557 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41558
41559 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41560 QuickHex(t, ptr, count);
41561 - debugl1(cs, cs->dlog);
41562 + debugl1(cs, "%s", cs->dlog);
41563 }
41564 }
41565
41566 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41567
41568 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41569 QuickHex(t, ptr, count);
41570 - debugl1(cs, bcs->blog);
41571 + debugl1(cs, "%s", bcs->blog);
41572 }
41573 }
41574
41575 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41576
41577 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41578 QuickHex(t, ptr, count);
41579 - debugl1(cs, bcs->blog);
41580 + debugl1(cs, "%s", bcs->blog);
41581 }
41582 }
41583
41584 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41585 index a365ccc..7fdf78f 100644
41586 --- a/drivers/isdn/hisax/isac.c
41587 +++ b/drivers/isdn/hisax/isac.c
41588 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41589
41590 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41591 QuickHex(t, ptr, count);
41592 - debugl1(cs, cs->dlog);
41593 + debugl1(cs, "%s", cs->dlog);
41594 }
41595 }
41596
41597 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41598
41599 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41600 QuickHex(t, ptr, count);
41601 - debugl1(cs, cs->dlog);
41602 + debugl1(cs, "%s", cs->dlog);
41603 }
41604 }
41605
41606 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41607 index 7fdf347..f4956c7 100644
41608 --- a/drivers/isdn/hisax/isar.c
41609 +++ b/drivers/isdn/hisax/isar.c
41610 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41611 t = tmp;
41612 t += sprintf(t, "sendmbox cnt %d", len);
41613 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41614 - debugl1(cs, tmp);
41615 + debugl1(cs, "%s", tmp);
41616 i -= 64;
41617 }
41618 }
41619 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41620 t = tmp;
41621 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41622 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41623 - debugl1(cs, tmp);
41624 + debugl1(cs, "%s", tmp);
41625 i -= 64;
41626 }
41627 }
41628 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41629 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41630 ireg->iis, ireg->cmsb);
41631 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41632 - debugl1(cs, debbuf);
41633 + debugl1(cs, "%s", debbuf);
41634 }
41635 break;
41636 case ISAR_IIS_INVMSG:
41637 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41638 index f946c58..e2ae787 100644
41639 --- a/drivers/isdn/hisax/jade.c
41640 +++ b/drivers/isdn/hisax/jade.c
41641 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41642 int jade = bcs->hw.hscx.hscx;
41643
41644 if (cs->debug & L1_DEB_HSCX) {
41645 - char tmp[40];
41646 - sprintf(tmp, "jade %c mode %d ichan %d",
41647 - 'A' + jade, mode, bc);
41648 - debugl1(cs, tmp);
41649 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41650 }
41651 bcs->mode = mode;
41652 bcs->channel = bc;
41653 @@ -257,23 +254,18 @@ void
41654 clear_pending_jade_ints(struct IsdnCardState *cs)
41655 {
41656 int val;
41657 - char tmp[64];
41658
41659 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41660 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41661
41662 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41663 - sprintf(tmp, "jade B ISTA %x", val);
41664 - debugl1(cs, tmp);
41665 + debugl1(cs, "jade B ISTA %x", val);
41666 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41667 - sprintf(tmp, "jade A ISTA %x", val);
41668 - debugl1(cs, tmp);
41669 + debugl1(cs, "jade A ISTA %x", val);
41670 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41671 - sprintf(tmp, "jade B STAR %x", val);
41672 - debugl1(cs, tmp);
41673 + debugl1(cs, "jade B STAR %x", val);
41674 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41675 - sprintf(tmp, "jade A STAR %x", val);
41676 - debugl1(cs, tmp);
41677 + debugl1(cs, "jade A STAR %x", val);
41678 /* Unmask ints */
41679 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41680 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41681 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41682 index f521fc8..b930da9 100644
41683 --- a/drivers/isdn/hisax/jade_irq.c
41684 +++ b/drivers/isdn/hisax/jade_irq.c
41685 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41686 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41687 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41688 QuickHex(t, ptr, count);
41689 - debugl1(cs, bcs->blog);
41690 + debugl1(cs, "%s", bcs->blog);
41691 }
41692 }
41693
41694 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41695 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41696 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41697 QuickHex(t, ptr, count);
41698 - debugl1(cs, bcs->blog);
41699 + debugl1(cs, "%s", bcs->blog);
41700 }
41701 }
41702
41703 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41704 index 4c1bca5..875402e 100644
41705 --- a/drivers/isdn/hisax/l3_1tr6.c
41706 +++ b/drivers/isdn/hisax/l3_1tr6.c
41707 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41708 {
41709 dev_kfree_skb(skb);
41710 if (pc->st->l3.debug & L3_DEB_WARN)
41711 - l3_debug(pc->st, msg);
41712 + l3_debug(pc->st, "%s", msg);
41713 l3_1tr6_release_req(pc, 0, NULL);
41714 }
41715
41716 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41717 {
41718 u_char *p;
41719 int bcfound = 0;
41720 - char tmp[80];
41721 struct sk_buff *skb = arg;
41722
41723 /* Channel Identification */
41724 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41725 /* Signal all services, linklevel takes care of Service-Indicator */
41726 if (bcfound) {
41727 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41728 - sprintf(tmp, "non-digital call: %s -> %s",
41729 + l3_debug(pc->st, "non-digital call: %s -> %s",
41730 pc->para.setup.phone,
41731 pc->para.setup.eazmsn);
41732 - l3_debug(pc->st, tmp);
41733 }
41734 newl3state(pc, 6);
41735 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41736 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41737 {
41738 u_char *p;
41739 int i, tmpcharge = 0;
41740 - char a_charge[8], tmp[32];
41741 + char a_charge[8];
41742 struct sk_buff *skb = arg;
41743
41744 p = skb->data;
41745 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41746 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41747 }
41748 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41749 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41750 - l3_debug(pc->st, tmp);
41751 + l3_debug(pc->st, "charging info %d",
41752 + pc->para.chargeinfo);
41753 }
41754 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41755 l3_debug(pc->st, "charging info not found");
41756 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41757 struct sk_buff *skb = arg;
41758 u_char *p;
41759 int i, tmpcharge = 0;
41760 - char a_charge[8], tmp[32];
41761 + char a_charge[8];
41762
41763 StopAllL3Timer(pc);
41764 p = skb->data;
41765 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41766 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41767 }
41768 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41769 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41770 - l3_debug(pc->st, tmp);
41771 + l3_debug(pc->st, "charging info %d",
41772 + pc->para.chargeinfo);
41773 }
41774 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41775 l3_debug(pc->st, "charging info not found");
41776 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41777 int i, mt, cr;
41778 struct l3_process *proc;
41779 struct sk_buff *skb = arg;
41780 - char tmp[80];
41781
41782 switch (pr) {
41783 case (DL_DATA | INDICATION):
41784 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41785 }
41786 if (skb->len < 4) {
41787 if (st->l3.debug & L3_DEB_PROTERR) {
41788 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41789 - l3_debug(st, tmp);
41790 + l3_debug(st, "up1tr6 len only %d", skb->len);
41791 }
41792 dev_kfree_skb(skb);
41793 return;
41794 }
41795 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41796 if (st->l3.debug & L3_DEB_PROTERR) {
41797 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41798 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41799 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41800 skb->data[0], skb->len);
41801 - l3_debug(st, tmp);
41802 }
41803 dev_kfree_skb(skb);
41804 return;
41805 }
41806 if (skb->data[1] != 1) {
41807 if (st->l3.debug & L3_DEB_PROTERR) {
41808 - sprintf(tmp, "up1tr6 CR len not 1");
41809 - l3_debug(st, tmp);
41810 + l3_debug(st, "up1tr6 CR len not 1");
41811 }
41812 dev_kfree_skb(skb);
41813 return;
41814 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41815 if (skb->data[0] == PROTO_DIS_N0) {
41816 dev_kfree_skb(skb);
41817 if (st->l3.debug & L3_DEB_STATE) {
41818 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41819 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41820 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41821 - l3_debug(st, tmp);
41822 }
41823 } else if (skb->data[0] == PROTO_DIS_N1) {
41824 if (!(proc = getl3proc(st, cr))) {
41825 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41826 if (cr < 128) {
41827 if (!(proc = new_l3_process(st, cr))) {
41828 if (st->l3.debug & L3_DEB_PROTERR) {
41829 - sprintf(tmp, "up1tr6 no roc mem");
41830 - l3_debug(st, tmp);
41831 + l3_debug(st, "up1tr6 no roc mem");
41832 }
41833 dev_kfree_skb(skb);
41834 return;
41835 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41836 } else {
41837 if (!(proc = new_l3_process(st, cr))) {
41838 if (st->l3.debug & L3_DEB_PROTERR) {
41839 - sprintf(tmp, "up1tr6 no roc mem");
41840 - l3_debug(st, tmp);
41841 + l3_debug(st, "up1tr6 no roc mem");
41842 }
41843 dev_kfree_skb(skb);
41844 return;
41845 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41846 if (i == ARRAY_SIZE(datastln1)) {
41847 dev_kfree_skb(skb);
41848 if (st->l3.debug & L3_DEB_STATE) {
41849 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41850 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41851 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41852 proc->state, mt);
41853 - l3_debug(st, tmp);
41854 }
41855 return;
41856 } else {
41857 if (st->l3.debug & L3_DEB_STATE) {
41858 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41859 + l3_debug(st, "up1tr6%sstate %d mt %x",
41860 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41861 proc->state, mt);
41862 - l3_debug(st, tmp);
41863 }
41864 datastln1[i].rout(proc, pr, skb);
41865 }
41866 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41867 int i, cr;
41868 struct l3_process *proc;
41869 struct Channel *chan;
41870 - char tmp[80];
41871
41872 if ((DL_ESTABLISH | REQUEST) == pr) {
41873 l3_msg(st, pr, NULL);
41874 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41875 break;
41876 if (i == ARRAY_SIZE(downstl)) {
41877 if (st->l3.debug & L3_DEB_STATE) {
41878 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41879 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41880 proc->state, pr);
41881 - l3_debug(st, tmp);
41882 }
41883 } else {
41884 if (st->l3.debug & L3_DEB_STATE) {
41885 - sprintf(tmp, "down1tr6 state %d prim %d",
41886 + l3_debug(st, "down1tr6 state %d prim %d",
41887 proc->state, pr);
41888 - l3_debug(st, tmp);
41889 }
41890 downstl[i].rout(proc, pr, arg);
41891 }
41892 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41893 index b646eed..233e432 100644
41894 --- a/drivers/isdn/hisax/netjet.c
41895 +++ b/drivers/isdn/hisax/netjet.c
41896 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41897 else
41898 j = i;
41899 QuickHex(t, p, j);
41900 - debugl1(cs, tmp);
41901 + debugl1(cs, "%s", tmp);
41902 p += j;
41903 i -= j;
41904 t = tmp;
41905 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41906 index 041bf52..af1b020 100644
41907 --- a/drivers/isdn/hisax/q931.c
41908 +++ b/drivers/isdn/hisax/q931.c
41909 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41910 dp--;
41911 *dp++ = '\n';
41912 *dp = 0;
41913 - HiSax_putstatus(cs, NULL, cs->dlog);
41914 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41915 } else
41916 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41917 }
41918 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41919 }
41920 if (finish) {
41921 *dp = 0;
41922 - HiSax_putstatus(cs, NULL, cs->dlog);
41923 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41924 return;
41925 }
41926 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41927 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41928 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41929 }
41930 *dp = 0;
41931 - HiSax_putstatus(cs, NULL, cs->dlog);
41932 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41933 }
41934 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41935 index d8cac69..a858955 100644
41936 --- a/drivers/isdn/hisax/w6692.c
41937 +++ b/drivers/isdn/hisax/w6692.c
41938 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41939
41940 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41941 QuickHex(t, ptr, count);
41942 - debugl1(cs, cs->dlog);
41943 + debugl1(cs, "%s", cs->dlog);
41944 }
41945 }
41946
41947 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41948
41949 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41950 QuickHex(t, ptr, count);
41951 - debugl1(cs, cs->dlog);
41952 + debugl1(cs, "%s", cs->dlog);
41953 }
41954 }
41955
41956 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41957 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41958 bcs->channel + '1', count);
41959 QuickHex(t, ptr, count);
41960 - debugl1(cs, bcs->blog);
41961 + debugl1(cs, "%s", bcs->blog);
41962 }
41963 }
41964
41965 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41966 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41967 bcs->channel + '1', count);
41968 QuickHex(t, ptr, count);
41969 - debugl1(cs, bcs->blog);
41970 + debugl1(cs, "%s", bcs->blog);
41971 }
41972 }
41973
41974 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41975 index 9bb12ba..d4262f7 100644
41976 --- a/drivers/isdn/i4l/isdn_common.c
41977 +++ b/drivers/isdn/i4l/isdn_common.c
41978 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41979 } else
41980 return -EINVAL;
41981 case IIOCDBGVAR:
41982 + if (!capable(CAP_SYS_RAWIO))
41983 + return -EPERM;
41984 if (arg) {
41985 if (copy_to_user(argp, &dev, sizeof(ulong)))
41986 return -EFAULT;
41987 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41988 index 3c5f249..5fac4d0 100644
41989 --- a/drivers/isdn/i4l/isdn_tty.c
41990 +++ b/drivers/isdn/i4l/isdn_tty.c
41991 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41992
41993 #ifdef ISDN_DEBUG_MODEM_OPEN
41994 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41995 - port->count);
41996 + atomic_read(&port->count));
41997 #endif
41998 - port->count++;
41999 + atomic_inc(&port->count);
42000 port->tty = tty;
42001 /*
42002 * Start up serial port
42003 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42004 #endif
42005 return;
42006 }
42007 - if ((tty->count == 1) && (port->count != 1)) {
42008 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
42009 /*
42010 * Uh, oh. tty->count is 1, which means that the tty
42011 * structure will be freed. Info->count should always
42012 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42013 * serial port won't be shutdown.
42014 */
42015 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
42016 - "info->count is %d\n", port->count);
42017 - port->count = 1;
42018 + "info->count is %d\n", atomic_read(&port->count));
42019 + atomic_set(&port->count, 1);
42020 }
42021 - if (--port->count < 0) {
42022 + if (atomic_dec_return(&port->count) < 0) {
42023 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
42024 - info->line, port->count);
42025 - port->count = 0;
42026 + info->line, atomic_read(&port->count));
42027 + atomic_set(&port->count, 0);
42028 }
42029 - if (port->count) {
42030 + if (atomic_read(&port->count)) {
42031 #ifdef ISDN_DEBUG_MODEM_OPEN
42032 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
42033 #endif
42034 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
42035 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
42036 return;
42037 isdn_tty_shutdown(info);
42038 - port->count = 0;
42039 + atomic_set(&port->count, 0);
42040 port->flags &= ~ASYNC_NORMAL_ACTIVE;
42041 port->tty = NULL;
42042 wake_up_interruptible(&port->open_wait);
42043 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
42044 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
42045 modem_info *info = &dev->mdm.info[i];
42046
42047 - if (info->port.count == 0)
42048 + if (atomic_read(&info->port.count) == 0)
42049 continue;
42050 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
42051 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
42052 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
42053 index e74df7c..03a03ba 100644
42054 --- a/drivers/isdn/icn/icn.c
42055 +++ b/drivers/isdn/icn/icn.c
42056 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
42057 if (count > len)
42058 count = len;
42059 if (user) {
42060 - if (copy_from_user(msg, buf, count))
42061 + if (count > sizeof msg || copy_from_user(msg, buf, count))
42062 return -EFAULT;
42063 } else
42064 memcpy(msg, buf, count);
42065 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
42066 index 6a8405d..0bd1c7e 100644
42067 --- a/drivers/leds/leds-clevo-mail.c
42068 +++ b/drivers/leds/leds-clevo-mail.c
42069 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
42070 * detected as working, but in reality it is not) as low as
42071 * possible.
42072 */
42073 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
42074 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
42075 {
42076 .callback = clevo_mail_led_dmi_callback,
42077 .ident = "Clevo D410J",
42078 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
42079 index 64e204e..c6bf189 100644
42080 --- a/drivers/leds/leds-ss4200.c
42081 +++ b/drivers/leds/leds-ss4200.c
42082 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
42083 * detected as working, but in reality it is not) as low as
42084 * possible.
42085 */
42086 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
42087 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
42088 {
42089 .callback = ss4200_led_dmi_callback,
42090 .ident = "Intel SS4200-E",
42091 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
42092 index 0bf1e4e..b4bf44e 100644
42093 --- a/drivers/lguest/core.c
42094 +++ b/drivers/lguest/core.c
42095 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
42096 * The end address needs +1 because __get_vm_area allocates an
42097 * extra guard page, so we need space for that.
42098 */
42099 +
42100 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
42101 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42102 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
42103 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42104 +#else
42105 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42106 VM_ALLOC, switcher_addr, switcher_addr
42107 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42108 +#endif
42109 +
42110 if (!switcher_vma) {
42111 err = -ENOMEM;
42112 printk("lguest: could not map switcher pages high\n");
42113 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42114 * Now the Switcher is mapped at the right address, we can't fail!
42115 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42116 */
42117 - memcpy(switcher_vma->addr, start_switcher_text,
42118 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42119 end_switcher_text - start_switcher_text);
42120
42121 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42122 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42123 index a35d8d1..59fb772 100644
42124 --- a/drivers/lguest/page_tables.c
42125 +++ b/drivers/lguest/page_tables.c
42126 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42127 /*:*/
42128
42129 #ifdef CONFIG_X86_PAE
42130 -static void release_pmd(pmd_t *spmd)
42131 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42132 {
42133 /* If the entry's not present, there's nothing to release. */
42134 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42135 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42136 index 5169239..47cb4db 100644
42137 --- a/drivers/lguest/x86/core.c
42138 +++ b/drivers/lguest/x86/core.c
42139 @@ -59,7 +59,7 @@ static struct {
42140 /* Offset from where switcher.S was compiled to where we've copied it */
42141 static unsigned long switcher_offset(void)
42142 {
42143 - return switcher_addr - (unsigned long)start_switcher_text;
42144 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42145 }
42146
42147 /* This cpu's struct lguest_pages (after the Switcher text page) */
42148 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42149 * These copies are pretty cheap, so we do them unconditionally: */
42150 /* Save the current Host top-level page directory.
42151 */
42152 +
42153 +#ifdef CONFIG_PAX_PER_CPU_PGD
42154 + pages->state.host_cr3 = read_cr3();
42155 +#else
42156 pages->state.host_cr3 = __pa(current->mm->pgd);
42157 +#endif
42158 +
42159 /*
42160 * Set up the Guest's page tables to see this CPU's pages (and no
42161 * other CPU's pages).
42162 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42163 * compiled-in switcher code and the high-mapped copy we just made.
42164 */
42165 for (i = 0; i < IDT_ENTRIES; i++)
42166 - default_idt_entries[i] += switcher_offset();
42167 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42168
42169 /*
42170 * Set up the Switcher's per-cpu areas.
42171 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42172 * it will be undisturbed when we switch. To change %cs and jump we
42173 * need this structure to feed to Intel's "lcall" instruction.
42174 */
42175 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42176 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42177 lguest_entry.segment = LGUEST_CS;
42178
42179 /*
42180 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42181 index 40634b0..4f5855e 100644
42182 --- a/drivers/lguest/x86/switcher_32.S
42183 +++ b/drivers/lguest/x86/switcher_32.S
42184 @@ -87,6 +87,7 @@
42185 #include <asm/page.h>
42186 #include <asm/segment.h>
42187 #include <asm/lguest.h>
42188 +#include <asm/processor-flags.h>
42189
42190 // We mark the start of the code to copy
42191 // It's placed in .text tho it's never run here
42192 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42193 // Changes type when we load it: damn Intel!
42194 // For after we switch over our page tables
42195 // That entry will be read-only: we'd crash.
42196 +
42197 +#ifdef CONFIG_PAX_KERNEXEC
42198 + mov %cr0, %edx
42199 + xor $X86_CR0_WP, %edx
42200 + mov %edx, %cr0
42201 +#endif
42202 +
42203 movl $(GDT_ENTRY_TSS*8), %edx
42204 ltr %dx
42205
42206 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42207 // Let's clear it again for our return.
42208 // The GDT descriptor of the Host
42209 // Points to the table after two "size" bytes
42210 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42211 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42212 // Clear "used" from type field (byte 5, bit 2)
42213 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42214 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42215 +
42216 +#ifdef CONFIG_PAX_KERNEXEC
42217 + mov %cr0, %eax
42218 + xor $X86_CR0_WP, %eax
42219 + mov %eax, %cr0
42220 +#endif
42221
42222 // Once our page table's switched, the Guest is live!
42223 // The Host fades as we run this final step.
42224 @@ -295,13 +309,12 @@ deliver_to_host:
42225 // I consulted gcc, and it gave
42226 // These instructions, which I gladly credit:
42227 leal (%edx,%ebx,8), %eax
42228 - movzwl (%eax),%edx
42229 - movl 4(%eax), %eax
42230 - xorw %ax, %ax
42231 - orl %eax, %edx
42232 + movl 4(%eax), %edx
42233 + movw (%eax), %dx
42234 // Now the address of the handler's in %edx
42235 // We call it now: its "iret" drops us home.
42236 - jmp *%edx
42237 + ljmp $__KERNEL_CS, $1f
42238 +1: jmp *%edx
42239
42240 // Every interrupt can come to us here
42241 // But we must truly tell each apart.
42242 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42243 index 0003992..854bbce 100644
42244 --- a/drivers/md/bcache/closure.h
42245 +++ b/drivers/md/bcache/closure.h
42246 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42247 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42248 struct workqueue_struct *wq)
42249 {
42250 - BUG_ON(object_is_on_stack(cl));
42251 + BUG_ON(object_starts_on_stack(cl));
42252 closure_set_ip(cl);
42253 cl->fn = fn;
42254 cl->wq = wq;
42255 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42256 index 547c4c5..5be1de4 100644
42257 --- a/drivers/md/bcache/super.c
42258 +++ b/drivers/md/bcache/super.c
42259 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42260 err:
42261 closure_sync(&op.cl);
42262 /* XXX: test this, it's broken */
42263 - bch_cache_set_error(c, err);
42264 + bch_cache_set_error(c, "%s", err);
42265 }
42266
42267 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42268 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42269 index a7fd821..9dcf6c3 100644
42270 --- a/drivers/md/bitmap.c
42271 +++ b/drivers/md/bitmap.c
42272 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42273 chunk_kb ? "KB" : "B");
42274 if (bitmap->storage.file) {
42275 seq_printf(seq, ", file: ");
42276 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42277 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42278 }
42279
42280 seq_printf(seq, "\n");
42281 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42282 index f1b7586..a49c4bd 100644
42283 --- a/drivers/md/dm-ioctl.c
42284 +++ b/drivers/md/dm-ioctl.c
42285 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42286 cmd == DM_LIST_VERSIONS_CMD)
42287 return 0;
42288
42289 - if ((cmd == DM_DEV_CREATE_CMD)) {
42290 + if (cmd == DM_DEV_CREATE_CMD) {
42291 if (!*param->name) {
42292 DMWARN("name not supplied when creating device");
42293 return -EINVAL;
42294 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42295 index 699b5be..eac0a15 100644
42296 --- a/drivers/md/dm-raid1.c
42297 +++ b/drivers/md/dm-raid1.c
42298 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42299
42300 struct mirror {
42301 struct mirror_set *ms;
42302 - atomic_t error_count;
42303 + atomic_unchecked_t error_count;
42304 unsigned long error_type;
42305 struct dm_dev *dev;
42306 sector_t offset;
42307 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42308 struct mirror *m;
42309
42310 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42311 - if (!atomic_read(&m->error_count))
42312 + if (!atomic_read_unchecked(&m->error_count))
42313 return m;
42314
42315 return NULL;
42316 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42317 * simple way to tell if a device has encountered
42318 * errors.
42319 */
42320 - atomic_inc(&m->error_count);
42321 + atomic_inc_unchecked(&m->error_count);
42322
42323 if (test_and_set_bit(error_type, &m->error_type))
42324 return;
42325 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42326 struct mirror *m = get_default_mirror(ms);
42327
42328 do {
42329 - if (likely(!atomic_read(&m->error_count)))
42330 + if (likely(!atomic_read_unchecked(&m->error_count)))
42331 return m;
42332
42333 if (m-- == ms->mirror)
42334 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42335 {
42336 struct mirror *default_mirror = get_default_mirror(m->ms);
42337
42338 - return !atomic_read(&default_mirror->error_count);
42339 + return !atomic_read_unchecked(&default_mirror->error_count);
42340 }
42341
42342 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42343 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42344 */
42345 if (likely(region_in_sync(ms, region, 1)))
42346 m = choose_mirror(ms, bio->bi_sector);
42347 - else if (m && atomic_read(&m->error_count))
42348 + else if (m && atomic_read_unchecked(&m->error_count))
42349 m = NULL;
42350
42351 if (likely(m))
42352 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42353 }
42354
42355 ms->mirror[mirror].ms = ms;
42356 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42357 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42358 ms->mirror[mirror].error_type = 0;
42359 ms->mirror[mirror].offset = offset;
42360
42361 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42362 */
42363 static char device_status_char(struct mirror *m)
42364 {
42365 - if (!atomic_read(&(m->error_count)))
42366 + if (!atomic_read_unchecked(&(m->error_count)))
42367 return 'A';
42368
42369 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42370 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42371 index d907ca6..cfb8384 100644
42372 --- a/drivers/md/dm-stripe.c
42373 +++ b/drivers/md/dm-stripe.c
42374 @@ -20,7 +20,7 @@ struct stripe {
42375 struct dm_dev *dev;
42376 sector_t physical_start;
42377
42378 - atomic_t error_count;
42379 + atomic_unchecked_t error_count;
42380 };
42381
42382 struct stripe_c {
42383 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42384 kfree(sc);
42385 return r;
42386 }
42387 - atomic_set(&(sc->stripe[i].error_count), 0);
42388 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42389 }
42390
42391 ti->private = sc;
42392 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42393 DMEMIT("%d ", sc->stripes);
42394 for (i = 0; i < sc->stripes; i++) {
42395 DMEMIT("%s ", sc->stripe[i].dev->name);
42396 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42397 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42398 'D' : 'A';
42399 }
42400 buffer[i] = '\0';
42401 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42402 */
42403 for (i = 0; i < sc->stripes; i++)
42404 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42405 - atomic_inc(&(sc->stripe[i].error_count));
42406 - if (atomic_read(&(sc->stripe[i].error_count)) <
42407 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42408 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42409 DM_IO_ERROR_THRESHOLD)
42410 schedule_work(&sc->trigger_event);
42411 }
42412 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42413 index f221812..aca962b 100644
42414 --- a/drivers/md/dm-table.c
42415 +++ b/drivers/md/dm-table.c
42416 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42417 if (!dev_size)
42418 return 0;
42419
42420 - if ((start >= dev_size) || (start + len > dev_size)) {
42421 + if ((start >= dev_size) || (len > dev_size - start)) {
42422 DMWARN("%s: %s too small for target: "
42423 "start=%llu, len=%llu, dev_size=%llu",
42424 dm_device_name(ti->table->md), bdevname(bdev, b),
42425 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42426 index 60bce43..9b997d0 100644
42427 --- a/drivers/md/dm-thin-metadata.c
42428 +++ b/drivers/md/dm-thin-metadata.c
42429 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42430 {
42431 pmd->info.tm = pmd->tm;
42432 pmd->info.levels = 2;
42433 - pmd->info.value_type.context = pmd->data_sm;
42434 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42435 pmd->info.value_type.size = sizeof(__le64);
42436 pmd->info.value_type.inc = data_block_inc;
42437 pmd->info.value_type.dec = data_block_dec;
42438 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42439
42440 pmd->bl_info.tm = pmd->tm;
42441 pmd->bl_info.levels = 1;
42442 - pmd->bl_info.value_type.context = pmd->data_sm;
42443 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42444 pmd->bl_info.value_type.size = sizeof(__le64);
42445 pmd->bl_info.value_type.inc = data_block_inc;
42446 pmd->bl_info.value_type.dec = data_block_dec;
42447 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42448 index 9e39d2b..fb879a7 100644
42449 --- a/drivers/md/dm.c
42450 +++ b/drivers/md/dm.c
42451 @@ -178,9 +178,9 @@ struct mapped_device {
42452 /*
42453 * Event handling.
42454 */
42455 - atomic_t event_nr;
42456 + atomic_unchecked_t event_nr;
42457 wait_queue_head_t eventq;
42458 - atomic_t uevent_seq;
42459 + atomic_unchecked_t uevent_seq;
42460 struct list_head uevent_list;
42461 spinlock_t uevent_lock; /* Protect access to uevent_list */
42462
42463 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42464 spin_lock_init(&md->deferred_lock);
42465 atomic_set(&md->holders, 1);
42466 atomic_set(&md->open_count, 0);
42467 - atomic_set(&md->event_nr, 0);
42468 - atomic_set(&md->uevent_seq, 0);
42469 + atomic_set_unchecked(&md->event_nr, 0);
42470 + atomic_set_unchecked(&md->uevent_seq, 0);
42471 INIT_LIST_HEAD(&md->uevent_list);
42472 spin_lock_init(&md->uevent_lock);
42473
42474 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42475
42476 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42477
42478 - atomic_inc(&md->event_nr);
42479 + atomic_inc_unchecked(&md->event_nr);
42480 wake_up(&md->eventq);
42481 }
42482
42483 @@ -2716,18 +2716,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42484
42485 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42486 {
42487 - return atomic_add_return(1, &md->uevent_seq);
42488 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42489 }
42490
42491 uint32_t dm_get_event_nr(struct mapped_device *md)
42492 {
42493 - return atomic_read(&md->event_nr);
42494 + return atomic_read_unchecked(&md->event_nr);
42495 }
42496
42497 int dm_wait_event(struct mapped_device *md, int event_nr)
42498 {
42499 return wait_event_interruptible(md->eventq,
42500 - (event_nr != atomic_read(&md->event_nr)));
42501 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42502 }
42503
42504 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42505 diff --git a/drivers/md/md.c b/drivers/md/md.c
42506 index 9f13e13..411a5b8 100644
42507 --- a/drivers/md/md.c
42508 +++ b/drivers/md/md.c
42509 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42510 * start build, activate spare
42511 */
42512 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42513 -static atomic_t md_event_count;
42514 +static atomic_unchecked_t md_event_count;
42515 void md_new_event(struct mddev *mddev)
42516 {
42517 - atomic_inc(&md_event_count);
42518 + atomic_inc_unchecked(&md_event_count);
42519 wake_up(&md_event_waiters);
42520 }
42521 EXPORT_SYMBOL_GPL(md_new_event);
42522 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42523 */
42524 static void md_new_event_inintr(struct mddev *mddev)
42525 {
42526 - atomic_inc(&md_event_count);
42527 + atomic_inc_unchecked(&md_event_count);
42528 wake_up(&md_event_waiters);
42529 }
42530
42531 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42532 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42533 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42534 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42535 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42536 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42537
42538 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42539 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42540 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42541 else
42542 sb->resync_offset = cpu_to_le64(0);
42543
42544 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42545 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42546
42547 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42548 sb->size = cpu_to_le64(mddev->dev_sectors);
42549 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42550 static ssize_t
42551 errors_show(struct md_rdev *rdev, char *page)
42552 {
42553 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42554 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42555 }
42556
42557 static ssize_t
42558 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42559 char *e;
42560 unsigned long n = simple_strtoul(buf, &e, 10);
42561 if (*buf && (*e == 0 || *e == '\n')) {
42562 - atomic_set(&rdev->corrected_errors, n);
42563 + atomic_set_unchecked(&rdev->corrected_errors, n);
42564 return len;
42565 }
42566 return -EINVAL;
42567 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42568 rdev->sb_loaded = 0;
42569 rdev->bb_page = NULL;
42570 atomic_set(&rdev->nr_pending, 0);
42571 - atomic_set(&rdev->read_errors, 0);
42572 - atomic_set(&rdev->corrected_errors, 0);
42573 + atomic_set_unchecked(&rdev->read_errors, 0);
42574 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42575
42576 INIT_LIST_HEAD(&rdev->same_set);
42577 init_waitqueue_head(&rdev->blocked_wait);
42578 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42579
42580 spin_unlock(&pers_lock);
42581 seq_printf(seq, "\n");
42582 - seq->poll_event = atomic_read(&md_event_count);
42583 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42584 return 0;
42585 }
42586 if (v == (void*)2) {
42587 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42588 return error;
42589
42590 seq = file->private_data;
42591 - seq->poll_event = atomic_read(&md_event_count);
42592 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42593 return error;
42594 }
42595
42596 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42597 /* always allow read */
42598 mask = POLLIN | POLLRDNORM;
42599
42600 - if (seq->poll_event != atomic_read(&md_event_count))
42601 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42602 mask |= POLLERR | POLLPRI;
42603 return mask;
42604 }
42605 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42606 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42607 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42608 (int)part_stat_read(&disk->part0, sectors[1]) -
42609 - atomic_read(&disk->sync_io);
42610 + atomic_read_unchecked(&disk->sync_io);
42611 /* sync IO will cause sync_io to increase before the disk_stats
42612 * as sync_io is counted when a request starts, and
42613 * disk_stats is counted when it completes.
42614 diff --git a/drivers/md/md.h b/drivers/md/md.h
42615 index 20f02c0..fd8c821 100644
42616 --- a/drivers/md/md.h
42617 +++ b/drivers/md/md.h
42618 @@ -94,13 +94,13 @@ struct md_rdev {
42619 * only maintained for arrays that
42620 * support hot removal
42621 */
42622 - atomic_t read_errors; /* number of consecutive read errors that
42623 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42624 * we have tried to ignore.
42625 */
42626 struct timespec last_read_error; /* monotonic time since our
42627 * last read error
42628 */
42629 - atomic_t corrected_errors; /* number of corrected read errors,
42630 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42631 * for reporting to userspace and storing
42632 * in superblock.
42633 */
42634 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42635
42636 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42637 {
42638 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42639 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42640 }
42641
42642 struct md_personality
42643 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42644 index 3e6d115..ffecdeb 100644
42645 --- a/drivers/md/persistent-data/dm-space-map.h
42646 +++ b/drivers/md/persistent-data/dm-space-map.h
42647 @@ -71,6 +71,7 @@ struct dm_space_map {
42648 dm_sm_threshold_fn fn,
42649 void *context);
42650 };
42651 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42652
42653 /*----------------------------------------------------------------*/
42654
42655 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42656 index d60412c..8d4c982 100644
42657 --- a/drivers/md/raid1.c
42658 +++ b/drivers/md/raid1.c
42659 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42660 if (r1_sync_page_io(rdev, sect, s,
42661 bio->bi_io_vec[idx].bv_page,
42662 READ) != 0)
42663 - atomic_add(s, &rdev->corrected_errors);
42664 + atomic_add_unchecked(s, &rdev->corrected_errors);
42665 }
42666 sectors -= s;
42667 sect += s;
42668 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42669 test_bit(In_sync, &rdev->flags)) {
42670 if (r1_sync_page_io(rdev, sect, s,
42671 conf->tmppage, READ)) {
42672 - atomic_add(s, &rdev->corrected_errors);
42673 + atomic_add_unchecked(s, &rdev->corrected_errors);
42674 printk(KERN_INFO
42675 "md/raid1:%s: read error corrected "
42676 "(%d sectors at %llu on %s)\n",
42677 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42678 index df7b0a0..a257495 100644
42679 --- a/drivers/md/raid10.c
42680 +++ b/drivers/md/raid10.c
42681 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42682 /* The write handler will notice the lack of
42683 * R10BIO_Uptodate and record any errors etc
42684 */
42685 - atomic_add(r10_bio->sectors,
42686 + atomic_add_unchecked(r10_bio->sectors,
42687 &conf->mirrors[d].rdev->corrected_errors);
42688
42689 /* for reconstruct, we always reschedule after a read.
42690 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42691 {
42692 struct timespec cur_time_mon;
42693 unsigned long hours_since_last;
42694 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42695 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42696
42697 ktime_get_ts(&cur_time_mon);
42698
42699 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42700 * overflowing the shift of read_errors by hours_since_last.
42701 */
42702 if (hours_since_last >= 8 * sizeof(read_errors))
42703 - atomic_set(&rdev->read_errors, 0);
42704 + atomic_set_unchecked(&rdev->read_errors, 0);
42705 else
42706 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42707 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42708 }
42709
42710 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42711 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42712 return;
42713
42714 check_decay_read_errors(mddev, rdev);
42715 - atomic_inc(&rdev->read_errors);
42716 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42717 + atomic_inc_unchecked(&rdev->read_errors);
42718 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42719 char b[BDEVNAME_SIZE];
42720 bdevname(rdev->bdev, b);
42721
42722 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42723 "md/raid10:%s: %s: Raid device exceeded "
42724 "read_error threshold [cur %d:max %d]\n",
42725 mdname(mddev), b,
42726 - atomic_read(&rdev->read_errors), max_read_errors);
42727 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42728 printk(KERN_NOTICE
42729 "md/raid10:%s: %s: Failing raid device\n",
42730 mdname(mddev), b);
42731 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42732 sect +
42733 choose_data_offset(r10_bio, rdev)),
42734 bdevname(rdev->bdev, b));
42735 - atomic_add(s, &rdev->corrected_errors);
42736 + atomic_add_unchecked(s, &rdev->corrected_errors);
42737 }
42738
42739 rdev_dec_pending(rdev, mddev);
42740 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42741 index 78ea443..7d57513 100644
42742 --- a/drivers/md/raid5.c
42743 +++ b/drivers/md/raid5.c
42744 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42745 mdname(conf->mddev), STRIPE_SECTORS,
42746 (unsigned long long)s,
42747 bdevname(rdev->bdev, b));
42748 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42749 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42750 clear_bit(R5_ReadError, &sh->dev[i].flags);
42751 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42752 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42753 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42754
42755 - if (atomic_read(&rdev->read_errors))
42756 - atomic_set(&rdev->read_errors, 0);
42757 + if (atomic_read_unchecked(&rdev->read_errors))
42758 + atomic_set_unchecked(&rdev->read_errors, 0);
42759 } else {
42760 const char *bdn = bdevname(rdev->bdev, b);
42761 int retry = 0;
42762 int set_bad = 0;
42763
42764 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42765 - atomic_inc(&rdev->read_errors);
42766 + atomic_inc_unchecked(&rdev->read_errors);
42767 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42768 printk_ratelimited(
42769 KERN_WARNING
42770 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42771 mdname(conf->mddev),
42772 (unsigned long long)s,
42773 bdn);
42774 - } else if (atomic_read(&rdev->read_errors)
42775 + } else if (atomic_read_unchecked(&rdev->read_errors)
42776 > conf->max_nr_stripes)
42777 printk(KERN_WARNING
42778 "md/raid:%s: Too many read errors, failing device %s.\n",
42779 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42780 index 401ef64..836e563 100644
42781 --- a/drivers/media/dvb-core/dvbdev.c
42782 +++ b/drivers/media/dvb-core/dvbdev.c
42783 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42784 const struct dvb_device *template, void *priv, int type)
42785 {
42786 struct dvb_device *dvbdev;
42787 - struct file_operations *dvbdevfops;
42788 + file_operations_no_const *dvbdevfops;
42789 struct device *clsdev;
42790 int minor;
42791 int id;
42792 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42793 index 9b6c3bb..baeb5c7 100644
42794 --- a/drivers/media/dvb-frontends/dib3000.h
42795 +++ b/drivers/media/dvb-frontends/dib3000.h
42796 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42797 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42798 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42799 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42800 -};
42801 +} __no_const;
42802
42803 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42804 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42805 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42806 index ecf21d9..b992428d 100644
42807 --- a/drivers/media/pci/cx88/cx88-video.c
42808 +++ b/drivers/media/pci/cx88/cx88-video.c
42809 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42810
42811 /* ------------------------------------------------------------------ */
42812
42813 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42814 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42815 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42816 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42817 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42818 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42819
42820 module_param_array(video_nr, int, NULL, 0444);
42821 module_param_array(vbi_nr, int, NULL, 0444);
42822 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42823 index c08ae3e..eb59af1 100644
42824 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42825 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42826 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42827 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42828
42829 /* ivtv instance counter */
42830 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42831 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42832
42833 /* Parameter declarations */
42834 static int cardtype[IVTV_MAX_CARDS];
42835 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42836 index dfd0a21..6bbb465 100644
42837 --- a/drivers/media/platform/omap/omap_vout.c
42838 +++ b/drivers/media/platform/omap/omap_vout.c
42839 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42840 OMAP_VIDEO2,
42841 };
42842
42843 -static struct videobuf_queue_ops video_vbq_ops;
42844 /* Variables configurable through module params*/
42845 static u32 video1_numbuffers = 3;
42846 static u32 video2_numbuffers = 3;
42847 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42848 {
42849 struct videobuf_queue *q;
42850 struct omap_vout_device *vout = NULL;
42851 + static struct videobuf_queue_ops video_vbq_ops = {
42852 + .buf_setup = omap_vout_buffer_setup,
42853 + .buf_prepare = omap_vout_buffer_prepare,
42854 + .buf_release = omap_vout_buffer_release,
42855 + .buf_queue = omap_vout_buffer_queue,
42856 + };
42857
42858 vout = video_drvdata(file);
42859 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42860 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42861 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42862
42863 q = &vout->vbq;
42864 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42865 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42866 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42867 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42868 spin_lock_init(&vout->vbq_lock);
42869
42870 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42871 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42872 index 04e6490..2df65bf 100644
42873 --- a/drivers/media/platform/s5p-tv/mixer.h
42874 +++ b/drivers/media/platform/s5p-tv/mixer.h
42875 @@ -156,7 +156,7 @@ struct mxr_layer {
42876 /** layer index (unique identifier) */
42877 int idx;
42878 /** callbacks for layer methods */
42879 - struct mxr_layer_ops ops;
42880 + struct mxr_layer_ops *ops;
42881 /** format array */
42882 const struct mxr_format **fmt_array;
42883 /** size of format array */
42884 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42885 index b93a21f..2535195 100644
42886 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42887 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42888 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42889 {
42890 struct mxr_layer *layer;
42891 int ret;
42892 - struct mxr_layer_ops ops = {
42893 + static struct mxr_layer_ops ops = {
42894 .release = mxr_graph_layer_release,
42895 .buffer_set = mxr_graph_buffer_set,
42896 .stream_set = mxr_graph_stream_set,
42897 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42898 index b713403..53cb5ad 100644
42899 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42900 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42901 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42902 layer->update_buf = next;
42903 }
42904
42905 - layer->ops.buffer_set(layer, layer->update_buf);
42906 + layer->ops->buffer_set(layer, layer->update_buf);
42907
42908 if (done && done != layer->shadow_buf)
42909 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42910 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42911 index 641b1f0..49cff30 100644
42912 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42913 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42914 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42915 layer->geo.src.height = layer->geo.src.full_height;
42916
42917 mxr_geometry_dump(mdev, &layer->geo);
42918 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42919 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42920 mxr_geometry_dump(mdev, &layer->geo);
42921 }
42922
42923 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42924 layer->geo.dst.full_width = mbus_fmt.width;
42925 layer->geo.dst.full_height = mbus_fmt.height;
42926 layer->geo.dst.field = mbus_fmt.field;
42927 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42928 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42929
42930 mxr_geometry_dump(mdev, &layer->geo);
42931 }
42932 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42933 /* set source size to highest accepted value */
42934 geo->src.full_width = max(geo->dst.full_width, pix->width);
42935 geo->src.full_height = max(geo->dst.full_height, pix->height);
42936 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42937 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42938 mxr_geometry_dump(mdev, &layer->geo);
42939 /* set cropping to total visible screen */
42940 geo->src.width = pix->width;
42941 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42942 geo->src.x_offset = 0;
42943 geo->src.y_offset = 0;
42944 /* assure consistency of geometry */
42945 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42946 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42947 mxr_geometry_dump(mdev, &layer->geo);
42948 /* set full size to lowest possible value */
42949 geo->src.full_width = 0;
42950 geo->src.full_height = 0;
42951 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42952 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42953 mxr_geometry_dump(mdev, &layer->geo);
42954
42955 /* returning results */
42956 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42957 target->width = s->r.width;
42958 target->height = s->r.height;
42959
42960 - layer->ops.fix_geometry(layer, stage, s->flags);
42961 + layer->ops->fix_geometry(layer, stage, s->flags);
42962
42963 /* retrieve update selection rectangle */
42964 res.left = target->x_offset;
42965 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42966 mxr_output_get(mdev);
42967
42968 mxr_layer_update_output(layer);
42969 - layer->ops.format_set(layer);
42970 + layer->ops->format_set(layer);
42971 /* enabling layer in hardware */
42972 spin_lock_irqsave(&layer->enq_slock, flags);
42973 layer->state = MXR_LAYER_STREAMING;
42974 spin_unlock_irqrestore(&layer->enq_slock, flags);
42975
42976 - layer->ops.stream_set(layer, MXR_ENABLE);
42977 + layer->ops->stream_set(layer, MXR_ENABLE);
42978 mxr_streamer_get(mdev);
42979
42980 return 0;
42981 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42982 spin_unlock_irqrestore(&layer->enq_slock, flags);
42983
42984 /* disabling layer in hardware */
42985 - layer->ops.stream_set(layer, MXR_DISABLE);
42986 + layer->ops->stream_set(layer, MXR_DISABLE);
42987 /* remove one streamer */
42988 mxr_streamer_put(mdev);
42989 /* allow changes in output configuration */
42990 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42991
42992 void mxr_layer_release(struct mxr_layer *layer)
42993 {
42994 - if (layer->ops.release)
42995 - layer->ops.release(layer);
42996 + if (layer->ops->release)
42997 + layer->ops->release(layer);
42998 }
42999
43000 void mxr_base_layer_release(struct mxr_layer *layer)
43001 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
43002
43003 layer->mdev = mdev;
43004 layer->idx = idx;
43005 - layer->ops = *ops;
43006 + layer->ops = ops;
43007
43008 spin_lock_init(&layer->enq_slock);
43009 INIT_LIST_HEAD(&layer->enq_list);
43010 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43011 index 3d13a63..da31bf1 100644
43012 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43013 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43014 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
43015 {
43016 struct mxr_layer *layer;
43017 int ret;
43018 - struct mxr_layer_ops ops = {
43019 + static struct mxr_layer_ops ops = {
43020 .release = mxr_vp_layer_release,
43021 .buffer_set = mxr_vp_buffer_set,
43022 .stream_set = mxr_vp_stream_set,
43023 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
43024 index 545c04c..a14bded 100644
43025 --- a/drivers/media/radio/radio-cadet.c
43026 +++ b/drivers/media/radio/radio-cadet.c
43027 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43028 unsigned char readbuf[RDS_BUFFER];
43029 int i = 0;
43030
43031 + if (count > RDS_BUFFER)
43032 + return -EFAULT;
43033 mutex_lock(&dev->lock);
43034 if (dev->rdsstat == 0)
43035 cadet_start_rds(dev);
43036 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43037 while (i < count && dev->rdsin != dev->rdsout)
43038 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
43039
43040 - if (i && copy_to_user(data, readbuf, i))
43041 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
43042 i = -EFAULT;
43043 unlock:
43044 mutex_unlock(&dev->lock);
43045 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
43046 index bd4d3a7..ffc0b9d 100644
43047 --- a/drivers/media/radio/radio-maxiradio.c
43048 +++ b/drivers/media/radio/radio-maxiradio.c
43049 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
43050 /* TEA5757 pin mappings */
43051 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
43052
43053 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
43054 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
43055
43056 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
43057 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
43058 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
43059 index 8fa18ab..caee70f 100644
43060 --- a/drivers/media/radio/radio-shark.c
43061 +++ b/drivers/media/radio/radio-shark.c
43062 @@ -79,7 +79,7 @@ struct shark_device {
43063 u32 last_val;
43064 };
43065
43066 -static atomic_t shark_instance = ATOMIC_INIT(0);
43067 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43068
43069 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43070 {
43071 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43072 index 9fb6697..f167415 100644
43073 --- a/drivers/media/radio/radio-shark2.c
43074 +++ b/drivers/media/radio/radio-shark2.c
43075 @@ -74,7 +74,7 @@ struct shark_device {
43076 u8 *transfer_buffer;
43077 };
43078
43079 -static atomic_t shark_instance = ATOMIC_INIT(0);
43080 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43081
43082 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43083 {
43084 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43085 index 9c9084c..a9e8dfb 100644
43086 --- a/drivers/media/radio/radio-si476x.c
43087 +++ b/drivers/media/radio/radio-si476x.c
43088 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43089 struct si476x_radio *radio;
43090 struct v4l2_ctrl *ctrl;
43091
43092 - static atomic_t instance = ATOMIC_INIT(0);
43093 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43094
43095 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43096 if (!radio)
43097 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43098 index 1cf382a..c22998c 100644
43099 --- a/drivers/media/rc/rc-main.c
43100 +++ b/drivers/media/rc/rc-main.c
43101 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43102 int rc_register_device(struct rc_dev *dev)
43103 {
43104 static bool raw_init = false; /* raw decoders loaded? */
43105 - static atomic_t devno = ATOMIC_INIT(0);
43106 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43107 struct rc_map *rc_map;
43108 const char *path;
43109 int rc;
43110 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
43111 */
43112 mutex_lock(&dev->lock);
43113
43114 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43115 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43116 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43117 dev_set_drvdata(&dev->dev, dev);
43118 rc = device_add(&dev->dev);
43119 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43120 index 3940bb0..fb3952a 100644
43121 --- a/drivers/media/usb/dvb-usb/cxusb.c
43122 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43123 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43124
43125 struct dib0700_adapter_state {
43126 int (*set_param_save) (struct dvb_frontend *);
43127 -};
43128 +} __no_const;
43129
43130 static int dib7070_set_param_override(struct dvb_frontend *fe)
43131 {
43132 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43133 index 6e237b6..dc25556 100644
43134 --- a/drivers/media/usb/dvb-usb/dw2102.c
43135 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43136 @@ -118,7 +118,7 @@ struct su3000_state {
43137
43138 struct s6x0_state {
43139 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43140 -};
43141 +} __no_const;
43142
43143 /* debug */
43144 static int dvb_usb_dw2102_debug;
43145 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43146 index 8f7a6a4..59502dd 100644
43147 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43148 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43149 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43150 __u32 reserved;
43151 };
43152
43153 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43154 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43155 enum v4l2_memory memory)
43156 {
43157 void __user *up_pln;
43158 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43159 return 0;
43160 }
43161
43162 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43163 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43164 enum v4l2_memory memory)
43165 {
43166 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43167 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43168 put_user(kp->start_block, &up->start_block) ||
43169 put_user(kp->blocks, &up->blocks) ||
43170 put_user(tmp, &up->edid) ||
43171 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43172 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43173 return -EFAULT;
43174 return 0;
43175 }
43176 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43177 index 02d1b63..5fd6b16 100644
43178 --- a/drivers/media/v4l2-core/v4l2-device.c
43179 +++ b/drivers/media/v4l2-core/v4l2-device.c
43180 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43181 EXPORT_SYMBOL_GPL(v4l2_device_put);
43182
43183 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43184 - atomic_t *instance)
43185 + atomic_unchecked_t *instance)
43186 {
43187 - int num = atomic_inc_return(instance) - 1;
43188 + int num = atomic_inc_return_unchecked(instance) - 1;
43189 int len = strlen(basename);
43190
43191 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43192 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43193 index 68e6b5e..d8b923e 100644
43194 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43195 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43196 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43197 struct file *file, void *fh, void *p);
43198 } u;
43199 void (*debug)(const void *arg, bool write_only);
43200 -};
43201 +} __do_const;
43202 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43203
43204 /* This control needs a priority check */
43205 #define INFO_FL_PRIO (1 << 0)
43206 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43207 struct video_device *vfd = video_devdata(file);
43208 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43209 bool write_only = false;
43210 - struct v4l2_ioctl_info default_info;
43211 + v4l2_ioctl_info_no_const default_info;
43212 const struct v4l2_ioctl_info *info;
43213 void *fh = file->private_data;
43214 struct v4l2_fh *vfh = NULL;
43215 @@ -2194,7 +2195,7 @@ done:
43216 }
43217
43218 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43219 - void * __user *user_ptr, void ***kernel_ptr)
43220 + void __user **user_ptr, void ***kernel_ptr)
43221 {
43222 int ret = 0;
43223
43224 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43225 ret = -EINVAL;
43226 break;
43227 }
43228 - *user_ptr = (void __user *)buf->m.planes;
43229 + *user_ptr = (void __force_user *)buf->m.planes;
43230 *kernel_ptr = (void *)&buf->m.planes;
43231 *array_size = sizeof(struct v4l2_plane) * buf->length;
43232 ret = 1;
43233 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43234 ret = -EINVAL;
43235 break;
43236 }
43237 - *user_ptr = (void __user *)ctrls->controls;
43238 + *user_ptr = (void __force_user *)ctrls->controls;
43239 *kernel_ptr = (void *)&ctrls->controls;
43240 *array_size = sizeof(struct v4l2_ext_control)
43241 * ctrls->count;
43242 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43243 index 767ff4d..c69d259 100644
43244 --- a/drivers/message/fusion/mptbase.c
43245 +++ b/drivers/message/fusion/mptbase.c
43246 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43247 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43248 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43249
43250 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43251 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43252 +#else
43253 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43254 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43255 +#endif
43256 +
43257 /*
43258 * Rounding UP to nearest 4-kB boundary here...
43259 */
43260 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43261 ioc->facts.GlobalCredits);
43262
43263 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43264 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43265 + NULL, NULL);
43266 +#else
43267 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43268 +#endif
43269 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43270 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43271 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43272 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43273 index dd239bd..689c4f7 100644
43274 --- a/drivers/message/fusion/mptsas.c
43275 +++ b/drivers/message/fusion/mptsas.c
43276 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43277 return 0;
43278 }
43279
43280 +static inline void
43281 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43282 +{
43283 + if (phy_info->port_details) {
43284 + phy_info->port_details->rphy = rphy;
43285 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43286 + ioc->name, rphy));
43287 + }
43288 +
43289 + if (rphy) {
43290 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43291 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43292 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43293 + ioc->name, rphy, rphy->dev.release));
43294 + }
43295 +}
43296 +
43297 /* no mutex */
43298 static void
43299 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43300 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43301 return NULL;
43302 }
43303
43304 -static inline void
43305 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43306 -{
43307 - if (phy_info->port_details) {
43308 - phy_info->port_details->rphy = rphy;
43309 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43310 - ioc->name, rphy));
43311 - }
43312 -
43313 - if (rphy) {
43314 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43315 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43316 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43317 - ioc->name, rphy, rphy->dev.release));
43318 - }
43319 -}
43320 -
43321 static inline struct sas_port *
43322 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43323 {
43324 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43325 index 727819c..ad74694 100644
43326 --- a/drivers/message/fusion/mptscsih.c
43327 +++ b/drivers/message/fusion/mptscsih.c
43328 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43329
43330 h = shost_priv(SChost);
43331
43332 - if (h) {
43333 - if (h->info_kbuf == NULL)
43334 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43335 - return h->info_kbuf;
43336 - h->info_kbuf[0] = '\0';
43337 + if (!h)
43338 + return NULL;
43339
43340 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43341 - h->info_kbuf[size-1] = '\0';
43342 - }
43343 + if (h->info_kbuf == NULL)
43344 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43345 + return h->info_kbuf;
43346 + h->info_kbuf[0] = '\0';
43347 +
43348 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43349 + h->info_kbuf[size-1] = '\0';
43350
43351 return h->info_kbuf;
43352 }
43353 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43354 index b7d87cd..9890039 100644
43355 --- a/drivers/message/i2o/i2o_proc.c
43356 +++ b/drivers/message/i2o/i2o_proc.c
43357 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43358 "Array Controller Device"
43359 };
43360
43361 -static char *chtostr(char *tmp, u8 *chars, int n)
43362 -{
43363 - tmp[0] = 0;
43364 - return strncat(tmp, (char *)chars, n);
43365 -}
43366 -
43367 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43368 char *group)
43369 {
43370 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43371 } *result;
43372
43373 i2o_exec_execute_ddm_table ddm_table;
43374 - char tmp[28 + 1];
43375
43376 result = kmalloc(sizeof(*result), GFP_KERNEL);
43377 if (!result)
43378 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43379
43380 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43381 seq_printf(seq, "%-#8x", ddm_table.module_id);
43382 - seq_printf(seq, "%-29s",
43383 - chtostr(tmp, ddm_table.module_name_version, 28));
43384 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43385 seq_printf(seq, "%9d ", ddm_table.data_size);
43386 seq_printf(seq, "%8d", ddm_table.code_size);
43387
43388 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43389
43390 i2o_driver_result_table *result;
43391 i2o_driver_store_table *dst;
43392 - char tmp[28 + 1];
43393
43394 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43395 if (result == NULL)
43396 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43397
43398 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43399 seq_printf(seq, "%-#8x", dst->module_id);
43400 - seq_printf(seq, "%-29s",
43401 - chtostr(tmp, dst->module_name_version, 28));
43402 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43403 + seq_printf(seq, "%-.28s", dst->module_name_version);
43404 + seq_printf(seq, "%-.8s", dst->date);
43405 seq_printf(seq, "%8d ", dst->module_size);
43406 seq_printf(seq, "%8d ", dst->mpb_size);
43407 seq_printf(seq, "0x%04x", dst->module_flags);
43408 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43409 // == (allow) 512d bytes (max)
43410 static u16 *work16 = (u16 *) work32;
43411 int token;
43412 - char tmp[16 + 1];
43413
43414 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43415
43416 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43417 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43418 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43419 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43420 - seq_printf(seq, "Vendor info : %s\n",
43421 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43422 - seq_printf(seq, "Product info : %s\n",
43423 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43424 - seq_printf(seq, "Description : %s\n",
43425 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43426 - seq_printf(seq, "Product rev. : %s\n",
43427 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43428 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43429 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43430 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43431 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43432
43433 seq_printf(seq, "Serial number : ");
43434 print_serial_number(seq, (u8 *) (work32 + 16),
43435 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43436 u8 pad[256]; // allow up to 256 byte (max) serial number
43437 } result;
43438
43439 - char tmp[24 + 1];
43440 -
43441 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43442
43443 if (token < 0) {
43444 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43445 }
43446
43447 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43448 - seq_printf(seq, "Module name : %s\n",
43449 - chtostr(tmp, result.module_name, 24));
43450 - seq_printf(seq, "Module revision : %s\n",
43451 - chtostr(tmp, result.module_rev, 8));
43452 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43453 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43454
43455 seq_printf(seq, "Serial number : ");
43456 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43457 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43458 u8 instance_number[4];
43459 } result;
43460
43461 - char tmp[64 + 1];
43462 -
43463 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43464
43465 if (token < 0) {
43466 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43467 return 0;
43468 }
43469
43470 - seq_printf(seq, "Device name : %s\n",
43471 - chtostr(tmp, result.device_name, 64));
43472 - seq_printf(seq, "Service name : %s\n",
43473 - chtostr(tmp, result.service_name, 64));
43474 - seq_printf(seq, "Physical name : %s\n",
43475 - chtostr(tmp, result.physical_location, 64));
43476 - seq_printf(seq, "Instance number : %s\n",
43477 - chtostr(tmp, result.instance_number, 4));
43478 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43479 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43480 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43481 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43482
43483 return 0;
43484 }
43485 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43486 index a8c08f3..155fe3d 100644
43487 --- a/drivers/message/i2o/iop.c
43488 +++ b/drivers/message/i2o/iop.c
43489 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43490
43491 spin_lock_irqsave(&c->context_list_lock, flags);
43492
43493 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43494 - atomic_inc(&c->context_list_counter);
43495 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43496 + atomic_inc_unchecked(&c->context_list_counter);
43497
43498 - entry->context = atomic_read(&c->context_list_counter);
43499 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43500
43501 list_add(&entry->list, &c->context_list);
43502
43503 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43504
43505 #if BITS_PER_LONG == 64
43506 spin_lock_init(&c->context_list_lock);
43507 - atomic_set(&c->context_list_counter, 0);
43508 + atomic_set_unchecked(&c->context_list_counter, 0);
43509 INIT_LIST_HEAD(&c->context_list);
43510 #endif
43511
43512 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43513 index fcbb2e9..2635e11 100644
43514 --- a/drivers/mfd/janz-cmodio.c
43515 +++ b/drivers/mfd/janz-cmodio.c
43516 @@ -13,6 +13,7 @@
43517
43518 #include <linux/kernel.h>
43519 #include <linux/module.h>
43520 +#include <linux/slab.h>
43521 #include <linux/init.h>
43522 #include <linux/pci.h>
43523 #include <linux/interrupt.h>
43524 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43525 index 9aa6d1e..1631bfc 100644
43526 --- a/drivers/mfd/twl4030-irq.c
43527 +++ b/drivers/mfd/twl4030-irq.c
43528 @@ -35,6 +35,7 @@
43529 #include <linux/of.h>
43530 #include <linux/irqdomain.h>
43531 #include <linux/i2c/twl.h>
43532 +#include <asm/pgtable.h>
43533
43534 #include "twl-core.h"
43535
43536 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43537 * Install an irq handler for each of the SIH modules;
43538 * clone dummy irq_chip since PIH can't *do* anything
43539 */
43540 - twl4030_irq_chip = dummy_irq_chip;
43541 - twl4030_irq_chip.name = "twl4030";
43542 + pax_open_kernel();
43543 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43544 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43545
43546 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43547 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43548 + pax_close_kernel();
43549
43550 for (i = irq_base; i < irq_end; i++) {
43551 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43552 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43553 index 277a8db..0e0b754 100644
43554 --- a/drivers/mfd/twl6030-irq.c
43555 +++ b/drivers/mfd/twl6030-irq.c
43556 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43557 * install an irq handler for each of the modules;
43558 * clone dummy irq_chip since PIH can't *do* anything
43559 */
43560 - twl6030_irq_chip = dummy_irq_chip;
43561 - twl6030_irq_chip.name = "twl6030";
43562 - twl6030_irq_chip.irq_set_type = NULL;
43563 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43564 + pax_open_kernel();
43565 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43566 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43567 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43568 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43569 + pax_close_kernel();
43570
43571 for (i = irq_base; i < irq_end; i++) {
43572 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43573 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43574 index f32550a..e3e52a2 100644
43575 --- a/drivers/misc/c2port/core.c
43576 +++ b/drivers/misc/c2port/core.c
43577 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43578 mutex_init(&c2dev->mutex);
43579
43580 /* Create binary file */
43581 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43582 + pax_open_kernel();
43583 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43584 + pax_close_kernel();
43585 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43586 if (unlikely(ret))
43587 goto error_device_create_bin_file;
43588 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43589 index 36f5d52..32311c3 100644
43590 --- a/drivers/misc/kgdbts.c
43591 +++ b/drivers/misc/kgdbts.c
43592 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43593 char before[BREAK_INSTR_SIZE];
43594 char after[BREAK_INSTR_SIZE];
43595
43596 - probe_kernel_read(before, (char *)kgdbts_break_test,
43597 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43598 BREAK_INSTR_SIZE);
43599 init_simple_test();
43600 ts.tst = plant_and_detach_test;
43601 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43602 /* Activate test with initial breakpoint */
43603 if (!is_early)
43604 kgdb_breakpoint();
43605 - probe_kernel_read(after, (char *)kgdbts_break_test,
43606 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43607 BREAK_INSTR_SIZE);
43608 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43609 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43610 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43611 index 036effe..b3a6336 100644
43612 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43613 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43614 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43615 * the lid is closed. This leads to interrupts as soon as a little move
43616 * is done.
43617 */
43618 - atomic_inc(&lis3->count);
43619 + atomic_inc_unchecked(&lis3->count);
43620
43621 wake_up_interruptible(&lis3->misc_wait);
43622 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43623 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43624 if (lis3->pm_dev)
43625 pm_runtime_get_sync(lis3->pm_dev);
43626
43627 - atomic_set(&lis3->count, 0);
43628 + atomic_set_unchecked(&lis3->count, 0);
43629 return 0;
43630 }
43631
43632 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43633 add_wait_queue(&lis3->misc_wait, &wait);
43634 while (true) {
43635 set_current_state(TASK_INTERRUPTIBLE);
43636 - data = atomic_xchg(&lis3->count, 0);
43637 + data = atomic_xchg_unchecked(&lis3->count, 0);
43638 if (data)
43639 break;
43640
43641 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43642 struct lis3lv02d, miscdev);
43643
43644 poll_wait(file, &lis3->misc_wait, wait);
43645 - if (atomic_read(&lis3->count))
43646 + if (atomic_read_unchecked(&lis3->count))
43647 return POLLIN | POLLRDNORM;
43648 return 0;
43649 }
43650 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43651 index c439c82..1f20f57 100644
43652 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43653 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43654 @@ -297,7 +297,7 @@ struct lis3lv02d {
43655 struct input_polled_dev *idev; /* input device */
43656 struct platform_device *pdev; /* platform device */
43657 struct regulator_bulk_data regulators[2];
43658 - atomic_t count; /* interrupt count after last read */
43659 + atomic_unchecked_t count; /* interrupt count after last read */
43660 union axis_conversion ac; /* hw -> logical axis */
43661 int mapped_btns[3];
43662
43663 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43664 index 2f30bad..c4c13d0 100644
43665 --- a/drivers/misc/sgi-gru/gruhandles.c
43666 +++ b/drivers/misc/sgi-gru/gruhandles.c
43667 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43668 unsigned long nsec;
43669
43670 nsec = CLKS2NSEC(clks);
43671 - atomic_long_inc(&mcs_op_statistics[op].count);
43672 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43673 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43674 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43675 if (mcs_op_statistics[op].max < nsec)
43676 mcs_op_statistics[op].max = nsec;
43677 }
43678 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43679 index 4f76359..cdfcb2e 100644
43680 --- a/drivers/misc/sgi-gru/gruprocfs.c
43681 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43682 @@ -32,9 +32,9 @@
43683
43684 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43685
43686 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43687 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43688 {
43689 - unsigned long val = atomic_long_read(v);
43690 + unsigned long val = atomic_long_read_unchecked(v);
43691
43692 seq_printf(s, "%16lu %s\n", val, id);
43693 }
43694 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43695
43696 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43697 for (op = 0; op < mcsop_last; op++) {
43698 - count = atomic_long_read(&mcs_op_statistics[op].count);
43699 - total = atomic_long_read(&mcs_op_statistics[op].total);
43700 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43701 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43702 max = mcs_op_statistics[op].max;
43703 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43704 count ? total / count : 0, max);
43705 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43706 index 5c3ce24..4915ccb 100644
43707 --- a/drivers/misc/sgi-gru/grutables.h
43708 +++ b/drivers/misc/sgi-gru/grutables.h
43709 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43710 * GRU statistics.
43711 */
43712 struct gru_stats_s {
43713 - atomic_long_t vdata_alloc;
43714 - atomic_long_t vdata_free;
43715 - atomic_long_t gts_alloc;
43716 - atomic_long_t gts_free;
43717 - atomic_long_t gms_alloc;
43718 - atomic_long_t gms_free;
43719 - atomic_long_t gts_double_allocate;
43720 - atomic_long_t assign_context;
43721 - atomic_long_t assign_context_failed;
43722 - atomic_long_t free_context;
43723 - atomic_long_t load_user_context;
43724 - atomic_long_t load_kernel_context;
43725 - atomic_long_t lock_kernel_context;
43726 - atomic_long_t unlock_kernel_context;
43727 - atomic_long_t steal_user_context;
43728 - atomic_long_t steal_kernel_context;
43729 - atomic_long_t steal_context_failed;
43730 - atomic_long_t nopfn;
43731 - atomic_long_t asid_new;
43732 - atomic_long_t asid_next;
43733 - atomic_long_t asid_wrap;
43734 - atomic_long_t asid_reuse;
43735 - atomic_long_t intr;
43736 - atomic_long_t intr_cbr;
43737 - atomic_long_t intr_tfh;
43738 - atomic_long_t intr_spurious;
43739 - atomic_long_t intr_mm_lock_failed;
43740 - atomic_long_t call_os;
43741 - atomic_long_t call_os_wait_queue;
43742 - atomic_long_t user_flush_tlb;
43743 - atomic_long_t user_unload_context;
43744 - atomic_long_t user_exception;
43745 - atomic_long_t set_context_option;
43746 - atomic_long_t check_context_retarget_intr;
43747 - atomic_long_t check_context_unload;
43748 - atomic_long_t tlb_dropin;
43749 - atomic_long_t tlb_preload_page;
43750 - atomic_long_t tlb_dropin_fail_no_asid;
43751 - atomic_long_t tlb_dropin_fail_upm;
43752 - atomic_long_t tlb_dropin_fail_invalid;
43753 - atomic_long_t tlb_dropin_fail_range_active;
43754 - atomic_long_t tlb_dropin_fail_idle;
43755 - atomic_long_t tlb_dropin_fail_fmm;
43756 - atomic_long_t tlb_dropin_fail_no_exception;
43757 - atomic_long_t tfh_stale_on_fault;
43758 - atomic_long_t mmu_invalidate_range;
43759 - atomic_long_t mmu_invalidate_page;
43760 - atomic_long_t flush_tlb;
43761 - atomic_long_t flush_tlb_gru;
43762 - atomic_long_t flush_tlb_gru_tgh;
43763 - atomic_long_t flush_tlb_gru_zero_asid;
43764 + atomic_long_unchecked_t vdata_alloc;
43765 + atomic_long_unchecked_t vdata_free;
43766 + atomic_long_unchecked_t gts_alloc;
43767 + atomic_long_unchecked_t gts_free;
43768 + atomic_long_unchecked_t gms_alloc;
43769 + atomic_long_unchecked_t gms_free;
43770 + atomic_long_unchecked_t gts_double_allocate;
43771 + atomic_long_unchecked_t assign_context;
43772 + atomic_long_unchecked_t assign_context_failed;
43773 + atomic_long_unchecked_t free_context;
43774 + atomic_long_unchecked_t load_user_context;
43775 + atomic_long_unchecked_t load_kernel_context;
43776 + atomic_long_unchecked_t lock_kernel_context;
43777 + atomic_long_unchecked_t unlock_kernel_context;
43778 + atomic_long_unchecked_t steal_user_context;
43779 + atomic_long_unchecked_t steal_kernel_context;
43780 + atomic_long_unchecked_t steal_context_failed;
43781 + atomic_long_unchecked_t nopfn;
43782 + atomic_long_unchecked_t asid_new;
43783 + atomic_long_unchecked_t asid_next;
43784 + atomic_long_unchecked_t asid_wrap;
43785 + atomic_long_unchecked_t asid_reuse;
43786 + atomic_long_unchecked_t intr;
43787 + atomic_long_unchecked_t intr_cbr;
43788 + atomic_long_unchecked_t intr_tfh;
43789 + atomic_long_unchecked_t intr_spurious;
43790 + atomic_long_unchecked_t intr_mm_lock_failed;
43791 + atomic_long_unchecked_t call_os;
43792 + atomic_long_unchecked_t call_os_wait_queue;
43793 + atomic_long_unchecked_t user_flush_tlb;
43794 + atomic_long_unchecked_t user_unload_context;
43795 + atomic_long_unchecked_t user_exception;
43796 + atomic_long_unchecked_t set_context_option;
43797 + atomic_long_unchecked_t check_context_retarget_intr;
43798 + atomic_long_unchecked_t check_context_unload;
43799 + atomic_long_unchecked_t tlb_dropin;
43800 + atomic_long_unchecked_t tlb_preload_page;
43801 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43802 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43803 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43804 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43805 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43806 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43807 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43808 + atomic_long_unchecked_t tfh_stale_on_fault;
43809 + atomic_long_unchecked_t mmu_invalidate_range;
43810 + atomic_long_unchecked_t mmu_invalidate_page;
43811 + atomic_long_unchecked_t flush_tlb;
43812 + atomic_long_unchecked_t flush_tlb_gru;
43813 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43814 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43815
43816 - atomic_long_t copy_gpa;
43817 - atomic_long_t read_gpa;
43818 + atomic_long_unchecked_t copy_gpa;
43819 + atomic_long_unchecked_t read_gpa;
43820
43821 - atomic_long_t mesq_receive;
43822 - atomic_long_t mesq_receive_none;
43823 - atomic_long_t mesq_send;
43824 - atomic_long_t mesq_send_failed;
43825 - atomic_long_t mesq_noop;
43826 - atomic_long_t mesq_send_unexpected_error;
43827 - atomic_long_t mesq_send_lb_overflow;
43828 - atomic_long_t mesq_send_qlimit_reached;
43829 - atomic_long_t mesq_send_amo_nacked;
43830 - atomic_long_t mesq_send_put_nacked;
43831 - atomic_long_t mesq_page_overflow;
43832 - atomic_long_t mesq_qf_locked;
43833 - atomic_long_t mesq_qf_noop_not_full;
43834 - atomic_long_t mesq_qf_switch_head_failed;
43835 - atomic_long_t mesq_qf_unexpected_error;
43836 - atomic_long_t mesq_noop_unexpected_error;
43837 - atomic_long_t mesq_noop_lb_overflow;
43838 - atomic_long_t mesq_noop_qlimit_reached;
43839 - atomic_long_t mesq_noop_amo_nacked;
43840 - atomic_long_t mesq_noop_put_nacked;
43841 - atomic_long_t mesq_noop_page_overflow;
43842 + atomic_long_unchecked_t mesq_receive;
43843 + atomic_long_unchecked_t mesq_receive_none;
43844 + atomic_long_unchecked_t mesq_send;
43845 + atomic_long_unchecked_t mesq_send_failed;
43846 + atomic_long_unchecked_t mesq_noop;
43847 + atomic_long_unchecked_t mesq_send_unexpected_error;
43848 + atomic_long_unchecked_t mesq_send_lb_overflow;
43849 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43850 + atomic_long_unchecked_t mesq_send_amo_nacked;
43851 + atomic_long_unchecked_t mesq_send_put_nacked;
43852 + atomic_long_unchecked_t mesq_page_overflow;
43853 + atomic_long_unchecked_t mesq_qf_locked;
43854 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43855 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43856 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43857 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43858 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43859 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43860 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43861 + atomic_long_unchecked_t mesq_noop_put_nacked;
43862 + atomic_long_unchecked_t mesq_noop_page_overflow;
43863
43864 };
43865
43866 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43867 tghop_invalidate, mcsop_last};
43868
43869 struct mcs_op_statistic {
43870 - atomic_long_t count;
43871 - atomic_long_t total;
43872 + atomic_long_unchecked_t count;
43873 + atomic_long_unchecked_t total;
43874 unsigned long max;
43875 };
43876
43877 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43878
43879 #define STAT(id) do { \
43880 if (gru_options & OPT_STATS) \
43881 - atomic_long_inc(&gru_stats.id); \
43882 + atomic_long_inc_unchecked(&gru_stats.id); \
43883 } while (0)
43884
43885 #ifdef CONFIG_SGI_GRU_DEBUG
43886 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43887 index c862cd4..0d176fe 100644
43888 --- a/drivers/misc/sgi-xp/xp.h
43889 +++ b/drivers/misc/sgi-xp/xp.h
43890 @@ -288,7 +288,7 @@ struct xpc_interface {
43891 xpc_notify_func, void *);
43892 void (*received) (short, int, void *);
43893 enum xp_retval (*partid_to_nasids) (short, void *);
43894 -};
43895 +} __no_const;
43896
43897 extern struct xpc_interface xpc_interface;
43898
43899 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43900 index b94d5f7..7f494c5 100644
43901 --- a/drivers/misc/sgi-xp/xpc.h
43902 +++ b/drivers/misc/sgi-xp/xpc.h
43903 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43904 void (*received_payload) (struct xpc_channel *, void *);
43905 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43906 };
43907 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43908
43909 /* struct xpc_partition act_state values (for XPC HB) */
43910
43911 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43912 /* found in xpc_main.c */
43913 extern struct device *xpc_part;
43914 extern struct device *xpc_chan;
43915 -extern struct xpc_arch_operations xpc_arch_ops;
43916 +extern xpc_arch_operations_no_const xpc_arch_ops;
43917 extern int xpc_disengage_timelimit;
43918 extern int xpc_disengage_timedout;
43919 extern int xpc_activate_IRQ_rcvd;
43920 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43921 index 82dc574..8539ab2 100644
43922 --- a/drivers/misc/sgi-xp/xpc_main.c
43923 +++ b/drivers/misc/sgi-xp/xpc_main.c
43924 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43925 .notifier_call = xpc_system_die,
43926 };
43927
43928 -struct xpc_arch_operations xpc_arch_ops;
43929 +xpc_arch_operations_no_const xpc_arch_ops;
43930
43931 /*
43932 * Timer function to enforce the timelimit on the partition disengage.
43933 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43934
43935 if (((die_args->trapnr == X86_TRAP_MF) ||
43936 (die_args->trapnr == X86_TRAP_XF)) &&
43937 - !user_mode_vm(die_args->regs))
43938 + !user_mode(die_args->regs))
43939 xpc_die_deactivate();
43940
43941 break;
43942 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43943 index 837fc73..acb5862 100644
43944 --- a/drivers/mmc/core/mmc_ops.c
43945 +++ b/drivers/mmc/core/mmc_ops.c
43946 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43947 void *data_buf;
43948 int is_on_stack;
43949
43950 - is_on_stack = object_is_on_stack(buf);
43951 + is_on_stack = object_starts_on_stack(buf);
43952 if (is_on_stack) {
43953 /*
43954 * dma onto stack is unsafe/nonportable, but callers to this
43955 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43956 index 81b2994..dce857e 100644
43957 --- a/drivers/mmc/host/dw_mmc.h
43958 +++ b/drivers/mmc/host/dw_mmc.h
43959 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43960 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43961 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43962 int (*parse_dt)(struct dw_mci *host);
43963 -};
43964 +} __do_const;
43965 #endif /* _DW_MMC_H_ */
43966 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43967 index c3785ed..1984c44 100644
43968 --- a/drivers/mmc/host/mmci.c
43969 +++ b/drivers/mmc/host/mmci.c
43970 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43971 }
43972
43973 if (variant->busy_detect) {
43974 - mmci_ops.card_busy = mmci_card_busy;
43975 + pax_open_kernel();
43976 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43977 + pax_close_kernel();
43978 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43979 }
43980
43981 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43982 index 926aaf6..8e153e2 100644
43983 --- a/drivers/mmc/host/sdhci-s3c.c
43984 +++ b/drivers/mmc/host/sdhci-s3c.c
43985 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43986 * we can use overriding functions instead of default.
43987 */
43988 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43989 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43990 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43991 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43992 + pax_open_kernel();
43993 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43994 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43995 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43996 + pax_close_kernel();
43997 }
43998
43999 /* It supports additional host capabilities if needed */
44000 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
44001 index 0c8bb6b..6f35deb 100644
44002 --- a/drivers/mtd/nand/denali.c
44003 +++ b/drivers/mtd/nand/denali.c
44004 @@ -24,6 +24,7 @@
44005 #include <linux/slab.h>
44006 #include <linux/mtd/mtd.h>
44007 #include <linux/module.h>
44008 +#include <linux/slab.h>
44009
44010 #include "denali.h"
44011
44012 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44013 index 51b9d6a..52af9a7 100644
44014 --- a/drivers/mtd/nftlmount.c
44015 +++ b/drivers/mtd/nftlmount.c
44016 @@ -24,6 +24,7 @@
44017 #include <asm/errno.h>
44018 #include <linux/delay.h>
44019 #include <linux/slab.h>
44020 +#include <linux/sched.h>
44021 #include <linux/mtd/mtd.h>
44022 #include <linux/mtd/nand.h>
44023 #include <linux/mtd/nftl.h>
44024 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44025 index f9d5615..99dd95f 100644
44026 --- a/drivers/mtd/sm_ftl.c
44027 +++ b/drivers/mtd/sm_ftl.c
44028 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44029 #define SM_CIS_VENDOR_OFFSET 0x59
44030 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44031 {
44032 - struct attribute_group *attr_group;
44033 + attribute_group_no_const *attr_group;
44034 struct attribute **attributes;
44035 struct sm_sysfs_attribute *vendor_attribute;
44036
44037 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44038 index e48cb33..72e73fc 100644
44039 --- a/drivers/net/bonding/bond_main.c
44040 +++ b/drivers/net/bonding/bond_main.c
44041 @@ -4832,7 +4832,7 @@ static unsigned int bond_get_num_tx_queues(void)
44042 return tx_queues;
44043 }
44044
44045 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44046 +static struct rtnl_link_ops bond_link_ops = {
44047 .kind = "bond",
44048 .priv_size = sizeof(struct bonding),
44049 .setup = bond_setup,
44050 @@ -4957,8 +4957,8 @@ static void __exit bonding_exit(void)
44051
44052 bond_destroy_debugfs();
44053
44054 - rtnl_link_unregister(&bond_link_ops);
44055 unregister_pernet_subsys(&bond_net_ops);
44056 + rtnl_link_unregister(&bond_link_ops);
44057
44058 #ifdef CONFIG_NET_POLL_CONTROLLER
44059 /*
44060 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44061 index e1d2643..7f4133b 100644
44062 --- a/drivers/net/ethernet/8390/ax88796.c
44063 +++ b/drivers/net/ethernet/8390/ax88796.c
44064 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44065 if (ax->plat->reg_offsets)
44066 ei_local->reg_offset = ax->plat->reg_offsets;
44067 else {
44068 + resource_size_t _mem_size = mem_size;
44069 + do_div(_mem_size, 0x18);
44070 ei_local->reg_offset = ax->reg_offsets;
44071 for (ret = 0; ret < 0x18; ret++)
44072 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44073 + ax->reg_offsets[ret] = _mem_size * ret;
44074 }
44075
44076 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44077 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44078 index c07a6d0..ca88c45 100644
44079 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44080 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44081 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44082 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44083 {
44084 /* RX_MODE controlling object */
44085 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44086 + bnx2x_init_rx_mode_obj(bp);
44087
44088 /* multicast configuration controlling object */
44089 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44090 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44091 index 8f03c98..dd0ef10 100644
44092 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44093 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44094 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44095 return rc;
44096 }
44097
44098 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44099 - struct bnx2x_rx_mode_obj *o)
44100 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44101 {
44102 if (CHIP_IS_E1x(bp)) {
44103 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44104 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44105 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44106 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44107 } else {
44108 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44109 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44110 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44111 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44112 }
44113 }
44114
44115 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44116 index 798dfe9..05d0a44 100644
44117 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44118 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44119 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44120
44121 /********************* RX MODE ****************/
44122
44123 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44124 - struct bnx2x_rx_mode_obj *o);
44125 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44126
44127 /**
44128 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44129 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44130 index cd63d11..b67dd78 100644
44131 --- a/drivers/net/ethernet/broadcom/tg3.h
44132 +++ b/drivers/net/ethernet/broadcom/tg3.h
44133 @@ -147,6 +147,7 @@
44134 #define CHIPREV_ID_5750_A0 0x4000
44135 #define CHIPREV_ID_5750_A1 0x4001
44136 #define CHIPREV_ID_5750_A3 0x4003
44137 +#define CHIPREV_ID_5750_C1 0x4201
44138 #define CHIPREV_ID_5750_C2 0x4202
44139 #define CHIPREV_ID_5752_A0_HW 0x5000
44140 #define CHIPREV_ID_5752_A0 0x6000
44141 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44142 index 8cffcdf..aadf043 100644
44143 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44144 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44145 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44146 */
44147 struct l2t_skb_cb {
44148 arp_failure_handler_func arp_failure_handler;
44149 -};
44150 +} __no_const;
44151
44152 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44153
44154 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
44155 index 9c89dc8..725ecc3 100644
44156 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
44157 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
44158 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
44159 flits = skb_transport_offset(skb) / 8;
44160 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
44161 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
44162 - skb->tail - skb->transport_header,
44163 + skb_tail_pointer(skb) - skb_transport_header(skb),
44164 adap->pdev);
44165 if (need_skb_unmap()) {
44166 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
44167 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44168 index 4c83003..2a2a5b9 100644
44169 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44170 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44171 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44172 for (i=0; i<ETH_ALEN; i++) {
44173 tmp.addr[i] = dev->dev_addr[i];
44174 }
44175 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44176 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44177 break;
44178
44179 case DE4X5_SET_HWADDR: /* Set the hardware address */
44180 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44181 spin_lock_irqsave(&lp->lock, flags);
44182 memcpy(&statbuf, &lp->pktStats, ioc->len);
44183 spin_unlock_irqrestore(&lp->lock, flags);
44184 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44185 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44186 return -EFAULT;
44187 break;
44188 }
44189 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44190 index 3d91a5e..1014702 100644
44191 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44192 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44193 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44194
44195 if (wrapped)
44196 newacc += 65536;
44197 - ACCESS_ONCE(*acc) = newacc;
44198 + ACCESS_ONCE_RW(*acc) = newacc;
44199 }
44200
44201 void populate_erx_stats(struct be_adapter *adapter,
44202 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44203 index 934e1ae..b262e6b 100644
44204 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44205 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44206 @@ -31,6 +31,8 @@
44207 #include <linux/netdevice.h>
44208 #include <linux/phy.h>
44209 #include <linux/platform_device.h>
44210 +#include <linux/interrupt.h>
44211 +#include <linux/irqreturn.h>
44212 #include <net/ip.h>
44213
44214 #include "ftgmac100.h"
44215 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44216 index 4658f4c..407d155 100644
44217 --- a/drivers/net/ethernet/faraday/ftmac100.c
44218 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44219 @@ -31,6 +31,8 @@
44220 #include <linux/module.h>
44221 #include <linux/netdevice.h>
44222 #include <linux/platform_device.h>
44223 +#include <linux/interrupt.h>
44224 +#include <linux/irqreturn.h>
44225
44226 #include "ftmac100.h"
44227
44228 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44229 index 331987d..3be1135 100644
44230 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44231 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44232 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44233 }
44234
44235 /* update the base incval used to calculate frequency adjustment */
44236 - ACCESS_ONCE(adapter->base_incval) = incval;
44237 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44238 smp_mb();
44239
44240 /* need lock to prevent incorrect read while modifying cyclecounter */
44241 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44242 index fbe5363..266b4e3 100644
44243 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44244 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44245 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44246 struct __vxge_hw_fifo *fifo;
44247 struct vxge_hw_fifo_config *config;
44248 u32 txdl_size, txdl_per_memblock;
44249 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44250 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44251 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44252 + };
44253 +
44254 struct __vxge_hw_virtualpath *vpath;
44255
44256 if ((vp == NULL) || (attr == NULL)) {
44257 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44258 goto exit;
44259 }
44260
44261 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44262 -
44263 fifo->mempool =
44264 __vxge_hw_mempool_create(vpath->hldev,
44265 fifo->config->memblock_size,
44266 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44267 index 345d987..af69721 100644
44268 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44269 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44270 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44271 op_mode = QLC_83XX_DEFAULT_OPMODE;
44272
44273 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44274 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44275 + pax_open_kernel();
44276 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44277 + pax_close_kernel();
44278 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44279 } else {
44280 return -EIO;
44281 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44282 index 599d1fd..59868fe 100644
44283 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44284 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44285 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44286 case QLCNIC_NON_PRIV_FUNC:
44287 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44288 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44289 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44290 + pax_open_kernel();
44291 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44292 + pax_close_kernel();
44293 break;
44294 case QLCNIC_PRIV_FUNC:
44295 ahw->op_mode = QLCNIC_PRIV_FUNC;
44296 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44297 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44298 + pax_open_kernel();
44299 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44300 + pax_close_kernel();
44301 break;
44302 case QLCNIC_MGMT_FUNC:
44303 ahw->op_mode = QLCNIC_MGMT_FUNC;
44304 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44305 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44306 + pax_open_kernel();
44307 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44308 + pax_close_kernel();
44309 break;
44310 default:
44311 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44312 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44313 index 85e5c97..76f97ec 100644
44314 --- a/drivers/net/ethernet/realtek/r8169.c
44315 +++ b/drivers/net/ethernet/realtek/r8169.c
44316 @@ -759,22 +759,22 @@ struct rtl8169_private {
44317 struct mdio_ops {
44318 void (*write)(struct rtl8169_private *, int, int);
44319 int (*read)(struct rtl8169_private *, int);
44320 - } mdio_ops;
44321 + } __no_const mdio_ops;
44322
44323 struct pll_power_ops {
44324 void (*down)(struct rtl8169_private *);
44325 void (*up)(struct rtl8169_private *);
44326 - } pll_power_ops;
44327 + } __no_const pll_power_ops;
44328
44329 struct jumbo_ops {
44330 void (*enable)(struct rtl8169_private *);
44331 void (*disable)(struct rtl8169_private *);
44332 - } jumbo_ops;
44333 + } __no_const jumbo_ops;
44334
44335 struct csi_ops {
44336 void (*write)(struct rtl8169_private *, int, int);
44337 u32 (*read)(struct rtl8169_private *, int);
44338 - } csi_ops;
44339 + } __no_const csi_ops;
44340
44341 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44342 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44343 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44344 index b495394..0748c54 100644
44345 --- a/drivers/net/ethernet/sfc/ptp.c
44346 +++ b/drivers/net/ethernet/sfc/ptp.c
44347 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44348 (u32)((u64)ptp->start.dma_addr >> 32));
44349
44350 /* Clear flag that signals MC ready */
44351 - ACCESS_ONCE(*start) = 0;
44352 + ACCESS_ONCE_RW(*start) = 0;
44353 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44354 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44355
44356 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44357 index 50617c5..b13724c 100644
44358 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44359 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44360 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44361
44362 writel(value, ioaddr + MMC_CNTRL);
44363
44364 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44365 - MMC_CNTRL, value);
44366 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44367 +// MMC_CNTRL, value);
44368 }
44369
44370 /* To mask all all interrupts.*/
44371 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44372 index e6fe0d8..2b7d752 100644
44373 --- a/drivers/net/hyperv/hyperv_net.h
44374 +++ b/drivers/net/hyperv/hyperv_net.h
44375 @@ -101,7 +101,7 @@ struct rndis_device {
44376
44377 enum rndis_device_state state;
44378 bool link_state;
44379 - atomic_t new_req_id;
44380 + atomic_unchecked_t new_req_id;
44381
44382 spinlock_t request_lock;
44383 struct list_head req_list;
44384 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44385 index 0775f0a..d4fb316 100644
44386 --- a/drivers/net/hyperv/rndis_filter.c
44387 +++ b/drivers/net/hyperv/rndis_filter.c
44388 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44389 * template
44390 */
44391 set = &rndis_msg->msg.set_req;
44392 - set->req_id = atomic_inc_return(&dev->new_req_id);
44393 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44394
44395 /* Add to the request list */
44396 spin_lock_irqsave(&dev->request_lock, flags);
44397 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44398
44399 /* Setup the rndis set */
44400 halt = &request->request_msg.msg.halt_req;
44401 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44402 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44403
44404 /* Ignore return since this msg is optional. */
44405 rndis_filter_send_request(dev, request);
44406 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44407 index bf0d55e..82bcfbd1 100644
44408 --- a/drivers/net/ieee802154/fakehard.c
44409 +++ b/drivers/net/ieee802154/fakehard.c
44410 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44411 phy->transmit_power = 0xbf;
44412
44413 dev->netdev_ops = &fake_ops;
44414 - dev->ml_priv = &fake_mlme;
44415 + dev->ml_priv = (void *)&fake_mlme;
44416
44417 priv = netdev_priv(dev);
44418 priv->phy = phy;
44419 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44420 index 16b43bf..ead0c35 100644
44421 --- a/drivers/net/macvlan.c
44422 +++ b/drivers/net/macvlan.c
44423 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44424 int macvlan_link_register(struct rtnl_link_ops *ops)
44425 {
44426 /* common fields */
44427 - ops->priv_size = sizeof(struct macvlan_dev);
44428 - ops->validate = macvlan_validate;
44429 - ops->maxtype = IFLA_MACVLAN_MAX;
44430 - ops->policy = macvlan_policy;
44431 - ops->changelink = macvlan_changelink;
44432 - ops->get_size = macvlan_get_size;
44433 - ops->fill_info = macvlan_fill_info;
44434 + pax_open_kernel();
44435 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44436 + *(void **)&ops->validate = macvlan_validate;
44437 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44438 + *(const void **)&ops->policy = macvlan_policy;
44439 + *(void **)&ops->changelink = macvlan_changelink;
44440 + *(void **)&ops->get_size = macvlan_get_size;
44441 + *(void **)&ops->fill_info = macvlan_fill_info;
44442 + pax_close_kernel();
44443
44444 return rtnl_link_register(ops);
44445 };
44446 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44447 return NOTIFY_DONE;
44448 }
44449
44450 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44451 +static struct notifier_block macvlan_notifier_block = {
44452 .notifier_call = macvlan_device_event,
44453 };
44454
44455 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44456 index ea53abb..2e4d087 100644
44457 --- a/drivers/net/macvtap.c
44458 +++ b/drivers/net/macvtap.c
44459 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44460 return NOTIFY_DONE;
44461 }
44462
44463 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44464 +static struct notifier_block macvtap_notifier_block = {
44465 .notifier_call = macvtap_device_event,
44466 };
44467
44468 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44469 index daec9b0..6428fcb 100644
44470 --- a/drivers/net/phy/mdio-bitbang.c
44471 +++ b/drivers/net/phy/mdio-bitbang.c
44472 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44473 struct mdiobb_ctrl *ctrl = bus->priv;
44474
44475 module_put(ctrl->ops->owner);
44476 + mdiobus_unregister(bus);
44477 mdiobus_free(bus);
44478 }
44479 EXPORT_SYMBOL(free_mdio_bitbang);
44480 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44481 index 72ff14b..11d442d 100644
44482 --- a/drivers/net/ppp/ppp_generic.c
44483 +++ b/drivers/net/ppp/ppp_generic.c
44484 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44485 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44486 struct ppp_stats stats;
44487 struct ppp_comp_stats cstats;
44488 - char *vers;
44489
44490 switch (cmd) {
44491 case SIOCGPPPSTATS:
44492 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44493 break;
44494
44495 case SIOCGPPPVER:
44496 - vers = PPP_VERSION;
44497 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44498 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44499 break;
44500 err = 0;
44501 break;
44502 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44503 index 1252d9c..80e660b 100644
44504 --- a/drivers/net/slip/slhc.c
44505 +++ b/drivers/net/slip/slhc.c
44506 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44507 register struct tcphdr *thp;
44508 register struct iphdr *ip;
44509 register struct cstate *cs;
44510 - int len, hdrlen;
44511 + long len, hdrlen;
44512 unsigned char *cp = icp;
44513
44514 /* We've got a compressed packet; read the change byte */
44515 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44516 index bff7e0b..7315137 100644
44517 --- a/drivers/net/team/team.c
44518 +++ b/drivers/net/team/team.c
44519 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44520 return NOTIFY_DONE;
44521 }
44522
44523 -static struct notifier_block team_notifier_block __read_mostly = {
44524 +static struct notifier_block team_notifier_block = {
44525 .notifier_call = team_device_event,
44526 };
44527
44528 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44529 index 71af122..b3c20f3 100644
44530 --- a/drivers/net/tun.c
44531 +++ b/drivers/net/tun.c
44532 @@ -1691,11 +1691,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44533 INIT_LIST_HEAD(&tun->disabled);
44534 err = tun_attach(tun, file);
44535 if (err < 0)
44536 - goto err_free_dev;
44537 + goto err_free_flow;
44538
44539 err = register_netdevice(tun->dev);
44540 if (err < 0)
44541 - goto err_free_dev;
44542 + goto err_detach;
44543
44544 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
44545 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
44546 @@ -1739,7 +1739,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44547 strcpy(ifr->ifr_name, tun->dev->name);
44548 return 0;
44549
44550 - err_free_dev:
44551 +err_detach:
44552 + tun_detach_all(dev);
44553 +err_free_flow:
44554 + tun_flow_uninit(tun);
44555 + security_tun_dev_free_security(tun->security);
44556 +err_free_dev:
44557 free_netdev(dev);
44558 return err;
44559 }
44560 @@ -1869,7 +1874,7 @@ unlock:
44561 }
44562
44563 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44564 - unsigned long arg, int ifreq_len)
44565 + unsigned long arg, size_t ifreq_len)
44566 {
44567 struct tun_file *tfile = file->private_data;
44568 struct tun_struct *tun;
44569 @@ -1881,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44570 int vnet_hdr_sz;
44571 int ret;
44572
44573 + if (ifreq_len > sizeof ifr)
44574 + return -EFAULT;
44575 +
44576 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44577 if (copy_from_user(&ifr, argp, ifreq_len))
44578 return -EFAULT;
44579 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44580 index 86292e6..8d34433 100644
44581 --- a/drivers/net/usb/hso.c
44582 +++ b/drivers/net/usb/hso.c
44583 @@ -71,7 +71,7 @@
44584 #include <asm/byteorder.h>
44585 #include <linux/serial_core.h>
44586 #include <linux/serial.h>
44587 -
44588 +#include <asm/local.h>
44589
44590 #define MOD_AUTHOR "Option Wireless"
44591 #define MOD_DESCRIPTION "USB High Speed Option driver"
44592 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44593 struct urb *urb;
44594
44595 urb = serial->rx_urb[0];
44596 - if (serial->port.count > 0) {
44597 + if (atomic_read(&serial->port.count) > 0) {
44598 count = put_rxbuf_data(urb, serial);
44599 if (count == -1)
44600 return;
44601 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44602 DUMP1(urb->transfer_buffer, urb->actual_length);
44603
44604 /* Anyone listening? */
44605 - if (serial->port.count == 0)
44606 + if (atomic_read(&serial->port.count) == 0)
44607 return;
44608
44609 if (status == 0) {
44610 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44611 tty_port_tty_set(&serial->port, tty);
44612
44613 /* check for port already opened, if not set the termios */
44614 - serial->port.count++;
44615 - if (serial->port.count == 1) {
44616 + if (atomic_inc_return(&serial->port.count) == 1) {
44617 serial->rx_state = RX_IDLE;
44618 /* Force default termio settings */
44619 _hso_serial_set_termios(tty, NULL);
44620 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44621 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44622 if (result) {
44623 hso_stop_serial_device(serial->parent);
44624 - serial->port.count--;
44625 + atomic_dec(&serial->port.count);
44626 kref_put(&serial->parent->ref, hso_serial_ref_free);
44627 }
44628 } else {
44629 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44630
44631 /* reset the rts and dtr */
44632 /* do the actual close */
44633 - serial->port.count--;
44634 + atomic_dec(&serial->port.count);
44635
44636 - if (serial->port.count <= 0) {
44637 - serial->port.count = 0;
44638 + if (atomic_read(&serial->port.count) <= 0) {
44639 + atomic_set(&serial->port.count, 0);
44640 tty_port_tty_set(&serial->port, NULL);
44641 if (!usb_gone)
44642 hso_stop_serial_device(serial->parent);
44643 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44644
44645 /* the actual setup */
44646 spin_lock_irqsave(&serial->serial_lock, flags);
44647 - if (serial->port.count)
44648 + if (atomic_read(&serial->port.count))
44649 _hso_serial_set_termios(tty, old);
44650 else
44651 tty->termios = *old;
44652 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44653 D1("Pending read interrupt on port %d\n", i);
44654 spin_lock(&serial->serial_lock);
44655 if (serial->rx_state == RX_IDLE &&
44656 - serial->port.count > 0) {
44657 + atomic_read(&serial->port.count) > 0) {
44658 /* Setup and send a ctrl req read on
44659 * port i */
44660 if (!serial->rx_urb_filled[0]) {
44661 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44662 /* Start all serial ports */
44663 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44664 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44665 - if (dev2ser(serial_table[i])->port.count) {
44666 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44667 result =
44668 hso_start_serial_device(serial_table[i], GFP_NOIO);
44669 hso_kick_transmit(dev2ser(serial_table[i]));
44670 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44671 index a79e9d3..78cd4fa 100644
44672 --- a/drivers/net/usb/sierra_net.c
44673 +++ b/drivers/net/usb/sierra_net.c
44674 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44675 /* atomic counter partially included in MAC address to make sure 2 devices
44676 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44677 */
44678 -static atomic_t iface_counter = ATOMIC_INIT(0);
44679 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44680
44681 /*
44682 * SYNC Timer Delay definition used to set the expiry time
44683 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44684 dev->net->netdev_ops = &sierra_net_device_ops;
44685
44686 /* change MAC addr to include, ifacenum, and to be unique */
44687 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44688 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44689 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44690
44691 /* we will have to manufacture ethernet headers, prepare template */
44692 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44693 index 767f7af..8162b9d 100644
44694 --- a/drivers/net/vxlan.c
44695 +++ b/drivers/net/vxlan.c
44696 @@ -1868,7 +1868,7 @@ nla_put_failure:
44697 return -EMSGSIZE;
44698 }
44699
44700 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44701 +static struct rtnl_link_ops vxlan_link_ops = {
44702 .kind = "vxlan",
44703 .maxtype = IFLA_VXLAN_MAX,
44704 .policy = vxlan_policy,
44705 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44706 index 0b60295..b8bfa5b 100644
44707 --- a/drivers/net/wimax/i2400m/rx.c
44708 +++ b/drivers/net/wimax/i2400m/rx.c
44709 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44710 if (i2400m->rx_roq == NULL)
44711 goto error_roq_alloc;
44712
44713 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44714 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44715 GFP_KERNEL);
44716 if (rd == NULL) {
44717 result = -ENOMEM;
44718 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44719 index 34c8a33..3261fdc 100644
44720 --- a/drivers/net/wireless/at76c50x-usb.c
44721 +++ b/drivers/net/wireless/at76c50x-usb.c
44722 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44723 }
44724
44725 /* Convert timeout from the DFU status to jiffies */
44726 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44727 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44728 {
44729 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44730 | (s->poll_timeout[1] << 8)
44731 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44732 index 2b3426b..1f564be 100644
44733 --- a/drivers/net/wireless/ath/ath10k/core.c
44734 +++ b/drivers/net/wireless/ath/ath10k/core.c
44735 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44736
44737 int ath10k_core_register(struct ath10k *ar)
44738 {
44739 - struct ath10k_htc_ops htc_ops;
44740 + static struct ath10k_htc_ops htc_ops = {
44741 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44742 + };
44743 struct bmi_target_info target_info;
44744 int status;
44745
44746 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44747 if (status)
44748 goto err;
44749
44750 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44751 -
44752 ar->htc = ath10k_htc_create(ar, &htc_ops);
44753 if (IS_ERR(ar->htc)) {
44754 status = PTR_ERR(ar->htc);
44755 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44756 index 74363c9..237b926 100644
44757 --- a/drivers/net/wireless/ath/ath10k/htc.c
44758 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44759 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44760 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44761 struct ath10k_htc_ops *htc_ops)
44762 {
44763 - struct ath10k_hif_cb htc_callbacks;
44764 + static struct ath10k_hif_cb htc_callbacks = {
44765 + .rx_completion = ath10k_htc_rx_completion_handler,
44766 + .tx_completion = ath10k_htc_tx_completion_handler,
44767 + };
44768 struct ath10k_htc_ep *ep = NULL;
44769 struct ath10k_htc *htc = NULL;
44770
44771 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44772 ath10k_htc_reset_endpoint_states(htc);
44773
44774 /* setup HIF layer callbacks */
44775 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44776 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44777 htc->ar = ar;
44778
44779 /* Get HIF default pipe for HTC message exchange */
44780 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44781 index 8d78253..bebbb68 100644
44782 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44783 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44784 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44785 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44786 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44787
44788 - ACCESS_ONCE(ads->ds_link) = i->link;
44789 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44790 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44791 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44792
44793 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44794 ctl6 = SM(i->keytype, AR_EncrType);
44795 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44796
44797 if ((i->is_first || i->is_last) &&
44798 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44799 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44800 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44801 | set11nTries(i->rates, 1)
44802 | set11nTries(i->rates, 2)
44803 | set11nTries(i->rates, 3)
44804 | (i->dur_update ? AR_DurUpdateEna : 0)
44805 | SM(0, AR_BurstDur);
44806
44807 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44808 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44809 | set11nRate(i->rates, 1)
44810 | set11nRate(i->rates, 2)
44811 | set11nRate(i->rates, 3);
44812 } else {
44813 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44814 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44815 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44816 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44817 }
44818
44819 if (!i->is_first) {
44820 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44821 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44822 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44823 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44824 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44825 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44826 return;
44827 }
44828
44829 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44830 break;
44831 }
44832
44833 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44834 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44835 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44836 | SM(i->txpower, AR_XmitPower)
44837 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44838 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44839 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44840 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44841
44842 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44843 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44844 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44845 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44846
44847 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44848 return;
44849
44850 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44851 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44852 | set11nPktDurRTSCTS(i->rates, 1);
44853
44854 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44855 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44856 | set11nPktDurRTSCTS(i->rates, 3);
44857
44858 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44859 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44860 | set11nRateFlags(i->rates, 1)
44861 | set11nRateFlags(i->rates, 2)
44862 | set11nRateFlags(i->rates, 3)
44863 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44864 index 5163abd..3ada4c2 100644
44865 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44866 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44867 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44868 (i->qcu << AR_TxQcuNum_S) | desc_len;
44869
44870 checksum += val;
44871 - ACCESS_ONCE(ads->info) = val;
44872 + ACCESS_ONCE_RW(ads->info) = val;
44873
44874 checksum += i->link;
44875 - ACCESS_ONCE(ads->link) = i->link;
44876 + ACCESS_ONCE_RW(ads->link) = i->link;
44877
44878 checksum += i->buf_addr[0];
44879 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44880 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44881 checksum += i->buf_addr[1];
44882 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44883 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44884 checksum += i->buf_addr[2];
44885 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44886 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44887 checksum += i->buf_addr[3];
44888 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44889 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44890
44891 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44892 - ACCESS_ONCE(ads->ctl3) = val;
44893 + ACCESS_ONCE_RW(ads->ctl3) = val;
44894 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44895 - ACCESS_ONCE(ads->ctl5) = val;
44896 + ACCESS_ONCE_RW(ads->ctl5) = val;
44897 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44898 - ACCESS_ONCE(ads->ctl7) = val;
44899 + ACCESS_ONCE_RW(ads->ctl7) = val;
44900 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44901 - ACCESS_ONCE(ads->ctl9) = val;
44902 + ACCESS_ONCE_RW(ads->ctl9) = val;
44903
44904 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44905 - ACCESS_ONCE(ads->ctl10) = checksum;
44906 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44907
44908 if (i->is_first || i->is_last) {
44909 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44910 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44911 | set11nTries(i->rates, 1)
44912 | set11nTries(i->rates, 2)
44913 | set11nTries(i->rates, 3)
44914 | (i->dur_update ? AR_DurUpdateEna : 0)
44915 | SM(0, AR_BurstDur);
44916
44917 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44918 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44919 | set11nRate(i->rates, 1)
44920 | set11nRate(i->rates, 2)
44921 | set11nRate(i->rates, 3);
44922 } else {
44923 - ACCESS_ONCE(ads->ctl13) = 0;
44924 - ACCESS_ONCE(ads->ctl14) = 0;
44925 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44926 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44927 }
44928
44929 ads->ctl20 = 0;
44930 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44931
44932 ctl17 = SM(i->keytype, AR_EncrType);
44933 if (!i->is_first) {
44934 - ACCESS_ONCE(ads->ctl11) = 0;
44935 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44936 - ACCESS_ONCE(ads->ctl15) = 0;
44937 - ACCESS_ONCE(ads->ctl16) = 0;
44938 - ACCESS_ONCE(ads->ctl17) = ctl17;
44939 - ACCESS_ONCE(ads->ctl18) = 0;
44940 - ACCESS_ONCE(ads->ctl19) = 0;
44941 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44942 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44943 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44944 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44945 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44946 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44947 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44948 return;
44949 }
44950
44951 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44952 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44953 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44954 | SM(i->txpower, AR_XmitPower)
44955 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44956 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44957 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44958 ctl12 |= SM(val, AR_PAPRDChainMask);
44959
44960 - ACCESS_ONCE(ads->ctl12) = ctl12;
44961 - ACCESS_ONCE(ads->ctl17) = ctl17;
44962 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44963 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44964
44965 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44966 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44967 | set11nPktDurRTSCTS(i->rates, 1);
44968
44969 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44970 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44971 | set11nPktDurRTSCTS(i->rates, 3);
44972
44973 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44974 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44975 | set11nRateFlags(i->rates, 1)
44976 | set11nRateFlags(i->rates, 2)
44977 | set11nRateFlags(i->rates, 3)
44978 | SM(i->rtscts_rate, AR_RTSCTSRate);
44979
44980 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44981 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44982 }
44983
44984 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44985 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44986 index cd74b3a..6a28d24 100644
44987 --- a/drivers/net/wireless/ath/ath9k/hw.h
44988 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44989 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44990
44991 /* ANI */
44992 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44993 -};
44994 +} __no_const;
44995
44996 /**
44997 * struct ath_spec_scan - parameters for Atheros spectral scan
44998 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44999 struct ath_spec_scan *param);
45000 void (*spectral_scan_trigger)(struct ath_hw *ah);
45001 void (*spectral_scan_wait)(struct ath_hw *ah);
45002 -};
45003 +} __no_const;
45004
45005 struct ath_nf_limits {
45006 s16 max;
45007 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45008 index 9581d07..84f6a76 100644
45009 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45010 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45011 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45012 */
45013 if (il3945_mod_params.disable_hw_scan) {
45014 D_INFO("Disabling hw_scan\n");
45015 - il3945_mac_ops.hw_scan = NULL;
45016 + pax_open_kernel();
45017 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45018 + pax_close_kernel();
45019 }
45020
45021 D_INFO("*** LOAD DRIVER ***\n");
45022 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45023 index d532948..e0d8bb1 100644
45024 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45025 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45026 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45027 {
45028 struct iwl_priv *priv = file->private_data;
45029 char buf[64];
45030 - int buf_size;
45031 + size_t buf_size;
45032 u32 offset, len;
45033
45034 memset(buf, 0, sizeof(buf));
45035 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45036 struct iwl_priv *priv = file->private_data;
45037
45038 char buf[8];
45039 - int buf_size;
45040 + size_t buf_size;
45041 u32 reset_flag;
45042
45043 memset(buf, 0, sizeof(buf));
45044 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45045 {
45046 struct iwl_priv *priv = file->private_data;
45047 char buf[8];
45048 - int buf_size;
45049 + size_t buf_size;
45050 int ht40;
45051
45052 memset(buf, 0, sizeof(buf));
45053 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45054 {
45055 struct iwl_priv *priv = file->private_data;
45056 char buf[8];
45057 - int buf_size;
45058 + size_t buf_size;
45059 int value;
45060
45061 memset(buf, 0, sizeof(buf));
45062 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45063 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45064 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45065
45066 -static const char *fmt_value = " %-30s %10u\n";
45067 -static const char *fmt_hex = " %-30s 0x%02X\n";
45068 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45069 -static const char *fmt_header =
45070 +static const char fmt_value[] = " %-30s %10u\n";
45071 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45072 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45073 +static const char fmt_header[] =
45074 "%-32s current cumulative delta max\n";
45075
45076 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45077 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45078 {
45079 struct iwl_priv *priv = file->private_data;
45080 char buf[8];
45081 - int buf_size;
45082 + size_t buf_size;
45083 int clear;
45084
45085 memset(buf, 0, sizeof(buf));
45086 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45087 {
45088 struct iwl_priv *priv = file->private_data;
45089 char buf[8];
45090 - int buf_size;
45091 + size_t buf_size;
45092 int trace;
45093
45094 memset(buf, 0, sizeof(buf));
45095 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45096 {
45097 struct iwl_priv *priv = file->private_data;
45098 char buf[8];
45099 - int buf_size;
45100 + size_t buf_size;
45101 int missed;
45102
45103 memset(buf, 0, sizeof(buf));
45104 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45105
45106 struct iwl_priv *priv = file->private_data;
45107 char buf[8];
45108 - int buf_size;
45109 + size_t buf_size;
45110 int plcp;
45111
45112 memset(buf, 0, sizeof(buf));
45113 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45114
45115 struct iwl_priv *priv = file->private_data;
45116 char buf[8];
45117 - int buf_size;
45118 + size_t buf_size;
45119 int flush;
45120
45121 memset(buf, 0, sizeof(buf));
45122 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45123
45124 struct iwl_priv *priv = file->private_data;
45125 char buf[8];
45126 - int buf_size;
45127 + size_t buf_size;
45128 int rts;
45129
45130 if (!priv->cfg->ht_params)
45131 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45132 {
45133 struct iwl_priv *priv = file->private_data;
45134 char buf[8];
45135 - int buf_size;
45136 + size_t buf_size;
45137
45138 memset(buf, 0, sizeof(buf));
45139 buf_size = min(count, sizeof(buf) - 1);
45140 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45141 struct iwl_priv *priv = file->private_data;
45142 u32 event_log_flag;
45143 char buf[8];
45144 - int buf_size;
45145 + size_t buf_size;
45146
45147 /* check that the interface is up */
45148 if (!iwl_is_ready(priv))
45149 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45150 struct iwl_priv *priv = file->private_data;
45151 char buf[8];
45152 u32 calib_disabled;
45153 - int buf_size;
45154 + size_t buf_size;
45155
45156 memset(buf, 0, sizeof(buf));
45157 buf_size = min(count, sizeof(buf) - 1);
45158 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45159 index 1531a4f..21d2641 100644
45160 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45161 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45162 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45163 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45164 {
45165 struct iwl_nvm_data *data = priv->nvm_data;
45166 - char *debug_msg;
45167 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45168
45169 if (data->sku_cap_11n_enable &&
45170 !priv->cfg->ht_params) {
45171 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45172 return -EINVAL;
45173 }
45174
45175 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45176 IWL_DEBUG_INFO(priv, debug_msg,
45177 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45178 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45179 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45180 index 390e2f0..75cfbaf 100644
45181 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45182 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45183 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45184 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45185
45186 char buf[8];
45187 - int buf_size;
45188 + size_t buf_size;
45189 u32 reset_flag;
45190
45191 memset(buf, 0, sizeof(buf));
45192 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45193 {
45194 struct iwl_trans *trans = file->private_data;
45195 char buf[8];
45196 - int buf_size;
45197 + size_t buf_size;
45198 int csr;
45199
45200 memset(buf, 0, sizeof(buf));
45201 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45202 index cb34c78..9fec0dc 100644
45203 --- a/drivers/net/wireless/mac80211_hwsim.c
45204 +++ b/drivers/net/wireless/mac80211_hwsim.c
45205 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45206
45207 if (channels > 1) {
45208 hwsim_if_comb.num_different_channels = channels;
45209 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45210 - mac80211_hwsim_ops.cancel_hw_scan =
45211 - mac80211_hwsim_cancel_hw_scan;
45212 - mac80211_hwsim_ops.sw_scan_start = NULL;
45213 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45214 - mac80211_hwsim_ops.remain_on_channel =
45215 - mac80211_hwsim_roc;
45216 - mac80211_hwsim_ops.cancel_remain_on_channel =
45217 - mac80211_hwsim_croc;
45218 - mac80211_hwsim_ops.add_chanctx =
45219 - mac80211_hwsim_add_chanctx;
45220 - mac80211_hwsim_ops.remove_chanctx =
45221 - mac80211_hwsim_remove_chanctx;
45222 - mac80211_hwsim_ops.change_chanctx =
45223 - mac80211_hwsim_change_chanctx;
45224 - mac80211_hwsim_ops.assign_vif_chanctx =
45225 - mac80211_hwsim_assign_vif_chanctx;
45226 - mac80211_hwsim_ops.unassign_vif_chanctx =
45227 - mac80211_hwsim_unassign_vif_chanctx;
45228 + pax_open_kernel();
45229 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45230 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45231 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45232 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45233 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45234 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45235 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45236 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45237 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45238 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45239 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45240 + pax_close_kernel();
45241 }
45242
45243 spin_lock_init(&hwsim_radio_lock);
45244 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45245 index 8169a85..7fa3b47 100644
45246 --- a/drivers/net/wireless/rndis_wlan.c
45247 +++ b/drivers/net/wireless/rndis_wlan.c
45248 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45249
45250 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45251
45252 - if (rts_threshold < 0 || rts_threshold > 2347)
45253 + if (rts_threshold > 2347)
45254 rts_threshold = 2347;
45255
45256 tmp = cpu_to_le32(rts_threshold);
45257 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45258 index ee3fc57..ed5ddc9 100644
45259 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45260 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45261 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45262 * for hardware which doesn't support hardware
45263 * sequence counting.
45264 */
45265 - atomic_t seqno;
45266 + atomic_unchecked_t seqno;
45267 };
45268
45269 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45270 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45271 index aa95c6c..a59dd67 100644
45272 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45273 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45274 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45275 * sequence counter given by mac80211.
45276 */
45277 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45278 - seqno = atomic_add_return(0x10, &intf->seqno);
45279 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45280 else
45281 - seqno = atomic_read(&intf->seqno);
45282 + seqno = atomic_read_unchecked(&intf->seqno);
45283
45284 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45285 hdr->seq_ctrl |= cpu_to_le16(seqno);
45286 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45287 index e2b3d9c..67a5184 100644
45288 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45289 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45290 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45291
45292 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45293
45294 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45295 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45296 + pax_open_kernel();
45297 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45298 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45299 + pax_close_kernel();
45300
45301 wl1251_info("using dedicated interrupt line");
45302 } else {
45303 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45304 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45305 + pax_open_kernel();
45306 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45307 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45308 + pax_close_kernel();
45309
45310 wl1251_info("using SDIO interrupt");
45311 }
45312 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45313 index 1c627da..69f7d17 100644
45314 --- a/drivers/net/wireless/ti/wl12xx/main.c
45315 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45316 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45317 sizeof(wl->conf.mem));
45318
45319 /* read data preparation is only needed by wl127x */
45320 - wl->ops->prepare_read = wl127x_prepare_read;
45321 + pax_open_kernel();
45322 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45323 + pax_close_kernel();
45324
45325 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45326 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45327 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45328 sizeof(wl->conf.mem));
45329
45330 /* read data preparation is only needed by wl127x */
45331 - wl->ops->prepare_read = wl127x_prepare_read;
45332 + pax_open_kernel();
45333 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45334 + pax_close_kernel();
45335
45336 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45337 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45338 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45339 index 7aa0eb8..5a9ef38 100644
45340 --- a/drivers/net/wireless/ti/wl18xx/main.c
45341 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45342 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45343 }
45344
45345 if (!checksum_param) {
45346 - wl18xx_ops.set_rx_csum = NULL;
45347 - wl18xx_ops.init_vif = NULL;
45348 + pax_open_kernel();
45349 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45350 + *(void **)&wl18xx_ops.init_vif = NULL;
45351 + pax_close_kernel();
45352 }
45353
45354 /* Enable 11a Band only if we have 5G antennas */
45355 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45356 index 7ef0b4a..ff65c28 100644
45357 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45358 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45359 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45360 {
45361 struct zd_usb *usb = urb->context;
45362 struct zd_usb_interrupt *intr = &usb->intr;
45363 - int len;
45364 + unsigned int len;
45365 u16 int_num;
45366
45367 ZD_ASSERT(in_interrupt());
45368 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45369 index d93b2b6..ae50401 100644
45370 --- a/drivers/oprofile/buffer_sync.c
45371 +++ b/drivers/oprofile/buffer_sync.c
45372 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45373 if (cookie == NO_COOKIE)
45374 offset = pc;
45375 if (cookie == INVALID_COOKIE) {
45376 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45377 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45378 offset = pc;
45379 }
45380 if (cookie != last_cookie) {
45381 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45382 /* add userspace sample */
45383
45384 if (!mm) {
45385 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45386 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45387 return 0;
45388 }
45389
45390 cookie = lookup_dcookie(mm, s->eip, &offset);
45391
45392 if (cookie == INVALID_COOKIE) {
45393 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45394 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45395 return 0;
45396 }
45397
45398 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45399 /* ignore backtraces if failed to add a sample */
45400 if (state == sb_bt_start) {
45401 state = sb_bt_ignore;
45402 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45403 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45404 }
45405 }
45406 release_mm(mm);
45407 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45408 index c0cc4e7..44d4e54 100644
45409 --- a/drivers/oprofile/event_buffer.c
45410 +++ b/drivers/oprofile/event_buffer.c
45411 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45412 }
45413
45414 if (buffer_pos == buffer_size) {
45415 - atomic_inc(&oprofile_stats.event_lost_overflow);
45416 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45417 return;
45418 }
45419
45420 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45421 index ed2c3ec..deda85a 100644
45422 --- a/drivers/oprofile/oprof.c
45423 +++ b/drivers/oprofile/oprof.c
45424 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45425 if (oprofile_ops.switch_events())
45426 return;
45427
45428 - atomic_inc(&oprofile_stats.multiplex_counter);
45429 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45430 start_switch_worker();
45431 }
45432
45433 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45434 index 84a208d..d61b0a1 100644
45435 --- a/drivers/oprofile/oprofile_files.c
45436 +++ b/drivers/oprofile/oprofile_files.c
45437 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45438
45439 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45440
45441 -static ssize_t timeout_read(struct file *file, char __user *buf,
45442 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45443 size_t count, loff_t *offset)
45444 {
45445 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45446 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45447 index 917d28e..d62d981 100644
45448 --- a/drivers/oprofile/oprofile_stats.c
45449 +++ b/drivers/oprofile/oprofile_stats.c
45450 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45451 cpu_buf->sample_invalid_eip = 0;
45452 }
45453
45454 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45455 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45456 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45457 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45458 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45459 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45460 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45461 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45462 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45463 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45464 }
45465
45466
45467 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45468 index 38b6fc0..b5cbfce 100644
45469 --- a/drivers/oprofile/oprofile_stats.h
45470 +++ b/drivers/oprofile/oprofile_stats.h
45471 @@ -13,11 +13,11 @@
45472 #include <linux/atomic.h>
45473
45474 struct oprofile_stat_struct {
45475 - atomic_t sample_lost_no_mm;
45476 - atomic_t sample_lost_no_mapping;
45477 - atomic_t bt_lost_no_mapping;
45478 - atomic_t event_lost_overflow;
45479 - atomic_t multiplex_counter;
45480 + atomic_unchecked_t sample_lost_no_mm;
45481 + atomic_unchecked_t sample_lost_no_mapping;
45482 + atomic_unchecked_t bt_lost_no_mapping;
45483 + atomic_unchecked_t event_lost_overflow;
45484 + atomic_unchecked_t multiplex_counter;
45485 };
45486
45487 extern struct oprofile_stat_struct oprofile_stats;
45488 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45489 index 7c12d9c..558bf3bb 100644
45490 --- a/drivers/oprofile/oprofilefs.c
45491 +++ b/drivers/oprofile/oprofilefs.c
45492 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45493
45494
45495 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45496 - char const *name, atomic_t *val)
45497 + char const *name, atomic_unchecked_t *val)
45498 {
45499 return __oprofilefs_create_file(sb, root, name,
45500 &atomic_ro_fops, 0444, val);
45501 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45502 index 61be1d9..dec05d7 100644
45503 --- a/drivers/oprofile/timer_int.c
45504 +++ b/drivers/oprofile/timer_int.c
45505 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45506 return NOTIFY_OK;
45507 }
45508
45509 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45510 +static struct notifier_block oprofile_cpu_notifier = {
45511 .notifier_call = oprofile_cpu_notify,
45512 };
45513
45514 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45515 index 92ed045..62d39bd7 100644
45516 --- a/drivers/parport/procfs.c
45517 +++ b/drivers/parport/procfs.c
45518 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45519
45520 *ppos += len;
45521
45522 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45523 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45524 }
45525
45526 #ifdef CONFIG_PARPORT_1284
45527 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45528
45529 *ppos += len;
45530
45531 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45532 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45533 }
45534 #endif /* IEEE1284.3 support. */
45535
45536 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45537 index c35e8ad..fc33beb 100644
45538 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45539 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45540 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45541 goto init_cleanup;
45542 }
45543
45544 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45545 + pax_open_kernel();
45546 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45547 + pax_close_kernel();
45548 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45549
45550 return retval;
45551 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45552 index a6a71c4..c91097b 100644
45553 --- a/drivers/pci/hotplug/cpcihp_generic.c
45554 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45555 @@ -73,7 +73,6 @@ static u16 port;
45556 static unsigned int enum_bit;
45557 static u8 enum_mask;
45558
45559 -static struct cpci_hp_controller_ops generic_hpc_ops;
45560 static struct cpci_hp_controller generic_hpc;
45561
45562 static int __init validate_parameters(void)
45563 @@ -139,6 +138,10 @@ static int query_enum(void)
45564 return ((value & enum_mask) == enum_mask);
45565 }
45566
45567 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45568 + .query_enum = query_enum,
45569 +};
45570 +
45571 static int __init cpcihp_generic_init(void)
45572 {
45573 int status;
45574 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45575 pci_dev_put(dev);
45576
45577 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45578 - generic_hpc_ops.query_enum = query_enum;
45579 generic_hpc.ops = &generic_hpc_ops;
45580
45581 status = cpci_hp_register_controller(&generic_hpc);
45582 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45583 index 449b4bb..257e2e8 100644
45584 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45585 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45586 @@ -59,7 +59,6 @@
45587 /* local variables */
45588 static bool debug;
45589 static bool poll;
45590 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45591 static struct cpci_hp_controller zt5550_hpc;
45592
45593 /* Primary cPCI bus bridge device */
45594 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45595 return 0;
45596 }
45597
45598 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45599 + .query_enum = zt5550_hc_query_enum,
45600 +};
45601 +
45602 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45603 {
45604 int status;
45605 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45606 dbg("returned from zt5550_hc_config");
45607
45608 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45609 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45610 zt5550_hpc.ops = &zt5550_hpc_ops;
45611 if(!poll) {
45612 zt5550_hpc.irq = hc_dev->irq;
45613 zt5550_hpc.irq_flags = IRQF_SHARED;
45614 zt5550_hpc.dev_id = hc_dev;
45615
45616 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45617 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45618 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45619 + pax_open_kernel();
45620 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45621 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45622 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45623 + pax_open_kernel();
45624 } else {
45625 info("using ENUM# polling mode");
45626 }
45627 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45628 index 76ba8a1..20ca857 100644
45629 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45630 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45631 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45632
45633 void compaq_nvram_init (void __iomem *rom_start)
45634 {
45635 +
45636 +#ifndef CONFIG_PAX_KERNEXEC
45637 if (rom_start) {
45638 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45639 }
45640 +#endif
45641 +
45642 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45643
45644 /* initialize our int15 lock */
45645 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45646 index ec20f74..c1d961e 100644
45647 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45648 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45649 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45650 return -EINVAL;
45651 }
45652
45653 - slot->ops->owner = owner;
45654 - slot->ops->mod_name = mod_name;
45655 + pax_open_kernel();
45656 + *(struct module **)&slot->ops->owner = owner;
45657 + *(const char **)&slot->ops->mod_name = mod_name;
45658 + pax_close_kernel();
45659
45660 mutex_lock(&pci_hp_mutex);
45661 /*
45662 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45663 index 7d72c5e..edce02c 100644
45664 --- a/drivers/pci/hotplug/pciehp_core.c
45665 +++ b/drivers/pci/hotplug/pciehp_core.c
45666 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45667 struct slot *slot = ctrl->slot;
45668 struct hotplug_slot *hotplug = NULL;
45669 struct hotplug_slot_info *info = NULL;
45670 - struct hotplug_slot_ops *ops = NULL;
45671 + hotplug_slot_ops_no_const *ops = NULL;
45672 char name[SLOT_NAME_SIZE];
45673 int retval = -ENOMEM;
45674
45675 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45676 index c0dbe1f..94cf3d8 100644
45677 --- a/drivers/pci/pci-sysfs.c
45678 +++ b/drivers/pci/pci-sysfs.c
45679 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45680 {
45681 /* allocate attribute structure, piggyback attribute name */
45682 int name_len = write_combine ? 13 : 10;
45683 - struct bin_attribute *res_attr;
45684 + bin_attribute_no_const *res_attr;
45685 int retval;
45686
45687 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45688 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45689 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45690 {
45691 int retval;
45692 - struct bin_attribute *attr;
45693 + bin_attribute_no_const *attr;
45694
45695 /* If the device has VPD, try to expose it in sysfs. */
45696 if (dev->vpd) {
45697 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45698 {
45699 int retval;
45700 int rom_size = 0;
45701 - struct bin_attribute *attr;
45702 + bin_attribute_no_const *attr;
45703
45704 if (!sysfs_initialized)
45705 return -EACCES;
45706 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45707 index d1182c4..2a138ec 100644
45708 --- a/drivers/pci/pci.h
45709 +++ b/drivers/pci/pci.h
45710 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45711 struct pci_vpd {
45712 unsigned int len;
45713 const struct pci_vpd_ops *ops;
45714 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45715 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45716 };
45717
45718 int pci_vpd_pci22_init(struct pci_dev *dev);
45719 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45720 index 403a443..034e050 100644
45721 --- a/drivers/pci/pcie/aspm.c
45722 +++ b/drivers/pci/pcie/aspm.c
45723 @@ -27,9 +27,9 @@
45724 #define MODULE_PARAM_PREFIX "pcie_aspm."
45725
45726 /* Note: those are not register definitions */
45727 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45728 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45729 -#define ASPM_STATE_L1 (4) /* L1 state */
45730 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45731 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45732 +#define ASPM_STATE_L1 (4U) /* L1 state */
45733 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45734 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45735
45736 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45737 index 46ada5c..20da716 100644
45738 --- a/drivers/pci/probe.c
45739 +++ b/drivers/pci/probe.c
45740 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45741 struct pci_bus_region region, inverted_region;
45742 bool bar_too_big = false, bar_disabled = false;
45743
45744 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45745 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45746
45747 /* No printks while decoding is disabled! */
45748 if (!dev->mmio_always_on) {
45749 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45750 index cdc7836..528635c 100644
45751 --- a/drivers/pci/proc.c
45752 +++ b/drivers/pci/proc.c
45753 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45754 static int __init pci_proc_init(void)
45755 {
45756 struct pci_dev *dev = NULL;
45757 +
45758 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45759 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45760 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45761 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45762 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45763 +#endif
45764 +#else
45765 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45766 +#endif
45767 proc_create("devices", 0, proc_bus_pci_dir,
45768 &proc_bus_pci_dev_operations);
45769 proc_initialized = 1;
45770 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45771 index 3e5b4497..dcdfb70 100644
45772 --- a/drivers/platform/x86/chromeos_laptop.c
45773 +++ b/drivers/platform/x86/chromeos_laptop.c
45774 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45775 return 0;
45776 }
45777
45778 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45779 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45780 {
45781 .ident = "Samsung Series 5 550 - Touchpad",
45782 .matches = {
45783 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45784 index 62f8030..c7f2a45 100644
45785 --- a/drivers/platform/x86/msi-laptop.c
45786 +++ b/drivers/platform/x86/msi-laptop.c
45787 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45788
45789 if (!quirks->ec_read_only) {
45790 /* allow userland write sysfs file */
45791 - dev_attr_bluetooth.store = store_bluetooth;
45792 - dev_attr_wlan.store = store_wlan;
45793 - dev_attr_threeg.store = store_threeg;
45794 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45795 - dev_attr_wlan.attr.mode |= S_IWUSR;
45796 - dev_attr_threeg.attr.mode |= S_IWUSR;
45797 + pax_open_kernel();
45798 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45799 + *(void **)&dev_attr_wlan.store = store_wlan;
45800 + *(void **)&dev_attr_threeg.store = store_threeg;
45801 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45802 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45803 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45804 + pax_close_kernel();
45805 }
45806
45807 /* disable hardware control by fn key */
45808 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45809 index 3a1b6bf..b453930 100644
45810 --- a/drivers/platform/x86/sony-laptop.c
45811 +++ b/drivers/platform/x86/sony-laptop.c
45812 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45813 }
45814
45815 /* High speed charging function */
45816 -static struct device_attribute *hsc_handle;
45817 +static device_attribute_no_const *hsc_handle;
45818
45819 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45820 struct device_attribute *attr,
45821 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45822 index 54d31c0..3f896d3 100644
45823 --- a/drivers/platform/x86/thinkpad_acpi.c
45824 +++ b/drivers/platform/x86/thinkpad_acpi.c
45825 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45826 return 0;
45827 }
45828
45829 -void static hotkey_mask_warn_incomplete_mask(void)
45830 +static void hotkey_mask_warn_incomplete_mask(void)
45831 {
45832 /* log only what the user can fix... */
45833 const u32 wantedmask = hotkey_driver_mask &
45834 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45835 }
45836 }
45837
45838 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45839 - struct tp_nvram_state *newn,
45840 - const u32 event_mask)
45841 -{
45842 -
45843 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45844 do { \
45845 if ((event_mask & (1 << __scancode)) && \
45846 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45847 tpacpi_hotkey_send_key(__scancode); \
45848 } while (0)
45849
45850 - void issue_volchange(const unsigned int oldvol,
45851 - const unsigned int newvol)
45852 - {
45853 - unsigned int i = oldvol;
45854 +static void issue_volchange(const unsigned int oldvol,
45855 + const unsigned int newvol,
45856 + const u32 event_mask)
45857 +{
45858 + unsigned int i = oldvol;
45859
45860 - while (i > newvol) {
45861 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45862 - i--;
45863 - }
45864 - while (i < newvol) {
45865 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45866 - i++;
45867 - }
45868 + while (i > newvol) {
45869 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45870 + i--;
45871 }
45872 + while (i < newvol) {
45873 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45874 + i++;
45875 + }
45876 +}
45877
45878 - void issue_brightnesschange(const unsigned int oldbrt,
45879 - const unsigned int newbrt)
45880 - {
45881 - unsigned int i = oldbrt;
45882 +static void issue_brightnesschange(const unsigned int oldbrt,
45883 + const unsigned int newbrt,
45884 + const u32 event_mask)
45885 +{
45886 + unsigned int i = oldbrt;
45887
45888 - while (i > newbrt) {
45889 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45890 - i--;
45891 - }
45892 - while (i < newbrt) {
45893 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45894 - i++;
45895 - }
45896 + while (i > newbrt) {
45897 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45898 + i--;
45899 + }
45900 + while (i < newbrt) {
45901 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45902 + i++;
45903 }
45904 +}
45905
45906 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45907 + struct tp_nvram_state *newn,
45908 + const u32 event_mask)
45909 +{
45910 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45911 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45912 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45913 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45914 oldn->volume_level != newn->volume_level) {
45915 /* recently muted, or repeated mute keypress, or
45916 * multiple presses ending in mute */
45917 - issue_volchange(oldn->volume_level, newn->volume_level);
45918 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45919 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45920 }
45921 } else {
45922 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45923 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45924 }
45925 if (oldn->volume_level != newn->volume_level) {
45926 - issue_volchange(oldn->volume_level, newn->volume_level);
45927 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45928 } else if (oldn->volume_toggle != newn->volume_toggle) {
45929 /* repeated vol up/down keypress at end of scale ? */
45930 if (newn->volume_level == 0)
45931 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45932 /* handle brightness */
45933 if (oldn->brightness_level != newn->brightness_level) {
45934 issue_brightnesschange(oldn->brightness_level,
45935 - newn->brightness_level);
45936 + newn->brightness_level,
45937 + event_mask);
45938 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45939 /* repeated key presses that didn't change state */
45940 if (newn->brightness_level == 0)
45941 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45942 && !tp_features.bright_unkfw)
45943 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45944 }
45945 +}
45946
45947 #undef TPACPI_COMPARE_KEY
45948 #undef TPACPI_MAY_SEND_KEY
45949 -}
45950
45951 /*
45952 * Polling driver
45953 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45954 index 769d265..a3a05ca 100644
45955 --- a/drivers/pnp/pnpbios/bioscalls.c
45956 +++ b/drivers/pnp/pnpbios/bioscalls.c
45957 @@ -58,7 +58,7 @@ do { \
45958 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45959 } while(0)
45960
45961 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45962 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45963 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45964
45965 /*
45966 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45967
45968 cpu = get_cpu();
45969 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45970 +
45971 + pax_open_kernel();
45972 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45973 + pax_close_kernel();
45974
45975 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45976 spin_lock_irqsave(&pnp_bios_lock, flags);
45977 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45978 :"memory");
45979 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45980
45981 + pax_open_kernel();
45982 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45983 + pax_close_kernel();
45984 +
45985 put_cpu();
45986
45987 /* If we get here and this is set then the PnP BIOS faulted on us. */
45988 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45989 return status;
45990 }
45991
45992 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45993 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45994 {
45995 int i;
45996
45997 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45998 pnp_bios_callpoint.offset = header->fields.pm16offset;
45999 pnp_bios_callpoint.segment = PNP_CS16;
46000
46001 + pax_open_kernel();
46002 +
46003 for_each_possible_cpu(i) {
46004 struct desc_struct *gdt = get_cpu_gdt_table(i);
46005 if (!gdt)
46006 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46007 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46008 (unsigned long)__va(header->fields.pm16dseg));
46009 }
46010 +
46011 + pax_close_kernel();
46012 }
46013 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46014 index d95e101..67f0c3f 100644
46015 --- a/drivers/pnp/resource.c
46016 +++ b/drivers/pnp/resource.c
46017 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46018 return 1;
46019
46020 /* check if the resource is valid */
46021 - if (*irq < 0 || *irq > 15)
46022 + if (*irq > 15)
46023 return 0;
46024
46025 /* check if the resource is reserved */
46026 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46027 return 1;
46028
46029 /* check if the resource is valid */
46030 - if (*dma < 0 || *dma == 4 || *dma > 7)
46031 + if (*dma == 4 || *dma > 7)
46032 return 0;
46033
46034 /* check if the resource is reserved */
46035 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46036 index 0c52e2a..3421ab7 100644
46037 --- a/drivers/power/pda_power.c
46038 +++ b/drivers/power/pda_power.c
46039 @@ -37,7 +37,11 @@ static int polling;
46040
46041 #if IS_ENABLED(CONFIG_USB_PHY)
46042 static struct usb_phy *transceiver;
46043 -static struct notifier_block otg_nb;
46044 +static int otg_handle_notification(struct notifier_block *nb,
46045 + unsigned long event, void *unused);
46046 +static struct notifier_block otg_nb = {
46047 + .notifier_call = otg_handle_notification
46048 +};
46049 #endif
46050
46051 static struct regulator *ac_draw;
46052 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46053
46054 #if IS_ENABLED(CONFIG_USB_PHY)
46055 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46056 - otg_nb.notifier_call = otg_handle_notification;
46057 ret = usb_register_notifier(transceiver, &otg_nb);
46058 if (ret) {
46059 dev_err(dev, "failure to register otg notifier\n");
46060 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46061 index cc439fd..8fa30df 100644
46062 --- a/drivers/power/power_supply.h
46063 +++ b/drivers/power/power_supply.h
46064 @@ -16,12 +16,12 @@ struct power_supply;
46065
46066 #ifdef CONFIG_SYSFS
46067
46068 -extern void power_supply_init_attrs(struct device_type *dev_type);
46069 +extern void power_supply_init_attrs(void);
46070 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46071
46072 #else
46073
46074 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46075 +static inline void power_supply_init_attrs(void) {}
46076 #define power_supply_uevent NULL
46077
46078 #endif /* CONFIG_SYSFS */
46079 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46080 index 3b2d5df..3207114 100644
46081 --- a/drivers/power/power_supply_core.c
46082 +++ b/drivers/power/power_supply_core.c
46083 @@ -24,7 +24,10 @@
46084 struct class *power_supply_class;
46085 EXPORT_SYMBOL_GPL(power_supply_class);
46086
46087 -static struct device_type power_supply_dev_type;
46088 +extern const struct attribute_group *power_supply_attr_groups[];
46089 +static struct device_type power_supply_dev_type = {
46090 + .groups = power_supply_attr_groups,
46091 +};
46092
46093 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46094 struct power_supply *supply)
46095 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
46096 return PTR_ERR(power_supply_class);
46097
46098 power_supply_class->dev_uevent = power_supply_uevent;
46099 - power_supply_init_attrs(&power_supply_dev_type);
46100 + power_supply_init_attrs();
46101
46102 return 0;
46103 }
46104 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46105 index 29178f7..c65f324 100644
46106 --- a/drivers/power/power_supply_sysfs.c
46107 +++ b/drivers/power/power_supply_sysfs.c
46108 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46109 .is_visible = power_supply_attr_is_visible,
46110 };
46111
46112 -static const struct attribute_group *power_supply_attr_groups[] = {
46113 +const struct attribute_group *power_supply_attr_groups[] = {
46114 &power_supply_attr_group,
46115 NULL,
46116 };
46117
46118 -void power_supply_init_attrs(struct device_type *dev_type)
46119 +void power_supply_init_attrs(void)
46120 {
46121 int i;
46122
46123 - dev_type->groups = power_supply_attr_groups;
46124 -
46125 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46126 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46127 }
46128 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46129 index 288c75a..065bc84 100644
46130 --- a/drivers/regulator/core.c
46131 +++ b/drivers/regulator/core.c
46132 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46133 {
46134 const struct regulation_constraints *constraints = NULL;
46135 const struct regulator_init_data *init_data;
46136 - static atomic_t regulator_no = ATOMIC_INIT(0);
46137 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46138 struct regulator_dev *rdev;
46139 struct device *dev;
46140 int ret, i;
46141 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46142 rdev->dev.of_node = config->of_node;
46143 rdev->dev.parent = dev;
46144 dev_set_name(&rdev->dev, "regulator.%d",
46145 - atomic_inc_return(&regulator_no) - 1);
46146 + atomic_inc_return_unchecked(&regulator_no) - 1);
46147 ret = device_register(&rdev->dev);
46148 if (ret != 0) {
46149 put_device(&rdev->dev);
46150 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46151 index d428ef9..fdc0357 100644
46152 --- a/drivers/regulator/max8660.c
46153 +++ b/drivers/regulator/max8660.c
46154 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
46155 max8660->shadow_regs[MAX8660_OVER1] = 5;
46156 } else {
46157 /* Otherwise devices can be toggled via software */
46158 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46159 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46160 + pax_open_kernel();
46161 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46162 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46163 + pax_close_kernel();
46164 }
46165
46166 /*
46167 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46168 index 0c5195a..637a453d 100644
46169 --- a/drivers/regulator/max8973-regulator.c
46170 +++ b/drivers/regulator/max8973-regulator.c
46171 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46172 if (!pdata || !pdata->enable_ext_control) {
46173 max->desc.enable_reg = MAX8973_VOUT;
46174 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46175 - max->ops.enable = regulator_enable_regmap;
46176 - max->ops.disable = regulator_disable_regmap;
46177 - max->ops.is_enabled = regulator_is_enabled_regmap;
46178 + pax_open_kernel();
46179 + *(void **)&max->ops.enable = regulator_enable_regmap;
46180 + *(void **)&max->ops.disable = regulator_disable_regmap;
46181 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46182 + pax_close_kernel();
46183 }
46184
46185 if (pdata) {
46186 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46187 index 1037e07..e64dea1 100644
46188 --- a/drivers/regulator/mc13892-regulator.c
46189 +++ b/drivers/regulator/mc13892-regulator.c
46190 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46191 }
46192 mc13xxx_unlock(mc13892);
46193
46194 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46195 + pax_open_kernel();
46196 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46197 = mc13892_vcam_set_mode;
46198 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46199 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46200 = mc13892_vcam_get_mode;
46201 + pax_close_kernel();
46202
46203 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46204 ARRAY_SIZE(mc13892_regulators));
46205 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46206 index be06d71..264aee9 100644
46207 --- a/drivers/rtc/rtc-cmos.c
46208 +++ b/drivers/rtc/rtc-cmos.c
46209 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46210 hpet_rtc_timer_init();
46211
46212 /* export at least the first block of NVRAM */
46213 - nvram.size = address_space - NVRAM_OFFSET;
46214 + pax_open_kernel();
46215 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46216 + pax_close_kernel();
46217 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46218 if (retval < 0) {
46219 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46220 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46221 index d049393..bb20be0 100644
46222 --- a/drivers/rtc/rtc-dev.c
46223 +++ b/drivers/rtc/rtc-dev.c
46224 @@ -16,6 +16,7 @@
46225 #include <linux/module.h>
46226 #include <linux/rtc.h>
46227 #include <linux/sched.h>
46228 +#include <linux/grsecurity.h>
46229 #include "rtc-core.h"
46230
46231 static dev_t rtc_devt;
46232 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46233 if (copy_from_user(&tm, uarg, sizeof(tm)))
46234 return -EFAULT;
46235
46236 + gr_log_timechange();
46237 +
46238 return rtc_set_time(rtc, &tm);
46239
46240 case RTC_PIE_ON:
46241 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46242 index ca18fd1..055e42d 100644
46243 --- a/drivers/rtc/rtc-ds1307.c
46244 +++ b/drivers/rtc/rtc-ds1307.c
46245 @@ -107,7 +107,7 @@ struct ds1307 {
46246 u8 offset; /* register's offset */
46247 u8 regs[11];
46248 u16 nvram_offset;
46249 - struct bin_attribute *nvram;
46250 + bin_attribute_no_const *nvram;
46251 enum ds_type type;
46252 unsigned long flags;
46253 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46254 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46255 index fcb0329..d77b7f2 100644
46256 --- a/drivers/rtc/rtc-m48t59.c
46257 +++ b/drivers/rtc/rtc-m48t59.c
46258 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46259 if (IS_ERR(m48t59->rtc))
46260 return PTR_ERR(m48t59->rtc);
46261
46262 - m48t59_nvram_attr.size = pdata->offset;
46263 + pax_open_kernel();
46264 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46265 + pax_close_kernel();
46266
46267 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46268 if (ret)
46269 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46270 index e693af6..2e525b6 100644
46271 --- a/drivers/scsi/bfa/bfa_fcpim.h
46272 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46273 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46274
46275 struct bfa_itn_s {
46276 bfa_isr_func_t isr;
46277 -};
46278 +} __no_const;
46279
46280 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46281 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46282 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46283 index 90814fe..4384138 100644
46284 --- a/drivers/scsi/bfa/bfa_ioc.h
46285 +++ b/drivers/scsi/bfa/bfa_ioc.h
46286 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46287 bfa_ioc_disable_cbfn_t disable_cbfn;
46288 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46289 bfa_ioc_reset_cbfn_t reset_cbfn;
46290 -};
46291 +} __no_const;
46292
46293 /*
46294 * IOC event notification mechanism.
46295 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46296 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46297 enum bfi_ioc_state fwstate);
46298 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46299 -};
46300 +} __no_const;
46301
46302 /*
46303 * Queue element to wait for room in request queue. FIFO order is
46304 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46305 index c9382d6..6619864 100644
46306 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46307 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46308 @@ -33,8 +33,8 @@
46309 */
46310 #include "libfcoe.h"
46311
46312 -static atomic_t ctlr_num;
46313 -static atomic_t fcf_num;
46314 +static atomic_unchecked_t ctlr_num;
46315 +static atomic_unchecked_t fcf_num;
46316
46317 /*
46318 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46319 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46320 if (!ctlr)
46321 goto out;
46322
46323 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46324 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46325 ctlr->f = f;
46326 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46327 INIT_LIST_HEAD(&ctlr->fcfs);
46328 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46329 fcf->dev.parent = &ctlr->dev;
46330 fcf->dev.bus = &fcoe_bus_type;
46331 fcf->dev.type = &fcoe_fcf_device_type;
46332 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46333 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46334 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46335
46336 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46337 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46338 {
46339 int error;
46340
46341 - atomic_set(&ctlr_num, 0);
46342 - atomic_set(&fcf_num, 0);
46343 + atomic_set_unchecked(&ctlr_num, 0);
46344 + atomic_set_unchecked(&fcf_num, 0);
46345
46346 error = bus_register(&fcoe_bus_type);
46347 if (error)
46348 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46349 index df0c3c7..b00e1d0 100644
46350 --- a/drivers/scsi/hosts.c
46351 +++ b/drivers/scsi/hosts.c
46352 @@ -42,7 +42,7 @@
46353 #include "scsi_logging.h"
46354
46355
46356 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46357 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46358
46359
46360 static void scsi_host_cls_release(struct device *dev)
46361 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46362 * subtract one because we increment first then return, but we need to
46363 * know what the next host number was before increment
46364 */
46365 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46366 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46367 shost->dma_channel = 0xff;
46368
46369 /* These three are default values which can be overridden */
46370 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46371 index 7f4f790..b75b92a 100644
46372 --- a/drivers/scsi/hpsa.c
46373 +++ b/drivers/scsi/hpsa.c
46374 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46375 unsigned long flags;
46376
46377 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46378 - return h->access.command_completed(h, q);
46379 + return h->access->command_completed(h, q);
46380
46381 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46382 a = rq->head[rq->current_entry];
46383 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46384 while (!list_empty(&h->reqQ)) {
46385 c = list_entry(h->reqQ.next, struct CommandList, list);
46386 /* can't do anything if fifo is full */
46387 - if ((h->access.fifo_full(h))) {
46388 + if ((h->access->fifo_full(h))) {
46389 dev_warn(&h->pdev->dev, "fifo full\n");
46390 break;
46391 }
46392 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46393
46394 /* Tell the controller execute command */
46395 spin_unlock_irqrestore(&h->lock, flags);
46396 - h->access.submit_command(h, c);
46397 + h->access->submit_command(h, c);
46398 spin_lock_irqsave(&h->lock, flags);
46399 }
46400 spin_unlock_irqrestore(&h->lock, flags);
46401 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46402
46403 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46404 {
46405 - return h->access.command_completed(h, q);
46406 + return h->access->command_completed(h, q);
46407 }
46408
46409 static inline bool interrupt_pending(struct ctlr_info *h)
46410 {
46411 - return h->access.intr_pending(h);
46412 + return h->access->intr_pending(h);
46413 }
46414
46415 static inline long interrupt_not_for_us(struct ctlr_info *h)
46416 {
46417 - return (h->access.intr_pending(h) == 0) ||
46418 + return (h->access->intr_pending(h) == 0) ||
46419 (h->interrupts_enabled == 0);
46420 }
46421
46422 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46423 if (prod_index < 0)
46424 return -ENODEV;
46425 h->product_name = products[prod_index].product_name;
46426 - h->access = *(products[prod_index].access);
46427 + h->access = products[prod_index].access;
46428
46429 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46430 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46431 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46432
46433 assert_spin_locked(&lockup_detector_lock);
46434 remove_ctlr_from_lockup_detector_list(h);
46435 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46436 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46437 spin_lock_irqsave(&h->lock, flags);
46438 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46439 spin_unlock_irqrestore(&h->lock, flags);
46440 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46441 }
46442
46443 /* make sure the board interrupts are off */
46444 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46445 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46446
46447 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46448 goto clean2;
46449 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46450 * fake ones to scoop up any residual completions.
46451 */
46452 spin_lock_irqsave(&h->lock, flags);
46453 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46454 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46455 spin_unlock_irqrestore(&h->lock, flags);
46456 free_irqs(h);
46457 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46458 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46459 dev_info(&h->pdev->dev, "Board READY.\n");
46460 dev_info(&h->pdev->dev,
46461 "Waiting for stale completions to drain.\n");
46462 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46463 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46464 msleep(10000);
46465 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46466 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46467
46468 rc = controller_reset_failed(h->cfgtable);
46469 if (rc)
46470 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46471 }
46472
46473 /* Turn the interrupts on so we can service requests */
46474 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46475 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46476
46477 hpsa_hba_inquiry(h);
46478 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46479 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46480 * To write all data in the battery backed cache to disks
46481 */
46482 hpsa_flush_cache(h);
46483 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46484 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46485 hpsa_free_irqs_and_disable_msix(h);
46486 }
46487
46488 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46489 return;
46490 }
46491 /* Change the access methods to the performant access methods */
46492 - h->access = SA5_performant_access;
46493 + h->access = &SA5_performant_access;
46494 h->transMethod = CFGTBL_Trans_Performant;
46495 }
46496
46497 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46498 index 9816479..c5d4e97 100644
46499 --- a/drivers/scsi/hpsa.h
46500 +++ b/drivers/scsi/hpsa.h
46501 @@ -79,7 +79,7 @@ struct ctlr_info {
46502 unsigned int msix_vector;
46503 unsigned int msi_vector;
46504 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46505 - struct access_method access;
46506 + struct access_method *access;
46507
46508 /* queue and queue Info */
46509 struct list_head reqQ;
46510 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46511 index 5879929..32b241d 100644
46512 --- a/drivers/scsi/libfc/fc_exch.c
46513 +++ b/drivers/scsi/libfc/fc_exch.c
46514 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46515 u16 pool_max_index;
46516
46517 struct {
46518 - atomic_t no_free_exch;
46519 - atomic_t no_free_exch_xid;
46520 - atomic_t xid_not_found;
46521 - atomic_t xid_busy;
46522 - atomic_t seq_not_found;
46523 - atomic_t non_bls_resp;
46524 + atomic_unchecked_t no_free_exch;
46525 + atomic_unchecked_t no_free_exch_xid;
46526 + atomic_unchecked_t xid_not_found;
46527 + atomic_unchecked_t xid_busy;
46528 + atomic_unchecked_t seq_not_found;
46529 + atomic_unchecked_t non_bls_resp;
46530 } stats;
46531 };
46532
46533 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46534 /* allocate memory for exchange */
46535 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46536 if (!ep) {
46537 - atomic_inc(&mp->stats.no_free_exch);
46538 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46539 goto out;
46540 }
46541 memset(ep, 0, sizeof(*ep));
46542 @@ -797,7 +797,7 @@ out:
46543 return ep;
46544 err:
46545 spin_unlock_bh(&pool->lock);
46546 - atomic_inc(&mp->stats.no_free_exch_xid);
46547 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46548 mempool_free(ep, mp->ep_pool);
46549 return NULL;
46550 }
46551 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46552 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46553 ep = fc_exch_find(mp, xid);
46554 if (!ep) {
46555 - atomic_inc(&mp->stats.xid_not_found);
46556 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46557 reject = FC_RJT_OX_ID;
46558 goto out;
46559 }
46560 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46561 ep = fc_exch_find(mp, xid);
46562 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46563 if (ep) {
46564 - atomic_inc(&mp->stats.xid_busy);
46565 + atomic_inc_unchecked(&mp->stats.xid_busy);
46566 reject = FC_RJT_RX_ID;
46567 goto rel;
46568 }
46569 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46570 }
46571 xid = ep->xid; /* get our XID */
46572 } else if (!ep) {
46573 - atomic_inc(&mp->stats.xid_not_found);
46574 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46575 reject = FC_RJT_RX_ID; /* XID not found */
46576 goto out;
46577 }
46578 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46579 } else {
46580 sp = &ep->seq;
46581 if (sp->id != fh->fh_seq_id) {
46582 - atomic_inc(&mp->stats.seq_not_found);
46583 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46584 if (f_ctl & FC_FC_END_SEQ) {
46585 /*
46586 * Update sequence_id based on incoming last
46587 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46588
46589 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46590 if (!ep) {
46591 - atomic_inc(&mp->stats.xid_not_found);
46592 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46593 goto out;
46594 }
46595 if (ep->esb_stat & ESB_ST_COMPLETE) {
46596 - atomic_inc(&mp->stats.xid_not_found);
46597 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46598 goto rel;
46599 }
46600 if (ep->rxid == FC_XID_UNKNOWN)
46601 ep->rxid = ntohs(fh->fh_rx_id);
46602 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46603 - atomic_inc(&mp->stats.xid_not_found);
46604 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46605 goto rel;
46606 }
46607 if (ep->did != ntoh24(fh->fh_s_id) &&
46608 ep->did != FC_FID_FLOGI) {
46609 - atomic_inc(&mp->stats.xid_not_found);
46610 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46611 goto rel;
46612 }
46613 sof = fr_sof(fp);
46614 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46615 sp->ssb_stat |= SSB_ST_RESP;
46616 sp->id = fh->fh_seq_id;
46617 } else if (sp->id != fh->fh_seq_id) {
46618 - atomic_inc(&mp->stats.seq_not_found);
46619 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46620 goto rel;
46621 }
46622
46623 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46624 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46625
46626 if (!sp)
46627 - atomic_inc(&mp->stats.xid_not_found);
46628 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46629 else
46630 - atomic_inc(&mp->stats.non_bls_resp);
46631 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46632
46633 fc_frame_free(fp);
46634 }
46635 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46636
46637 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46638 mp = ema->mp;
46639 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46640 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46641 st->fc_no_free_exch_xid +=
46642 - atomic_read(&mp->stats.no_free_exch_xid);
46643 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46644 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46645 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46646 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46647 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46648 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46649 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46650 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46651 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46652 }
46653 }
46654 EXPORT_SYMBOL(fc_exch_update_stats);
46655 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46656 index 161c98e..6d563b3 100644
46657 --- a/drivers/scsi/libsas/sas_ata.c
46658 +++ b/drivers/scsi/libsas/sas_ata.c
46659 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46660 .postreset = ata_std_postreset,
46661 .error_handler = ata_std_error_handler,
46662 .post_internal_cmd = sas_ata_post_internal,
46663 - .qc_defer = ata_std_qc_defer,
46664 + .qc_defer = ata_std_qc_defer,
46665 .qc_prep = ata_noop_qc_prep,
46666 .qc_issue = sas_ata_qc_issue,
46667 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46668 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46669 index 93f222d..73e977b 100644
46670 --- a/drivers/scsi/lpfc/lpfc.h
46671 +++ b/drivers/scsi/lpfc/lpfc.h
46672 @@ -431,7 +431,7 @@ struct lpfc_vport {
46673 struct dentry *debug_nodelist;
46674 struct dentry *vport_debugfs_root;
46675 struct lpfc_debugfs_trc *disc_trc;
46676 - atomic_t disc_trc_cnt;
46677 + atomic_unchecked_t disc_trc_cnt;
46678 #endif
46679 uint8_t stat_data_enabled;
46680 uint8_t stat_data_blocked;
46681 @@ -865,8 +865,8 @@ struct lpfc_hba {
46682 struct timer_list fabric_block_timer;
46683 unsigned long bit_flags;
46684 #define FABRIC_COMANDS_BLOCKED 0
46685 - atomic_t num_rsrc_err;
46686 - atomic_t num_cmd_success;
46687 + atomic_unchecked_t num_rsrc_err;
46688 + atomic_unchecked_t num_cmd_success;
46689 unsigned long last_rsrc_error_time;
46690 unsigned long last_ramp_down_time;
46691 unsigned long last_ramp_up_time;
46692 @@ -902,7 +902,7 @@ struct lpfc_hba {
46693
46694 struct dentry *debug_slow_ring_trc;
46695 struct lpfc_debugfs_trc *slow_ring_trc;
46696 - atomic_t slow_ring_trc_cnt;
46697 + atomic_unchecked_t slow_ring_trc_cnt;
46698 /* iDiag debugfs sub-directory */
46699 struct dentry *idiag_root;
46700 struct dentry *idiag_pci_cfg;
46701 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46702 index 60084e6..0e2e700 100644
46703 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46704 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46705 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46706
46707 #include <linux/debugfs.h>
46708
46709 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46710 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46711 static unsigned long lpfc_debugfs_start_time = 0L;
46712
46713 /* iDiag */
46714 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46715 lpfc_debugfs_enable = 0;
46716
46717 len = 0;
46718 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46719 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46720 (lpfc_debugfs_max_disc_trc - 1);
46721 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46722 dtp = vport->disc_trc + i;
46723 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46724 lpfc_debugfs_enable = 0;
46725
46726 len = 0;
46727 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46728 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46729 (lpfc_debugfs_max_slow_ring_trc - 1);
46730 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46731 dtp = phba->slow_ring_trc + i;
46732 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46733 !vport || !vport->disc_trc)
46734 return;
46735
46736 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46737 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46738 (lpfc_debugfs_max_disc_trc - 1);
46739 dtp = vport->disc_trc + index;
46740 dtp->fmt = fmt;
46741 dtp->data1 = data1;
46742 dtp->data2 = data2;
46743 dtp->data3 = data3;
46744 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46745 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46746 dtp->jif = jiffies;
46747 #endif
46748 return;
46749 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46750 !phba || !phba->slow_ring_trc)
46751 return;
46752
46753 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46754 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46755 (lpfc_debugfs_max_slow_ring_trc - 1);
46756 dtp = phba->slow_ring_trc + index;
46757 dtp->fmt = fmt;
46758 dtp->data1 = data1;
46759 dtp->data2 = data2;
46760 dtp->data3 = data3;
46761 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46762 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46763 dtp->jif = jiffies;
46764 #endif
46765 return;
46766 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46767 "slow_ring buffer\n");
46768 goto debug_failed;
46769 }
46770 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46771 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46772 memset(phba->slow_ring_trc, 0,
46773 (sizeof(struct lpfc_debugfs_trc) *
46774 lpfc_debugfs_max_slow_ring_trc));
46775 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46776 "buffer\n");
46777 goto debug_failed;
46778 }
46779 - atomic_set(&vport->disc_trc_cnt, 0);
46780 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46781
46782 snprintf(name, sizeof(name), "discovery_trace");
46783 vport->debug_disc_trc =
46784 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46785 index e0b20fa..30c2c0d 100644
46786 --- a/drivers/scsi/lpfc/lpfc_init.c
46787 +++ b/drivers/scsi/lpfc/lpfc_init.c
46788 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46789 "misc_register returned with status %d", error);
46790
46791 if (lpfc_enable_npiv) {
46792 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46793 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46794 + pax_open_kernel();
46795 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46796 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46797 + pax_close_kernel();
46798 }
46799 lpfc_transport_template =
46800 fc_attach_transport(&lpfc_transport_functions);
46801 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46802 index 243de1d..f40e3e5 100644
46803 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46804 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46805 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46806 uint32_t evt_posted;
46807
46808 spin_lock_irqsave(&phba->hbalock, flags);
46809 - atomic_inc(&phba->num_rsrc_err);
46810 + atomic_inc_unchecked(&phba->num_rsrc_err);
46811 phba->last_rsrc_error_time = jiffies;
46812
46813 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46814 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46815 unsigned long flags;
46816 struct lpfc_hba *phba = vport->phba;
46817 uint32_t evt_posted;
46818 - atomic_inc(&phba->num_cmd_success);
46819 + atomic_inc_unchecked(&phba->num_cmd_success);
46820
46821 if (vport->cfg_lun_queue_depth <= queue_depth)
46822 return;
46823 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46824 unsigned long num_rsrc_err, num_cmd_success;
46825 int i;
46826
46827 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46828 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46829 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46830 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46831
46832 /*
46833 * The error and success command counters are global per
46834 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46835 }
46836 }
46837 lpfc_destroy_vport_work_array(phba, vports);
46838 - atomic_set(&phba->num_rsrc_err, 0);
46839 - atomic_set(&phba->num_cmd_success, 0);
46840 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46841 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46842 }
46843
46844 /**
46845 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46846 }
46847 }
46848 lpfc_destroy_vport_work_array(phba, vports);
46849 - atomic_set(&phba->num_rsrc_err, 0);
46850 - atomic_set(&phba->num_cmd_success, 0);
46851 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46852 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46853 }
46854
46855 /**
46856 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46857 index 1eb7b028..b2a6080 100644
46858 --- a/drivers/scsi/pmcraid.c
46859 +++ b/drivers/scsi/pmcraid.c
46860 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46861 res->scsi_dev = scsi_dev;
46862 scsi_dev->hostdata = res;
46863 res->change_detected = 0;
46864 - atomic_set(&res->read_failures, 0);
46865 - atomic_set(&res->write_failures, 0);
46866 + atomic_set_unchecked(&res->read_failures, 0);
46867 + atomic_set_unchecked(&res->write_failures, 0);
46868 rc = 0;
46869 }
46870 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46871 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46872
46873 /* If this was a SCSI read/write command keep count of errors */
46874 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46875 - atomic_inc(&res->read_failures);
46876 + atomic_inc_unchecked(&res->read_failures);
46877 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46878 - atomic_inc(&res->write_failures);
46879 + atomic_inc_unchecked(&res->write_failures);
46880
46881 if (!RES_IS_GSCSI(res->cfg_entry) &&
46882 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46883 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46884 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46885 * hrrq_id assigned here in queuecommand
46886 */
46887 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46888 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46889 pinstance->num_hrrq;
46890 cmd->cmd_done = pmcraid_io_done;
46891
46892 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46893 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46894 * hrrq_id assigned here in queuecommand
46895 */
46896 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46897 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46898 pinstance->num_hrrq;
46899
46900 if (request_size) {
46901 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46902
46903 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46904 /* add resources only after host is added into system */
46905 - if (!atomic_read(&pinstance->expose_resources))
46906 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46907 return;
46908
46909 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46910 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46911 init_waitqueue_head(&pinstance->reset_wait_q);
46912
46913 atomic_set(&pinstance->outstanding_cmds, 0);
46914 - atomic_set(&pinstance->last_message_id, 0);
46915 - atomic_set(&pinstance->expose_resources, 0);
46916 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46917 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46918
46919 INIT_LIST_HEAD(&pinstance->free_res_q);
46920 INIT_LIST_HEAD(&pinstance->used_res_q);
46921 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46922 /* Schedule worker thread to handle CCN and take care of adding and
46923 * removing devices to OS
46924 */
46925 - atomic_set(&pinstance->expose_resources, 1);
46926 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46927 schedule_work(&pinstance->worker_q);
46928 return rc;
46929
46930 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46931 index e1d150f..6c6df44 100644
46932 --- a/drivers/scsi/pmcraid.h
46933 +++ b/drivers/scsi/pmcraid.h
46934 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46935 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46936
46937 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46938 - atomic_t last_message_id;
46939 + atomic_unchecked_t last_message_id;
46940
46941 /* configuration table */
46942 struct pmcraid_config_table *cfg_table;
46943 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46944 atomic_t outstanding_cmds;
46945
46946 /* should add/delete resources to mid-layer now ?*/
46947 - atomic_t expose_resources;
46948 + atomic_unchecked_t expose_resources;
46949
46950
46951
46952 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46953 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46954 };
46955 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46956 - atomic_t read_failures; /* count of failed READ commands */
46957 - atomic_t write_failures; /* count of failed WRITE commands */
46958 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46959 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46960
46961 /* To indicate add/delete/modify during CCN */
46962 u8 change_detected;
46963 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46964 index d7a99ae..801df70 100644
46965 --- a/drivers/scsi/qla2xxx/qla_attr.c
46966 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46967 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46968 return 0;
46969 }
46970
46971 -struct fc_function_template qla2xxx_transport_functions = {
46972 +fc_function_template_no_const qla2xxx_transport_functions = {
46973
46974 .show_host_node_name = 1,
46975 .show_host_port_name = 1,
46976 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46977 .bsg_timeout = qla24xx_bsg_timeout,
46978 };
46979
46980 -struct fc_function_template qla2xxx_transport_vport_functions = {
46981 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46982
46983 .show_host_node_name = 1,
46984 .show_host_port_name = 1,
46985 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46986 index 2d98232..a84298e 100644
46987 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46988 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46989 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46990 struct device_attribute;
46991 extern struct device_attribute *qla2x00_host_attrs[];
46992 struct fc_function_template;
46993 -extern struct fc_function_template qla2xxx_transport_functions;
46994 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46995 +extern fc_function_template_no_const qla2xxx_transport_functions;
46996 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46997 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46998 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46999 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47000 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47001 index 3e21e9f..426ba79 100644
47002 --- a/drivers/scsi/qla2xxx/qla_os.c
47003 +++ b/drivers/scsi/qla2xxx/qla_os.c
47004 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47005 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47006 /* Ok, a 64bit DMA mask is applicable. */
47007 ha->flags.enable_64bit_addressing = 1;
47008 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47009 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47010 + pax_open_kernel();
47011 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47012 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47013 + pax_close_kernel();
47014 return;
47015 }
47016 }
47017 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47018 index ddf16a8..80f4dd0 100644
47019 --- a/drivers/scsi/qla4xxx/ql4_def.h
47020 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47021 @@ -291,7 +291,7 @@ struct ddb_entry {
47022 * (4000 only) */
47023 atomic_t relogin_timer; /* Max Time to wait for
47024 * relogin to complete */
47025 - atomic_t relogin_retry_count; /* Num of times relogin has been
47026 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47027 * retried */
47028 uint32_t default_time2wait; /* Default Min time between
47029 * relogins (+aens) */
47030 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47031 index b246b3c..897004d 100644
47032 --- a/drivers/scsi/qla4xxx/ql4_os.c
47033 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47034 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47035 */
47036 if (!iscsi_is_session_online(cls_sess)) {
47037 /* Reset retry relogin timer */
47038 - atomic_inc(&ddb_entry->relogin_retry_count);
47039 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47040 DEBUG2(ql4_printk(KERN_INFO, ha,
47041 "%s: index[%d] relogin timed out-retrying"
47042 " relogin (%d), retry (%d)\n", __func__,
47043 ddb_entry->fw_ddb_index,
47044 - atomic_read(&ddb_entry->relogin_retry_count),
47045 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47046 ddb_entry->default_time2wait + 4));
47047 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47048 atomic_set(&ddb_entry->retry_relogin_timer,
47049 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47050
47051 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47052 atomic_set(&ddb_entry->relogin_timer, 0);
47053 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47054 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47055 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47056 ddb_entry->default_relogin_timeout =
47057 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47058 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47059 index eaa808e..95f8841 100644
47060 --- a/drivers/scsi/scsi.c
47061 +++ b/drivers/scsi/scsi.c
47062 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47063 unsigned long timeout;
47064 int rtn = 0;
47065
47066 - atomic_inc(&cmd->device->iorequest_cnt);
47067 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47068
47069 /* check if the device is still usable */
47070 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47071 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47072 index 124392f..75eb43e 100644
47073 --- a/drivers/scsi/scsi_lib.c
47074 +++ b/drivers/scsi/scsi_lib.c
47075 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47076 shost = sdev->host;
47077 scsi_init_cmd_errh(cmd);
47078 cmd->result = DID_NO_CONNECT << 16;
47079 - atomic_inc(&cmd->device->iorequest_cnt);
47080 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47081
47082 /*
47083 * SCSI request completion path will do scsi_device_unbusy(),
47084 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47085
47086 INIT_LIST_HEAD(&cmd->eh_entry);
47087
47088 - atomic_inc(&cmd->device->iodone_cnt);
47089 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47090 if (cmd->result)
47091 - atomic_inc(&cmd->device->ioerr_cnt);
47092 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47093
47094 disposition = scsi_decide_disposition(cmd);
47095 if (disposition != SUCCESS &&
47096 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47097 index 7e50061..71db7a6 100644
47098 --- a/drivers/scsi/scsi_sysfs.c
47099 +++ b/drivers/scsi/scsi_sysfs.c
47100 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47101 char *buf) \
47102 { \
47103 struct scsi_device *sdev = to_scsi_device(dev); \
47104 - unsigned long long count = atomic_read(&sdev->field); \
47105 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47106 return snprintf(buf, 20, "0x%llx\n", count); \
47107 } \
47108 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47109 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47110 index 84a1fdf..693b0d6 100644
47111 --- a/drivers/scsi/scsi_tgt_lib.c
47112 +++ b/drivers/scsi/scsi_tgt_lib.c
47113 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47114 int err;
47115
47116 dprintk("%lx %u\n", uaddr, len);
47117 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47118 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47119 if (err) {
47120 /*
47121 * TODO: need to fixup sg_tablesize, max_segment_size,
47122 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47123 index 4628fd5..a94a1c2 100644
47124 --- a/drivers/scsi/scsi_transport_fc.c
47125 +++ b/drivers/scsi/scsi_transport_fc.c
47126 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47127 * Netlink Infrastructure
47128 */
47129
47130 -static atomic_t fc_event_seq;
47131 +static atomic_unchecked_t fc_event_seq;
47132
47133 /**
47134 * fc_get_event_number - Obtain the next sequential FC event number
47135 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47136 u32
47137 fc_get_event_number(void)
47138 {
47139 - return atomic_add_return(1, &fc_event_seq);
47140 + return atomic_add_return_unchecked(1, &fc_event_seq);
47141 }
47142 EXPORT_SYMBOL(fc_get_event_number);
47143
47144 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47145 {
47146 int error;
47147
47148 - atomic_set(&fc_event_seq, 0);
47149 + atomic_set_unchecked(&fc_event_seq, 0);
47150
47151 error = transport_class_register(&fc_host_class);
47152 if (error)
47153 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47154 char *cp;
47155
47156 *val = simple_strtoul(buf, &cp, 0);
47157 - if ((*cp && (*cp != '\n')) || (*val < 0))
47158 + if (*cp && (*cp != '\n'))
47159 return -EINVAL;
47160 /*
47161 * Check for overflow; dev_loss_tmo is u32
47162 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47163 index abf7c40..c3240ed 100644
47164 --- a/drivers/scsi/scsi_transport_iscsi.c
47165 +++ b/drivers/scsi/scsi_transport_iscsi.c
47166 @@ -80,7 +80,7 @@ struct iscsi_internal {
47167 struct transport_container session_cont;
47168 };
47169
47170 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47171 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47172 static struct workqueue_struct *iscsi_eh_timer_workq;
47173
47174 static DEFINE_IDA(iscsi_sess_ida);
47175 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47176 int err;
47177
47178 ihost = shost->shost_data;
47179 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47180 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47181
47182 if (target_id == ISCSI_MAX_TARGET) {
47183 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47184 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47185 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47186 ISCSI_TRANSPORT_VERSION);
47187
47188 - atomic_set(&iscsi_session_nr, 0);
47189 + atomic_set_unchecked(&iscsi_session_nr, 0);
47190
47191 err = class_register(&iscsi_transport_class);
47192 if (err)
47193 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47194 index f379c7f..e8fc69c 100644
47195 --- a/drivers/scsi/scsi_transport_srp.c
47196 +++ b/drivers/scsi/scsi_transport_srp.c
47197 @@ -33,7 +33,7 @@
47198 #include "scsi_transport_srp_internal.h"
47199
47200 struct srp_host_attrs {
47201 - atomic_t next_port_id;
47202 + atomic_unchecked_t next_port_id;
47203 };
47204 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47205
47206 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47207 struct Scsi_Host *shost = dev_to_shost(dev);
47208 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47209
47210 - atomic_set(&srp_host->next_port_id, 0);
47211 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47212 return 0;
47213 }
47214
47215 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47216 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47217 rport->roles = ids->roles;
47218
47219 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47220 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47221 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47222
47223 transport_setup_device(&rport->dev);
47224 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47225 index 2783dd7..d20395b 100644
47226 --- a/drivers/scsi/sd.c
47227 +++ b/drivers/scsi/sd.c
47228 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47229 sdkp->disk = gd;
47230 sdkp->index = index;
47231 atomic_set(&sdkp->openers, 0);
47232 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47233 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47234
47235 if (!sdp->request_queue->rq_timeout) {
47236 if (sdp->type != TYPE_MOD)
47237 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47238 index df5e961..df6b97f 100644
47239 --- a/drivers/scsi/sg.c
47240 +++ b/drivers/scsi/sg.c
47241 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47242 sdp->disk->disk_name,
47243 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47244 NULL,
47245 - (char *)arg);
47246 + (char __user *)arg);
47247 case BLKTRACESTART:
47248 return blk_trace_startstop(sdp->device->request_queue, 1);
47249 case BLKTRACESTOP:
47250 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47251 index 978dda2..cb19aa0 100644
47252 --- a/drivers/spi/spi.c
47253 +++ b/drivers/spi/spi.c
47254 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47255 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47256
47257 /* portable code must never pass more than 32 bytes */
47258 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47259 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47260
47261 static u8 *buf;
47262
47263 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47264 index ee3a57f..18368c1 100644
47265 --- a/drivers/staging/android/timed_output.c
47266 +++ b/drivers/staging/android/timed_output.c
47267 @@ -25,7 +25,7 @@
47268 #include "timed_output.h"
47269
47270 static struct class *timed_output_class;
47271 -static atomic_t device_count;
47272 +static atomic_unchecked_t device_count;
47273
47274 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47275 char *buf)
47276 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47277 timed_output_class = class_create(THIS_MODULE, "timed_output");
47278 if (IS_ERR(timed_output_class))
47279 return PTR_ERR(timed_output_class);
47280 - atomic_set(&device_count, 0);
47281 + atomic_set_unchecked(&device_count, 0);
47282 }
47283
47284 return 0;
47285 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47286 if (ret < 0)
47287 return ret;
47288
47289 - tdev->index = atomic_inc_return(&device_count);
47290 + tdev->index = atomic_inc_return_unchecked(&device_count);
47291 tdev->dev = device_create(timed_output_class, NULL,
47292 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47293 if (IS_ERR(tdev->dev))
47294 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47295 index 3675020..e80d92c 100644
47296 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47297 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47298 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47299
47300 static int solo_sysfs_init(struct solo_dev *solo_dev)
47301 {
47302 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47303 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47304 struct device *dev = &solo_dev->dev;
47305 const char *driver;
47306 int i;
47307 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47308 index 3335941..2b26186 100644
47309 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47310 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47311 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47312
47313 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47314 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47315 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47316 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47317 if (p2m_id < 0)
47318 p2m_id = -p2m_id;
47319 }
47320 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47321 index 6f91d2e..3f011d2 100644
47322 --- a/drivers/staging/media/solo6x10/solo6x10.h
47323 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47324 @@ -238,7 +238,7 @@ struct solo_dev {
47325
47326 /* P2M DMA Engine */
47327 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47328 - atomic_t p2m_count;
47329 + atomic_unchecked_t p2m_count;
47330 int p2m_jiffies;
47331 unsigned int p2m_timeouts;
47332
47333 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47334 index 34afc16..ffe44dd 100644
47335 --- a/drivers/staging/octeon/ethernet-rx.c
47336 +++ b/drivers/staging/octeon/ethernet-rx.c
47337 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47338 /* Increment RX stats for virtual ports */
47339 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47340 #ifdef CONFIG_64BIT
47341 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47342 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47343 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47344 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47345 #else
47346 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47347 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47348 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47349 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47350 #endif
47351 }
47352 netif_receive_skb(skb);
47353 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47354 dev->name);
47355 */
47356 #ifdef CONFIG_64BIT
47357 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47358 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47359 #else
47360 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47361 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47362 #endif
47363 dev_kfree_skb_irq(skb);
47364 }
47365 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47366 index c3a90e7..023619a 100644
47367 --- a/drivers/staging/octeon/ethernet.c
47368 +++ b/drivers/staging/octeon/ethernet.c
47369 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47370 * since the RX tasklet also increments it.
47371 */
47372 #ifdef CONFIG_64BIT
47373 - atomic64_add(rx_status.dropped_packets,
47374 - (atomic64_t *)&priv->stats.rx_dropped);
47375 + atomic64_add_unchecked(rx_status.dropped_packets,
47376 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47377 #else
47378 - atomic_add(rx_status.dropped_packets,
47379 - (atomic_t *)&priv->stats.rx_dropped);
47380 + atomic_add_unchecked(rx_status.dropped_packets,
47381 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47382 #endif
47383 }
47384
47385 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47386 index dc23395..cf7e9b1 100644
47387 --- a/drivers/staging/rtl8712/rtl871x_io.h
47388 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47389 @@ -108,7 +108,7 @@ struct _io_ops {
47390 u8 *pmem);
47391 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47392 u8 *pmem);
47393 -};
47394 +} __no_const;
47395
47396 struct io_req {
47397 struct list_head list;
47398 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47399 index 1f5088b..0e59820 100644
47400 --- a/drivers/staging/sbe-2t3e3/netdev.c
47401 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47402 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47403 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47404
47405 if (rlen)
47406 - if (copy_to_user(data, &resp, rlen))
47407 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47408 return -EFAULT;
47409
47410 return 0;
47411 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47412 index a863a98..d272795 100644
47413 --- a/drivers/staging/usbip/vhci.h
47414 +++ b/drivers/staging/usbip/vhci.h
47415 @@ -83,7 +83,7 @@ struct vhci_hcd {
47416 unsigned resuming:1;
47417 unsigned long re_timeout;
47418
47419 - atomic_t seqnum;
47420 + atomic_unchecked_t seqnum;
47421
47422 /*
47423 * NOTE:
47424 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47425 index d7974cb..d78076b 100644
47426 --- a/drivers/staging/usbip/vhci_hcd.c
47427 +++ b/drivers/staging/usbip/vhci_hcd.c
47428 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47429
47430 spin_lock(&vdev->priv_lock);
47431
47432 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47433 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47434 if (priv->seqnum == 0xffff)
47435 dev_info(&urb->dev->dev, "seqnum max\n");
47436
47437 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47438 return -ENOMEM;
47439 }
47440
47441 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47442 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47443 if (unlink->seqnum == 0xffff)
47444 pr_info("seqnum max\n");
47445
47446 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47447 vdev->rhport = rhport;
47448 }
47449
47450 - atomic_set(&vhci->seqnum, 0);
47451 + atomic_set_unchecked(&vhci->seqnum, 0);
47452 spin_lock_init(&vhci->lock);
47453
47454 hcd->power_budget = 0; /* no limit */
47455 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47456 index d07fcb5..358e1e1 100644
47457 --- a/drivers/staging/usbip/vhci_rx.c
47458 +++ b/drivers/staging/usbip/vhci_rx.c
47459 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47460 if (!urb) {
47461 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47462 pr_info("max seqnum %d\n",
47463 - atomic_read(&the_controller->seqnum));
47464 + atomic_read_unchecked(&the_controller->seqnum));
47465 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47466 return;
47467 }
47468 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47469 index 57a08c5..5b4bb7c 100644
47470 --- a/drivers/staging/vt6655/hostap.c
47471 +++ b/drivers/staging/vt6655/hostap.c
47472 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47473 *
47474 */
47475
47476 +static net_device_ops_no_const apdev_netdev_ops;
47477 +
47478 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47479 {
47480 PSDevice apdev_priv;
47481 struct net_device *dev = pDevice->dev;
47482 int ret;
47483 - const struct net_device_ops apdev_netdev_ops = {
47484 - .ndo_start_xmit = pDevice->tx_80211,
47485 - };
47486
47487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47488
47489 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47490 *apdev_priv = *pDevice;
47491 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47492
47493 + /* only half broken now */
47494 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47495 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47496
47497 pDevice->apdev->type = ARPHRD_IEEE80211;
47498 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47499 index c699a30..b90a5fd 100644
47500 --- a/drivers/staging/vt6656/hostap.c
47501 +++ b/drivers/staging/vt6656/hostap.c
47502 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47503 *
47504 */
47505
47506 +static net_device_ops_no_const apdev_netdev_ops;
47507 +
47508 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47509 {
47510 struct vnt_private *apdev_priv;
47511 struct net_device *dev = pDevice->dev;
47512 int ret;
47513 - const struct net_device_ops apdev_netdev_ops = {
47514 - .ndo_start_xmit = pDevice->tx_80211,
47515 - };
47516
47517 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47518
47519 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47520 *apdev_priv = *pDevice;
47521 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47522
47523 + /* only half broken now */
47524 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47525 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47526
47527 pDevice->apdev->type = ARPHRD_IEEE80211;
47528 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47529 index d128ce2..fc1f9a1 100644
47530 --- a/drivers/staging/zcache/tmem.h
47531 +++ b/drivers/staging/zcache/tmem.h
47532 @@ -225,7 +225,7 @@ struct tmem_pamops {
47533 bool (*is_remote)(void *);
47534 int (*replace_in_obj)(void *, struct tmem_obj *);
47535 #endif
47536 -};
47537 +} __no_const;
47538 extern void tmem_register_pamops(struct tmem_pamops *m);
47539
47540 /* memory allocation methods provided by the host implementation */
47541 @@ -234,7 +234,7 @@ struct tmem_hostops {
47542 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47543 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47544 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47545 -};
47546 +} __no_const;
47547 extern void tmem_register_hostops(struct tmem_hostops *m);
47548
47549 /* core tmem accessor functions */
47550 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47551 index e51b09a..5ebac31 100644
47552 --- a/drivers/target/sbp/sbp_target.c
47553 +++ b/drivers/target/sbp/sbp_target.c
47554 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47555
47556 #define SESSION_MAINTENANCE_INTERVAL HZ
47557
47558 -static atomic_t login_id = ATOMIC_INIT(0);
47559 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47560
47561 static void session_maintenance_work(struct work_struct *);
47562 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47563 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47564 login->lun = se_lun;
47565 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47566 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47567 - login->login_id = atomic_inc_return(&login_id);
47568 + login->login_id = atomic_inc_return_unchecked(&login_id);
47569
47570 login->tgt_agt = sbp_target_agent_register(login);
47571 if (IS_ERR(login->tgt_agt)) {
47572 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47573 index 8f4142f..b127f7d 100644
47574 --- a/drivers/target/target_core_device.c
47575 +++ b/drivers/target/target_core_device.c
47576 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47577 spin_lock_init(&dev->se_port_lock);
47578 spin_lock_init(&dev->se_tmr_lock);
47579 spin_lock_init(&dev->qf_cmd_lock);
47580 - atomic_set(&dev->dev_ordered_id, 0);
47581 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47582 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47583 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47584 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47585 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47586 index d8e49d7..6fcfdec 100644
47587 --- a/drivers/target/target_core_transport.c
47588 +++ b/drivers/target/target_core_transport.c
47589 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47590 * Used to determine when ORDERED commands should go from
47591 * Dormant to Active status.
47592 */
47593 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47594 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47595 smp_mb__after_atomic_inc();
47596 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47597 cmd->se_ordered_id, cmd->sam_task_attr,
47598 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47599 index 33f83fe..d80f8e1 100644
47600 --- a/drivers/tty/cyclades.c
47601 +++ b/drivers/tty/cyclades.c
47602 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47603 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47604 info->port.count);
47605 #endif
47606 - info->port.count++;
47607 + atomic_inc(&info->port.count);
47608 #ifdef CY_DEBUG_COUNT
47609 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47610 - current->pid, info->port.count);
47611 + current->pid, atomic_read(&info->port.count));
47612 #endif
47613
47614 /*
47615 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47616 for (j = 0; j < cy_card[i].nports; j++) {
47617 info = &cy_card[i].ports[j];
47618
47619 - if (info->port.count) {
47620 + if (atomic_read(&info->port.count)) {
47621 /* XXX is the ldisc num worth this? */
47622 struct tty_struct *tty;
47623 struct tty_ldisc *ld;
47624 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47625 index eb255e8..f637a57 100644
47626 --- a/drivers/tty/hvc/hvc_console.c
47627 +++ b/drivers/tty/hvc/hvc_console.c
47628 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47629
47630 spin_lock_irqsave(&hp->port.lock, flags);
47631 /* Check and then increment for fast path open. */
47632 - if (hp->port.count++ > 0) {
47633 + if (atomic_inc_return(&hp->port.count) > 1) {
47634 spin_unlock_irqrestore(&hp->port.lock, flags);
47635 hvc_kick();
47636 return 0;
47637 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47638
47639 spin_lock_irqsave(&hp->port.lock, flags);
47640
47641 - if (--hp->port.count == 0) {
47642 + if (atomic_dec_return(&hp->port.count) == 0) {
47643 spin_unlock_irqrestore(&hp->port.lock, flags);
47644 /* We are done with the tty pointer now. */
47645 tty_port_tty_set(&hp->port, NULL);
47646 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47647 */
47648 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47649 } else {
47650 - if (hp->port.count < 0)
47651 + if (atomic_read(&hp->port.count) < 0)
47652 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47653 - hp->vtermno, hp->port.count);
47654 + hp->vtermno, atomic_read(&hp->port.count));
47655 spin_unlock_irqrestore(&hp->port.lock, flags);
47656 }
47657 }
47658 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47659 * open->hangup case this can be called after the final close so prevent
47660 * that from happening for now.
47661 */
47662 - if (hp->port.count <= 0) {
47663 + if (atomic_read(&hp->port.count) <= 0) {
47664 spin_unlock_irqrestore(&hp->port.lock, flags);
47665 return;
47666 }
47667
47668 - hp->port.count = 0;
47669 + atomic_set(&hp->port.count, 0);
47670 spin_unlock_irqrestore(&hp->port.lock, flags);
47671 tty_port_tty_set(&hp->port, NULL);
47672
47673 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47674 return -EPIPE;
47675
47676 /* FIXME what's this (unprotected) check for? */
47677 - if (hp->port.count <= 0)
47678 + if (atomic_read(&hp->port.count) <= 0)
47679 return -EIO;
47680
47681 spin_lock_irqsave(&hp->lock, flags);
47682 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47683 index 81e939e..95ead10 100644
47684 --- a/drivers/tty/hvc/hvcs.c
47685 +++ b/drivers/tty/hvc/hvcs.c
47686 @@ -83,6 +83,7 @@
47687 #include <asm/hvcserver.h>
47688 #include <asm/uaccess.h>
47689 #include <asm/vio.h>
47690 +#include <asm/local.h>
47691
47692 /*
47693 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47694 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47695
47696 spin_lock_irqsave(&hvcsd->lock, flags);
47697
47698 - if (hvcsd->port.count > 0) {
47699 + if (atomic_read(&hvcsd->port.count) > 0) {
47700 spin_unlock_irqrestore(&hvcsd->lock, flags);
47701 printk(KERN_INFO "HVCS: vterm state unchanged. "
47702 "The hvcs device node is still in use.\n");
47703 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47704 }
47705 }
47706
47707 - hvcsd->port.count = 0;
47708 + atomic_set(&hvcsd->port.count, 0);
47709 hvcsd->port.tty = tty;
47710 tty->driver_data = hvcsd;
47711
47712 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47713 unsigned long flags;
47714
47715 spin_lock_irqsave(&hvcsd->lock, flags);
47716 - hvcsd->port.count++;
47717 + atomic_inc(&hvcsd->port.count);
47718 hvcsd->todo_mask |= HVCS_SCHED_READ;
47719 spin_unlock_irqrestore(&hvcsd->lock, flags);
47720
47721 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47722 hvcsd = tty->driver_data;
47723
47724 spin_lock_irqsave(&hvcsd->lock, flags);
47725 - if (--hvcsd->port.count == 0) {
47726 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47727
47728 vio_disable_interrupts(hvcsd->vdev);
47729
47730 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47731
47732 free_irq(irq, hvcsd);
47733 return;
47734 - } else if (hvcsd->port.count < 0) {
47735 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47736 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47737 " is missmanaged.\n",
47738 - hvcsd->vdev->unit_address, hvcsd->port.count);
47739 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47740 }
47741
47742 spin_unlock_irqrestore(&hvcsd->lock, flags);
47743 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47744
47745 spin_lock_irqsave(&hvcsd->lock, flags);
47746 /* Preserve this so that we know how many kref refs to put */
47747 - temp_open_count = hvcsd->port.count;
47748 + temp_open_count = atomic_read(&hvcsd->port.count);
47749
47750 /*
47751 * Don't kref put inside the spinlock because the destruction
47752 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47753 tty->driver_data = NULL;
47754 hvcsd->port.tty = NULL;
47755
47756 - hvcsd->port.count = 0;
47757 + atomic_set(&hvcsd->port.count, 0);
47758
47759 /* This will drop any buffered data on the floor which is OK in a hangup
47760 * scenario. */
47761 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47762 * the middle of a write operation? This is a crummy place to do this
47763 * but we want to keep it all in the spinlock.
47764 */
47765 - if (hvcsd->port.count <= 0) {
47766 + if (atomic_read(&hvcsd->port.count) <= 0) {
47767 spin_unlock_irqrestore(&hvcsd->lock, flags);
47768 return -ENODEV;
47769 }
47770 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47771 {
47772 struct hvcs_struct *hvcsd = tty->driver_data;
47773
47774 - if (!hvcsd || hvcsd->port.count <= 0)
47775 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47776 return 0;
47777
47778 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47779 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47780 index 4190199..48f2920 100644
47781 --- a/drivers/tty/hvc/hvsi.c
47782 +++ b/drivers/tty/hvc/hvsi.c
47783 @@ -85,7 +85,7 @@ struct hvsi_struct {
47784 int n_outbuf;
47785 uint32_t vtermno;
47786 uint32_t virq;
47787 - atomic_t seqno; /* HVSI packet sequence number */
47788 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47789 uint16_t mctrl;
47790 uint8_t state; /* HVSI protocol state */
47791 uint8_t flags;
47792 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47793
47794 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47795 packet.hdr.len = sizeof(struct hvsi_query_response);
47796 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47797 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47798 packet.verb = VSV_SEND_VERSION_NUMBER;
47799 packet.u.version = HVSI_VERSION;
47800 packet.query_seqno = query_seqno+1;
47801 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47802
47803 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47804 packet.hdr.len = sizeof(struct hvsi_query);
47805 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47806 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47807 packet.verb = verb;
47808
47809 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47810 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47811 int wrote;
47812
47813 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47814 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47815 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47816 packet.hdr.len = sizeof(struct hvsi_control);
47817 packet.verb = VSV_SET_MODEM_CTL;
47818 packet.mask = HVSI_TSDTR;
47819 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47820 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47821
47822 packet.hdr.type = VS_DATA_PACKET_HEADER;
47823 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47824 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47825 packet.hdr.len = count + sizeof(struct hvsi_header);
47826 memcpy(&packet.data, buf, count);
47827
47828 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47829 struct hvsi_control packet __ALIGNED__;
47830
47831 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47832 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47833 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47834 packet.hdr.len = 6;
47835 packet.verb = VSV_CLOSE_PROTOCOL;
47836
47837 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47838 index ac27671..0f627ee 100644
47839 --- a/drivers/tty/hvc/hvsi_lib.c
47840 +++ b/drivers/tty/hvc/hvsi_lib.c
47841 @@ -9,7 +9,7 @@
47842
47843 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47844 {
47845 - packet->seqno = atomic_inc_return(&pv->seqno);
47846 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47847
47848 /* Assumes that always succeeds, works in practice */
47849 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47850 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47851
47852 /* Reset state */
47853 pv->established = 0;
47854 - atomic_set(&pv->seqno, 0);
47855 + atomic_set_unchecked(&pv->seqno, 0);
47856
47857 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47858
47859 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47860 pv->mctrl_update = 0;
47861 q.hdr.type = VS_QUERY_PACKET_HEADER;
47862 q.hdr.len = sizeof(struct hvsi_query);
47863 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47864 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47865 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47866 rc = hvsi_send_packet(pv, &q.hdr);
47867 if (rc <= 0) {
47868 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47869 index 8fd72ff..34a0bed 100644
47870 --- a/drivers/tty/ipwireless/tty.c
47871 +++ b/drivers/tty/ipwireless/tty.c
47872 @@ -29,6 +29,7 @@
47873 #include <linux/tty_driver.h>
47874 #include <linux/tty_flip.h>
47875 #include <linux/uaccess.h>
47876 +#include <asm/local.h>
47877
47878 #include "tty.h"
47879 #include "network.h"
47880 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47881 mutex_unlock(&tty->ipw_tty_mutex);
47882 return -ENODEV;
47883 }
47884 - if (tty->port.count == 0)
47885 + if (atomic_read(&tty->port.count) == 0)
47886 tty->tx_bytes_queued = 0;
47887
47888 - tty->port.count++;
47889 + atomic_inc(&tty->port.count);
47890
47891 tty->port.tty = linux_tty;
47892 linux_tty->driver_data = tty;
47893 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47894
47895 static void do_ipw_close(struct ipw_tty *tty)
47896 {
47897 - tty->port.count--;
47898 -
47899 - if (tty->port.count == 0) {
47900 + if (atomic_dec_return(&tty->port.count) == 0) {
47901 struct tty_struct *linux_tty = tty->port.tty;
47902
47903 if (linux_tty != NULL) {
47904 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47905 return;
47906
47907 mutex_lock(&tty->ipw_tty_mutex);
47908 - if (tty->port.count == 0) {
47909 + if (atomic_read(&tty->port.count) == 0) {
47910 mutex_unlock(&tty->ipw_tty_mutex);
47911 return;
47912 }
47913 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47914
47915 mutex_lock(&tty->ipw_tty_mutex);
47916
47917 - if (!tty->port.count) {
47918 + if (!atomic_read(&tty->port.count)) {
47919 mutex_unlock(&tty->ipw_tty_mutex);
47920 return;
47921 }
47922 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47923 return -ENODEV;
47924
47925 mutex_lock(&tty->ipw_tty_mutex);
47926 - if (!tty->port.count) {
47927 + if (!atomic_read(&tty->port.count)) {
47928 mutex_unlock(&tty->ipw_tty_mutex);
47929 return -EINVAL;
47930 }
47931 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47932 if (!tty)
47933 return -ENODEV;
47934
47935 - if (!tty->port.count)
47936 + if (!atomic_read(&tty->port.count))
47937 return -EINVAL;
47938
47939 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47940 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47941 if (!tty)
47942 return 0;
47943
47944 - if (!tty->port.count)
47945 + if (!atomic_read(&tty->port.count))
47946 return 0;
47947
47948 return tty->tx_bytes_queued;
47949 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47950 if (!tty)
47951 return -ENODEV;
47952
47953 - if (!tty->port.count)
47954 + if (!atomic_read(&tty->port.count))
47955 return -EINVAL;
47956
47957 return get_control_lines(tty);
47958 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47959 if (!tty)
47960 return -ENODEV;
47961
47962 - if (!tty->port.count)
47963 + if (!atomic_read(&tty->port.count))
47964 return -EINVAL;
47965
47966 return set_control_lines(tty, set, clear);
47967 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47968 if (!tty)
47969 return -ENODEV;
47970
47971 - if (!tty->port.count)
47972 + if (!atomic_read(&tty->port.count))
47973 return -EINVAL;
47974
47975 /* FIXME: Exactly how is the tty object locked here .. */
47976 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47977 * are gone */
47978 mutex_lock(&ttyj->ipw_tty_mutex);
47979 }
47980 - while (ttyj->port.count)
47981 + while (atomic_read(&ttyj->port.count))
47982 do_ipw_close(ttyj);
47983 ipwireless_disassociate_network_ttys(network,
47984 ttyj->channel_idx);
47985 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47986 index 1deaca4..c8582d4 100644
47987 --- a/drivers/tty/moxa.c
47988 +++ b/drivers/tty/moxa.c
47989 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47990 }
47991
47992 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47993 - ch->port.count++;
47994 + atomic_inc(&ch->port.count);
47995 tty->driver_data = ch;
47996 tty_port_tty_set(&ch->port, tty);
47997 mutex_lock(&ch->port.mutex);
47998 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47999 index 6422390..49003ac8 100644
48000 --- a/drivers/tty/n_gsm.c
48001 +++ b/drivers/tty/n_gsm.c
48002 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48003 spin_lock_init(&dlci->lock);
48004 mutex_init(&dlci->mutex);
48005 dlci->fifo = &dlci->_fifo;
48006 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48007 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48008 kfree(dlci);
48009 return NULL;
48010 }
48011 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48012 struct gsm_dlci *dlci = tty->driver_data;
48013 struct tty_port *port = &dlci->port;
48014
48015 - port->count++;
48016 + atomic_inc(&port->count);
48017 dlci_get(dlci);
48018 dlci_get(dlci->gsm->dlci[0]);
48019 mux_get(dlci->gsm);
48020 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48021 index 4bf0fc0..433bd58 100644
48022 --- a/drivers/tty/n_tty.c
48023 +++ b/drivers/tty/n_tty.c
48024 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48025 {
48026 *ops = tty_ldisc_N_TTY;
48027 ops->owner = NULL;
48028 - ops->refcount = ops->flags = 0;
48029 + atomic_set(&ops->refcount, 0);
48030 + ops->flags = 0;
48031 }
48032 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48033 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48034 index abfd990..5ab5da9 100644
48035 --- a/drivers/tty/pty.c
48036 +++ b/drivers/tty/pty.c
48037 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
48038 panic("Couldn't register Unix98 pts driver");
48039
48040 /* Now create the /dev/ptmx special device */
48041 + pax_open_kernel();
48042 tty_default_fops(&ptmx_fops);
48043 - ptmx_fops.open = ptmx_open;
48044 + *(void **)&ptmx_fops.open = ptmx_open;
48045 + pax_close_kernel();
48046
48047 cdev_init(&ptmx_cdev, &ptmx_fops);
48048 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48049 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48050 index 354564e..fe50d9a 100644
48051 --- a/drivers/tty/rocket.c
48052 +++ b/drivers/tty/rocket.c
48053 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48054 tty->driver_data = info;
48055 tty_port_tty_set(port, tty);
48056
48057 - if (port->count++ == 0) {
48058 + if (atomic_inc_return(&port->count) == 1) {
48059 atomic_inc(&rp_num_ports_open);
48060
48061 #ifdef ROCKET_DEBUG_OPEN
48062 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48063 #endif
48064 }
48065 #ifdef ROCKET_DEBUG_OPEN
48066 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48067 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48068 #endif
48069
48070 /*
48071 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48072 spin_unlock_irqrestore(&info->port.lock, flags);
48073 return;
48074 }
48075 - if (info->port.count)
48076 + if (atomic_read(&info->port.count))
48077 atomic_dec(&rp_num_ports_open);
48078 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48079 spin_unlock_irqrestore(&info->port.lock, flags);
48080 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48081 index e2520ab..034e20b 100644
48082 --- a/drivers/tty/serial/ioc4_serial.c
48083 +++ b/drivers/tty/serial/ioc4_serial.c
48084 @@ -437,7 +437,7 @@ struct ioc4_soft {
48085 } is_intr_info[MAX_IOC4_INTR_ENTS];
48086
48087 /* Number of entries active in the above array */
48088 - atomic_t is_num_intrs;
48089 + atomic_unchecked_t is_num_intrs;
48090 } is_intr_type[IOC4_NUM_INTR_TYPES];
48091
48092 /* is_ir_lock must be held while
48093 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48094 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48095 || (type == IOC4_OTHER_INTR_TYPE)));
48096
48097 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48098 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48099 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48100
48101 /* Save off the lower level interrupt handler */
48102 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48103
48104 soft = arg;
48105 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48106 - num_intrs = (int)atomic_read(
48107 + num_intrs = (int)atomic_read_unchecked(
48108 &soft->is_intr_type[intr_type].is_num_intrs);
48109
48110 this_mir = this_ir = pending_intrs(soft, intr_type);
48111 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48112 index 1002054..dd644a8 100644
48113 --- a/drivers/tty/serial/kgdboc.c
48114 +++ b/drivers/tty/serial/kgdboc.c
48115 @@ -24,8 +24,9 @@
48116 #define MAX_CONFIG_LEN 40
48117
48118 static struct kgdb_io kgdboc_io_ops;
48119 +static struct kgdb_io kgdboc_io_ops_console;
48120
48121 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48122 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48123 static int configured = -1;
48124
48125 static char config[MAX_CONFIG_LEN];
48126 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48127 kgdboc_unregister_kbd();
48128 if (configured == 1)
48129 kgdb_unregister_io_module(&kgdboc_io_ops);
48130 + else if (configured == 2)
48131 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48132 }
48133
48134 static int configure_kgdboc(void)
48135 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48136 int err;
48137 char *cptr = config;
48138 struct console *cons;
48139 + int is_console = 0;
48140
48141 err = kgdboc_option_setup(config);
48142 if (err || !strlen(config) || isspace(config[0]))
48143 goto noconfig;
48144
48145 err = -ENODEV;
48146 - kgdboc_io_ops.is_console = 0;
48147 kgdb_tty_driver = NULL;
48148
48149 kgdboc_use_kms = 0;
48150 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48151 int idx;
48152 if (cons->device && cons->device(cons, &idx) == p &&
48153 idx == tty_line) {
48154 - kgdboc_io_ops.is_console = 1;
48155 + is_console = 1;
48156 break;
48157 }
48158 cons = cons->next;
48159 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48160 kgdb_tty_line = tty_line;
48161
48162 do_register:
48163 - err = kgdb_register_io_module(&kgdboc_io_ops);
48164 + if (is_console) {
48165 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48166 + configured = 2;
48167 + } else {
48168 + err = kgdb_register_io_module(&kgdboc_io_ops);
48169 + configured = 1;
48170 + }
48171 if (err)
48172 goto noconfig;
48173
48174 @@ -205,8 +214,6 @@ do_register:
48175 if (err)
48176 goto nmi_con_failed;
48177
48178 - configured = 1;
48179 -
48180 return 0;
48181
48182 nmi_con_failed:
48183 @@ -223,7 +230,7 @@ noconfig:
48184 static int __init init_kgdboc(void)
48185 {
48186 /* Already configured? */
48187 - if (configured == 1)
48188 + if (configured >= 1)
48189 return 0;
48190
48191 return configure_kgdboc();
48192 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48193 if (config[len - 1] == '\n')
48194 config[len - 1] = '\0';
48195
48196 - if (configured == 1)
48197 + if (configured >= 1)
48198 cleanup_kgdboc();
48199
48200 /* Go and configure with the new params. */
48201 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48202 .post_exception = kgdboc_post_exp_handler,
48203 };
48204
48205 +static struct kgdb_io kgdboc_io_ops_console = {
48206 + .name = "kgdboc",
48207 + .read_char = kgdboc_get_char,
48208 + .write_char = kgdboc_put_char,
48209 + .pre_exception = kgdboc_pre_exp_handler,
48210 + .post_exception = kgdboc_post_exp_handler,
48211 + .is_console = 1
48212 +};
48213 +
48214 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48215 /* This is only available if kgdboc is a built in for early debugging */
48216 static int __init kgdboc_early_init(char *opt)
48217 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48218 index 2c6cfb3..048274e 100644
48219 --- a/drivers/tty/serial/msm_serial.c
48220 +++ b/drivers/tty/serial/msm_serial.c
48221 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48222 .cons = MSM_CONSOLE,
48223 };
48224
48225 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48226 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48227
48228 static int __init msm_serial_probe(struct platform_device *pdev)
48229 {
48230 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48231 int irq;
48232
48233 if (pdev->id == -1)
48234 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48235 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48236
48237 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48238 return -ENXIO;
48239 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48240 index 376079b..d8de7aa 100644
48241 --- a/drivers/tty/serial/samsung.c
48242 +++ b/drivers/tty/serial/samsung.c
48243 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48244 }
48245 }
48246
48247 +static int s3c64xx_serial_startup(struct uart_port *port);
48248 static int s3c24xx_serial_startup(struct uart_port *port)
48249 {
48250 struct s3c24xx_uart_port *ourport = to_ourport(port);
48251 int ret;
48252
48253 + /* Startup sequence is different for s3c64xx and higher SoC's */
48254 + if (s3c24xx_serial_has_interrupt_mask(port))
48255 + return s3c64xx_serial_startup(port);
48256 +
48257 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48258 port->mapbase, port->membase);
48259
48260 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48261 /* setup info for port */
48262 port->dev = &platdev->dev;
48263
48264 - /* Startup sequence is different for s3c64xx and higher SoC's */
48265 - if (s3c24xx_serial_has_interrupt_mask(port))
48266 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48267 -
48268 port->uartclk = 1;
48269
48270 if (cfg->uart_flags & UPF_CONS_FLOW) {
48271 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48272 index 28cdd28..56f1d60 100644
48273 --- a/drivers/tty/serial/serial_core.c
48274 +++ b/drivers/tty/serial/serial_core.c
48275 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48276 uart_flush_buffer(tty);
48277 uart_shutdown(tty, state);
48278 spin_lock_irqsave(&port->lock, flags);
48279 - port->count = 0;
48280 + atomic_set(&port->count, 0);
48281 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48282 spin_unlock_irqrestore(&port->lock, flags);
48283 tty_port_tty_set(port, NULL);
48284 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48285 goto end;
48286 }
48287
48288 - port->count++;
48289 + atomic_inc(&port->count);
48290 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48291 retval = -ENXIO;
48292 goto err_dec_count;
48293 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48294 /*
48295 * Make sure the device is in D0 state.
48296 */
48297 - if (port->count == 1)
48298 + if (atomic_read(&port->count) == 1)
48299 uart_change_pm(state, UART_PM_STATE_ON);
48300
48301 /*
48302 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48303 end:
48304 return retval;
48305 err_dec_count:
48306 - port->count--;
48307 + atomic_inc(&port->count);
48308 mutex_unlock(&port->mutex);
48309 goto end;
48310 }
48311 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48312 index 8eaf1ab..85c030d 100644
48313 --- a/drivers/tty/synclink.c
48314 +++ b/drivers/tty/synclink.c
48315 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48316
48317 if (debug_level >= DEBUG_LEVEL_INFO)
48318 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48319 - __FILE__,__LINE__, info->device_name, info->port.count);
48320 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48321
48322 if (tty_port_close_start(&info->port, tty, filp) == 0)
48323 goto cleanup;
48324 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48325 cleanup:
48326 if (debug_level >= DEBUG_LEVEL_INFO)
48327 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48328 - tty->driver->name, info->port.count);
48329 + tty->driver->name, atomic_read(&info->port.count));
48330
48331 } /* end of mgsl_close() */
48332
48333 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48334
48335 mgsl_flush_buffer(tty);
48336 shutdown(info);
48337 -
48338 - info->port.count = 0;
48339 +
48340 + atomic_set(&info->port.count, 0);
48341 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48342 info->port.tty = NULL;
48343
48344 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48345
48346 if (debug_level >= DEBUG_LEVEL_INFO)
48347 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48348 - __FILE__,__LINE__, tty->driver->name, port->count );
48349 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48350
48351 spin_lock_irqsave(&info->irq_spinlock, flags);
48352 if (!tty_hung_up_p(filp)) {
48353 extra_count = true;
48354 - port->count--;
48355 + atomic_dec(&port->count);
48356 }
48357 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48358 port->blocked_open++;
48359 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48360
48361 if (debug_level >= DEBUG_LEVEL_INFO)
48362 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48363 - __FILE__,__LINE__, tty->driver->name, port->count );
48364 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48365
48366 tty_unlock(tty);
48367 schedule();
48368 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48369
48370 /* FIXME: Racy on hangup during close wait */
48371 if (extra_count)
48372 - port->count++;
48373 + atomic_inc(&port->count);
48374 port->blocked_open--;
48375
48376 if (debug_level >= DEBUG_LEVEL_INFO)
48377 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48378 - __FILE__,__LINE__, tty->driver->name, port->count );
48379 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48380
48381 if (!retval)
48382 port->flags |= ASYNC_NORMAL_ACTIVE;
48383 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48384
48385 if (debug_level >= DEBUG_LEVEL_INFO)
48386 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48387 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48388 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48389
48390 /* If port is closing, signal caller to try again */
48391 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48392 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48393 spin_unlock_irqrestore(&info->netlock, flags);
48394 goto cleanup;
48395 }
48396 - info->port.count++;
48397 + atomic_inc(&info->port.count);
48398 spin_unlock_irqrestore(&info->netlock, flags);
48399
48400 - if (info->port.count == 1) {
48401 + if (atomic_read(&info->port.count) == 1) {
48402 /* 1st open on this device, init hardware */
48403 retval = startup(info);
48404 if (retval < 0)
48405 @@ -3446,8 +3446,8 @@ cleanup:
48406 if (retval) {
48407 if (tty->count == 1)
48408 info->port.tty = NULL; /* tty layer will release tty struct */
48409 - if(info->port.count)
48410 - info->port.count--;
48411 + if (atomic_read(&info->port.count))
48412 + atomic_dec(&info->port.count);
48413 }
48414
48415 return retval;
48416 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48417 unsigned short new_crctype;
48418
48419 /* return error if TTY interface open */
48420 - if (info->port.count)
48421 + if (atomic_read(&info->port.count))
48422 return -EBUSY;
48423
48424 switch (encoding)
48425 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48426
48427 /* arbitrate between network and tty opens */
48428 spin_lock_irqsave(&info->netlock, flags);
48429 - if (info->port.count != 0 || info->netcount != 0) {
48430 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48431 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48432 spin_unlock_irqrestore(&info->netlock, flags);
48433 return -EBUSY;
48434 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48435 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48436
48437 /* return error if TTY interface open */
48438 - if (info->port.count)
48439 + if (atomic_read(&info->port.count))
48440 return -EBUSY;
48441
48442 if (cmd != SIOCWANDEV)
48443 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48444 index 1abf946..1ee34fc 100644
48445 --- a/drivers/tty/synclink_gt.c
48446 +++ b/drivers/tty/synclink_gt.c
48447 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48448 tty->driver_data = info;
48449 info->port.tty = tty;
48450
48451 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48452 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48453
48454 /* If port is closing, signal caller to try again */
48455 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48456 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48457 mutex_unlock(&info->port.mutex);
48458 goto cleanup;
48459 }
48460 - info->port.count++;
48461 + atomic_inc(&info->port.count);
48462 spin_unlock_irqrestore(&info->netlock, flags);
48463
48464 - if (info->port.count == 1) {
48465 + if (atomic_read(&info->port.count) == 1) {
48466 /* 1st open on this device, init hardware */
48467 retval = startup(info);
48468 if (retval < 0) {
48469 @@ -715,8 +715,8 @@ cleanup:
48470 if (retval) {
48471 if (tty->count == 1)
48472 info->port.tty = NULL; /* tty layer will release tty struct */
48473 - if(info->port.count)
48474 - info->port.count--;
48475 + if(atomic_read(&info->port.count))
48476 + atomic_dec(&info->port.count);
48477 }
48478
48479 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48480 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48481
48482 if (sanity_check(info, tty->name, "close"))
48483 return;
48484 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48485 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48486
48487 if (tty_port_close_start(&info->port, tty, filp) == 0)
48488 goto cleanup;
48489 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48490 tty_port_close_end(&info->port, tty);
48491 info->port.tty = NULL;
48492 cleanup:
48493 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48494 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48495 }
48496
48497 static void hangup(struct tty_struct *tty)
48498 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48499 shutdown(info);
48500
48501 spin_lock_irqsave(&info->port.lock, flags);
48502 - info->port.count = 0;
48503 + atomic_set(&info->port.count, 0);
48504 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48505 info->port.tty = NULL;
48506 spin_unlock_irqrestore(&info->port.lock, flags);
48507 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48508 unsigned short new_crctype;
48509
48510 /* return error if TTY interface open */
48511 - if (info->port.count)
48512 + if (atomic_read(&info->port.count))
48513 return -EBUSY;
48514
48515 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48516 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48517
48518 /* arbitrate between network and tty opens */
48519 spin_lock_irqsave(&info->netlock, flags);
48520 - if (info->port.count != 0 || info->netcount != 0) {
48521 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48522 DBGINFO(("%s hdlc_open busy\n", dev->name));
48523 spin_unlock_irqrestore(&info->netlock, flags);
48524 return -EBUSY;
48525 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48526 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48527
48528 /* return error if TTY interface open */
48529 - if (info->port.count)
48530 + if (atomic_read(&info->port.count))
48531 return -EBUSY;
48532
48533 if (cmd != SIOCWANDEV)
48534 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48535 if (port == NULL)
48536 continue;
48537 spin_lock(&port->lock);
48538 - if ((port->port.count || port->netcount) &&
48539 + if ((atomic_read(&port->port.count) || port->netcount) &&
48540 port->pending_bh && !port->bh_running &&
48541 !port->bh_requested) {
48542 DBGISR(("%s bh queued\n", port->device_name));
48543 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48544 spin_lock_irqsave(&info->lock, flags);
48545 if (!tty_hung_up_p(filp)) {
48546 extra_count = true;
48547 - port->count--;
48548 + atomic_dec(&port->count);
48549 }
48550 spin_unlock_irqrestore(&info->lock, flags);
48551 port->blocked_open++;
48552 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48553 remove_wait_queue(&port->open_wait, &wait);
48554
48555 if (extra_count)
48556 - port->count++;
48557 + atomic_inc(&port->count);
48558 port->blocked_open--;
48559
48560 if (!retval)
48561 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48562 index dc6e969..5dc8786 100644
48563 --- a/drivers/tty/synclinkmp.c
48564 +++ b/drivers/tty/synclinkmp.c
48565 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48566
48567 if (debug_level >= DEBUG_LEVEL_INFO)
48568 printk("%s(%d):%s open(), old ref count = %d\n",
48569 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48570 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48571
48572 /* If port is closing, signal caller to try again */
48573 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48574 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48575 spin_unlock_irqrestore(&info->netlock, flags);
48576 goto cleanup;
48577 }
48578 - info->port.count++;
48579 + atomic_inc(&info->port.count);
48580 spin_unlock_irqrestore(&info->netlock, flags);
48581
48582 - if (info->port.count == 1) {
48583 + if (atomic_read(&info->port.count) == 1) {
48584 /* 1st open on this device, init hardware */
48585 retval = startup(info);
48586 if (retval < 0)
48587 @@ -796,8 +796,8 @@ cleanup:
48588 if (retval) {
48589 if (tty->count == 1)
48590 info->port.tty = NULL; /* tty layer will release tty struct */
48591 - if(info->port.count)
48592 - info->port.count--;
48593 + if(atomic_read(&info->port.count))
48594 + atomic_dec(&info->port.count);
48595 }
48596
48597 return retval;
48598 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48599
48600 if (debug_level >= DEBUG_LEVEL_INFO)
48601 printk("%s(%d):%s close() entry, count=%d\n",
48602 - __FILE__,__LINE__, info->device_name, info->port.count);
48603 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48604
48605 if (tty_port_close_start(&info->port, tty, filp) == 0)
48606 goto cleanup;
48607 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48608 cleanup:
48609 if (debug_level >= DEBUG_LEVEL_INFO)
48610 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48611 - tty->driver->name, info->port.count);
48612 + tty->driver->name, atomic_read(&info->port.count));
48613 }
48614
48615 /* Called by tty_hangup() when a hangup is signaled.
48616 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48617 shutdown(info);
48618
48619 spin_lock_irqsave(&info->port.lock, flags);
48620 - info->port.count = 0;
48621 + atomic_set(&info->port.count, 0);
48622 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48623 info->port.tty = NULL;
48624 spin_unlock_irqrestore(&info->port.lock, flags);
48625 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48626 unsigned short new_crctype;
48627
48628 /* return error if TTY interface open */
48629 - if (info->port.count)
48630 + if (atomic_read(&info->port.count))
48631 return -EBUSY;
48632
48633 switch (encoding)
48634 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48635
48636 /* arbitrate between network and tty opens */
48637 spin_lock_irqsave(&info->netlock, flags);
48638 - if (info->port.count != 0 || info->netcount != 0) {
48639 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48640 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48641 spin_unlock_irqrestore(&info->netlock, flags);
48642 return -EBUSY;
48643 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48644 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48645
48646 /* return error if TTY interface open */
48647 - if (info->port.count)
48648 + if (atomic_read(&info->port.count))
48649 return -EBUSY;
48650
48651 if (cmd != SIOCWANDEV)
48652 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48653 * do not request bottom half processing if the
48654 * device is not open in a normal mode.
48655 */
48656 - if ( port && (port->port.count || port->netcount) &&
48657 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48658 port->pending_bh && !port->bh_running &&
48659 !port->bh_requested ) {
48660 if ( debug_level >= DEBUG_LEVEL_ISR )
48661 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48662
48663 if (debug_level >= DEBUG_LEVEL_INFO)
48664 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48665 - __FILE__,__LINE__, tty->driver->name, port->count );
48666 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48667
48668 spin_lock_irqsave(&info->lock, flags);
48669 if (!tty_hung_up_p(filp)) {
48670 extra_count = true;
48671 - port->count--;
48672 + atomic_dec(&port->count);
48673 }
48674 spin_unlock_irqrestore(&info->lock, flags);
48675 port->blocked_open++;
48676 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48677
48678 if (debug_level >= DEBUG_LEVEL_INFO)
48679 printk("%s(%d):%s block_til_ready() count=%d\n",
48680 - __FILE__,__LINE__, tty->driver->name, port->count );
48681 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48682
48683 tty_unlock(tty);
48684 schedule();
48685 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48686 remove_wait_queue(&port->open_wait, &wait);
48687
48688 if (extra_count)
48689 - port->count++;
48690 + atomic_inc(&port->count);
48691 port->blocked_open--;
48692
48693 if (debug_level >= DEBUG_LEVEL_INFO)
48694 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48695 - __FILE__,__LINE__, tty->driver->name, port->count );
48696 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48697
48698 if (!retval)
48699 port->flags |= ASYNC_NORMAL_ACTIVE;
48700 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48701 index d5cc3ac..3263411 100644
48702 --- a/drivers/tty/sysrq.c
48703 +++ b/drivers/tty/sysrq.c
48704 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48705 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48706 size_t count, loff_t *ppos)
48707 {
48708 - if (count) {
48709 + if (count && capable(CAP_SYS_ADMIN)) {
48710 char c;
48711
48712 if (get_user(c, buf))
48713 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48714 index 20689b9..7fd3a31 100644
48715 --- a/drivers/tty/tty_io.c
48716 +++ b/drivers/tty/tty_io.c
48717 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48718
48719 void tty_default_fops(struct file_operations *fops)
48720 {
48721 - *fops = tty_fops;
48722 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48723 }
48724
48725 /*
48726 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48727 index 1afe192..73d2c20 100644
48728 --- a/drivers/tty/tty_ldisc.c
48729 +++ b/drivers/tty/tty_ldisc.c
48730 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48731 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48732 tty_ldiscs[disc] = new_ldisc;
48733 new_ldisc->num = disc;
48734 - new_ldisc->refcount = 0;
48735 + atomic_set(&new_ldisc->refcount, 0);
48736 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48737
48738 return ret;
48739 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48740 return -EINVAL;
48741
48742 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48743 - if (tty_ldiscs[disc]->refcount)
48744 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48745 ret = -EBUSY;
48746 else
48747 tty_ldiscs[disc] = NULL;
48748 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48749 if (ldops) {
48750 ret = ERR_PTR(-EAGAIN);
48751 if (try_module_get(ldops->owner)) {
48752 - ldops->refcount++;
48753 + atomic_inc(&ldops->refcount);
48754 ret = ldops;
48755 }
48756 }
48757 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48758 unsigned long flags;
48759
48760 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48761 - ldops->refcount--;
48762 + atomic_dec(&ldops->refcount);
48763 module_put(ldops->owner);
48764 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48765 }
48766 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48767 /* unreleased reader reference(s) will cause this WARN */
48768 WARN_ON(!atomic_dec_and_test(&ld->users));
48769
48770 - ld->ops->refcount--;
48771 + atomic_dec(&ld->ops->refcount);
48772 module_put(ld->ops->owner);
48773 kfree(ld);
48774 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48775 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48776 index f597e88..b7f68ed 100644
48777 --- a/drivers/tty/tty_port.c
48778 +++ b/drivers/tty/tty_port.c
48779 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48780 unsigned long flags;
48781
48782 spin_lock_irqsave(&port->lock, flags);
48783 - port->count = 0;
48784 + atomic_set(&port->count, 0);
48785 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48786 tty = port->tty;
48787 if (tty)
48788 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48789 /* The port lock protects the port counts */
48790 spin_lock_irqsave(&port->lock, flags);
48791 if (!tty_hung_up_p(filp))
48792 - port->count--;
48793 + atomic_dec(&port->count);
48794 port->blocked_open++;
48795 spin_unlock_irqrestore(&port->lock, flags);
48796
48797 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48798 we must not mess that up further */
48799 spin_lock_irqsave(&port->lock, flags);
48800 if (!tty_hung_up_p(filp))
48801 - port->count++;
48802 + atomic_inc(&port->count);
48803 port->blocked_open--;
48804 if (retval == 0)
48805 port->flags |= ASYNC_NORMAL_ACTIVE;
48806 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48807 return 0;
48808 }
48809
48810 - if (tty->count == 1 && port->count != 1) {
48811 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48812 printk(KERN_WARNING
48813 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48814 - port->count);
48815 - port->count = 1;
48816 + atomic_read(&port->count));
48817 + atomic_set(&port->count, 1);
48818 }
48819 - if (--port->count < 0) {
48820 + if (atomic_dec_return(&port->count) < 0) {
48821 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48822 - port->count);
48823 - port->count = 0;
48824 + atomic_read(&port->count));
48825 + atomic_set(&port->count, 0);
48826 }
48827
48828 - if (port->count) {
48829 + if (atomic_read(&port->count)) {
48830 spin_unlock_irqrestore(&port->lock, flags);
48831 if (port->ops->drop)
48832 port->ops->drop(port);
48833 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48834 {
48835 spin_lock_irq(&port->lock);
48836 if (!tty_hung_up_p(filp))
48837 - ++port->count;
48838 + atomic_inc(&port->count);
48839 spin_unlock_irq(&port->lock);
48840 tty_port_tty_set(port, tty);
48841
48842 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48843 index a9af1b9a..1e08e7f 100644
48844 --- a/drivers/tty/vt/keyboard.c
48845 +++ b/drivers/tty/vt/keyboard.c
48846 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48847 kbd->kbdmode == VC_OFF) &&
48848 value != KVAL(K_SAK))
48849 return; /* SAK is allowed even in raw mode */
48850 +
48851 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48852 + {
48853 + void *func = fn_handler[value];
48854 + if (func == fn_show_state || func == fn_show_ptregs ||
48855 + func == fn_show_mem)
48856 + return;
48857 + }
48858 +#endif
48859 +
48860 fn_handler[value](vc);
48861 }
48862
48863 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48864 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48865 return -EFAULT;
48866
48867 - if (!capable(CAP_SYS_TTY_CONFIG))
48868 - perm = 0;
48869 -
48870 switch (cmd) {
48871 case KDGKBENT:
48872 /* Ensure another thread doesn't free it under us */
48873 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48874 spin_unlock_irqrestore(&kbd_event_lock, flags);
48875 return put_user(val, &user_kbe->kb_value);
48876 case KDSKBENT:
48877 + if (!capable(CAP_SYS_TTY_CONFIG))
48878 + perm = 0;
48879 +
48880 if (!perm)
48881 return -EPERM;
48882 if (!i && v == K_NOSUCHMAP) {
48883 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48884 int i, j, k;
48885 int ret;
48886
48887 - if (!capable(CAP_SYS_TTY_CONFIG))
48888 - perm = 0;
48889 -
48890 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48891 if (!kbs) {
48892 ret = -ENOMEM;
48893 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48894 kfree(kbs);
48895 return ((p && *p) ? -EOVERFLOW : 0);
48896 case KDSKBSENT:
48897 + if (!capable(CAP_SYS_TTY_CONFIG))
48898 + perm = 0;
48899 +
48900 if (!perm) {
48901 ret = -EPERM;
48902 goto reterr;
48903 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48904 index 3b96f18..026a9bf 100644
48905 --- a/drivers/uio/uio.c
48906 +++ b/drivers/uio/uio.c
48907 @@ -25,6 +25,7 @@
48908 #include <linux/kobject.h>
48909 #include <linux/cdev.h>
48910 #include <linux/uio_driver.h>
48911 +#include <asm/local.h>
48912
48913 #define UIO_MAX_DEVICES (1U << MINORBITS)
48914
48915 @@ -32,10 +33,10 @@ struct uio_device {
48916 struct module *owner;
48917 struct device *dev;
48918 int minor;
48919 - atomic_t event;
48920 + atomic_unchecked_t event;
48921 struct fasync_struct *async_queue;
48922 wait_queue_head_t wait;
48923 - int vma_count;
48924 + local_t vma_count;
48925 struct uio_info *info;
48926 struct kobject *map_dir;
48927 struct kobject *portio_dir;
48928 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48929 struct device_attribute *attr, char *buf)
48930 {
48931 struct uio_device *idev = dev_get_drvdata(dev);
48932 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48933 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48934 }
48935
48936 static struct device_attribute uio_class_attributes[] = {
48937 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48938 {
48939 struct uio_device *idev = info->uio_dev;
48940
48941 - atomic_inc(&idev->event);
48942 + atomic_inc_unchecked(&idev->event);
48943 wake_up_interruptible(&idev->wait);
48944 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48945 }
48946 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48947 }
48948
48949 listener->dev = idev;
48950 - listener->event_count = atomic_read(&idev->event);
48951 + listener->event_count = atomic_read_unchecked(&idev->event);
48952 filep->private_data = listener;
48953
48954 if (idev->info->open) {
48955 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48956 return -EIO;
48957
48958 poll_wait(filep, &idev->wait, wait);
48959 - if (listener->event_count != atomic_read(&idev->event))
48960 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48961 return POLLIN | POLLRDNORM;
48962 return 0;
48963 }
48964 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48965 do {
48966 set_current_state(TASK_INTERRUPTIBLE);
48967
48968 - event_count = atomic_read(&idev->event);
48969 + event_count = atomic_read_unchecked(&idev->event);
48970 if (event_count != listener->event_count) {
48971 if (copy_to_user(buf, &event_count, count))
48972 retval = -EFAULT;
48973 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48974 static void uio_vma_open(struct vm_area_struct *vma)
48975 {
48976 struct uio_device *idev = vma->vm_private_data;
48977 - idev->vma_count++;
48978 + local_inc(&idev->vma_count);
48979 }
48980
48981 static void uio_vma_close(struct vm_area_struct *vma)
48982 {
48983 struct uio_device *idev = vma->vm_private_data;
48984 - idev->vma_count--;
48985 + local_dec(&idev->vma_count);
48986 }
48987
48988 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48989 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
48990 idev->owner = owner;
48991 idev->info = info;
48992 init_waitqueue_head(&idev->wait);
48993 - atomic_set(&idev->event, 0);
48994 + atomic_set_unchecked(&idev->event, 0);
48995
48996 ret = uio_get_minor(idev);
48997 if (ret)
48998 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48999 index 8a7eb77..c00402f 100644
49000 --- a/drivers/usb/atm/cxacru.c
49001 +++ b/drivers/usb/atm/cxacru.c
49002 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49003 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49004 if (ret < 2)
49005 return -EINVAL;
49006 - if (index < 0 || index > 0x7f)
49007 + if (index > 0x7f)
49008 return -EINVAL;
49009 pos += tmp;
49010
49011 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49012 index 5e0d33a..cc10579 100644
49013 --- a/drivers/usb/atm/usbatm.c
49014 +++ b/drivers/usb/atm/usbatm.c
49015 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49016 if (printk_ratelimit())
49017 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49018 __func__, vpi, vci);
49019 - atomic_inc(&vcc->stats->rx_err);
49020 + atomic_inc_unchecked(&vcc->stats->rx_err);
49021 return;
49022 }
49023
49024 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49025 if (length > ATM_MAX_AAL5_PDU) {
49026 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49027 __func__, length, vcc);
49028 - atomic_inc(&vcc->stats->rx_err);
49029 + atomic_inc_unchecked(&vcc->stats->rx_err);
49030 goto out;
49031 }
49032
49033 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49034 if (sarb->len < pdu_length) {
49035 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49036 __func__, pdu_length, sarb->len, vcc);
49037 - atomic_inc(&vcc->stats->rx_err);
49038 + atomic_inc_unchecked(&vcc->stats->rx_err);
49039 goto out;
49040 }
49041
49042 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49043 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49044 __func__, vcc);
49045 - atomic_inc(&vcc->stats->rx_err);
49046 + atomic_inc_unchecked(&vcc->stats->rx_err);
49047 goto out;
49048 }
49049
49050 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49051 if (printk_ratelimit())
49052 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49053 __func__, length);
49054 - atomic_inc(&vcc->stats->rx_drop);
49055 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49056 goto out;
49057 }
49058
49059 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49060
49061 vcc->push(vcc, skb);
49062
49063 - atomic_inc(&vcc->stats->rx);
49064 + atomic_inc_unchecked(&vcc->stats->rx);
49065 out:
49066 skb_trim(sarb, 0);
49067 }
49068 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
49069 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49070
49071 usbatm_pop(vcc, skb);
49072 - atomic_inc(&vcc->stats->tx);
49073 + atomic_inc_unchecked(&vcc->stats->tx);
49074
49075 skb = skb_dequeue(&instance->sndqueue);
49076 }
49077 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49078 if (!left--)
49079 return sprintf(page,
49080 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49081 - atomic_read(&atm_dev->stats.aal5.tx),
49082 - atomic_read(&atm_dev->stats.aal5.tx_err),
49083 - atomic_read(&atm_dev->stats.aal5.rx),
49084 - atomic_read(&atm_dev->stats.aal5.rx_err),
49085 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49086 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49087 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49088 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49089 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49090 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49091
49092 if (!left--) {
49093 if (instance->disconnected)
49094 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49095 index 2a3bbdf..91d72cf 100644
49096 --- a/drivers/usb/core/devices.c
49097 +++ b/drivers/usb/core/devices.c
49098 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49099 * time it gets called.
49100 */
49101 static struct device_connect_event {
49102 - atomic_t count;
49103 + atomic_unchecked_t count;
49104 wait_queue_head_t wait;
49105 } device_event = {
49106 .count = ATOMIC_INIT(1),
49107 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49108
49109 void usbfs_conn_disc_event(void)
49110 {
49111 - atomic_add(2, &device_event.count);
49112 + atomic_add_unchecked(2, &device_event.count);
49113 wake_up(&device_event.wait);
49114 }
49115
49116 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49117
49118 poll_wait(file, &device_event.wait, wait);
49119
49120 - event_count = atomic_read(&device_event.count);
49121 + event_count = atomic_read_unchecked(&device_event.count);
49122 if (file->f_version != event_count) {
49123 file->f_version = event_count;
49124 return POLLIN | POLLRDNORM;
49125 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49126 index 014dc99..4d25fd7 100644
49127 --- a/drivers/usb/core/hcd.c
49128 +++ b/drivers/usb/core/hcd.c
49129 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49130 */
49131 usb_get_urb(urb);
49132 atomic_inc(&urb->use_count);
49133 - atomic_inc(&urb->dev->urbnum);
49134 + atomic_inc_unchecked(&urb->dev->urbnum);
49135 usbmon_urb_submit(&hcd->self, urb);
49136
49137 /* NOTE requirements on root-hub callers (usbfs and the hub
49138 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49139 urb->hcpriv = NULL;
49140 INIT_LIST_HEAD(&urb->urb_list);
49141 atomic_dec(&urb->use_count);
49142 - atomic_dec(&urb->dev->urbnum);
49143 + atomic_dec_unchecked(&urb->dev->urbnum);
49144 if (atomic_read(&urb->reject))
49145 wake_up(&usb_kill_urb_queue);
49146 usb_put_urb(urb);
49147 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49148 index 17c3785..deffb11 100644
49149 --- a/drivers/usb/core/hub.c
49150 +++ b/drivers/usb/core/hub.c
49151 @@ -27,6 +27,7 @@
49152 #include <linux/freezer.h>
49153 #include <linux/random.h>
49154 #include <linux/pm_qos.h>
49155 +#include <linux/grsecurity.h>
49156
49157 #include <asm/uaccess.h>
49158 #include <asm/byteorder.h>
49159 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49160 goto done;
49161 return;
49162 }
49163 +
49164 + if (gr_handle_new_usb())
49165 + goto done;
49166 +
49167 if (hub_is_superspeed(hub->hdev))
49168 unit_load = 150;
49169 else
49170 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49171 index e7ee1e4..1dfc9ea4 100644
49172 --- a/drivers/usb/core/message.c
49173 +++ b/drivers/usb/core/message.c
49174 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49175 * method can wait for it to complete. Since you don't have a handle on the
49176 * URB used, you can't cancel the request.
49177 */
49178 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49179 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49180 __u8 requesttype, __u16 value, __u16 index, void *data,
49181 __u16 size, int timeout)
49182 {
49183 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49184 index d9284b9..17023c7 100644
49185 --- a/drivers/usb/core/sysfs.c
49186 +++ b/drivers/usb/core/sysfs.c
49187 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49188 struct usb_device *udev;
49189
49190 udev = to_usb_device(dev);
49191 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49192 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49193 }
49194 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49195
49196 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49197 index 7dad603..350f7a9 100644
49198 --- a/drivers/usb/core/usb.c
49199 +++ b/drivers/usb/core/usb.c
49200 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49201 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49202 dev->state = USB_STATE_ATTACHED;
49203 dev->lpm_disable_count = 1;
49204 - atomic_set(&dev->urbnum, 0);
49205 + atomic_set_unchecked(&dev->urbnum, 0);
49206
49207 INIT_LIST_HEAD(&dev->ep0.urb_list);
49208 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49209 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49210 index 14d28d6..5f511ac 100644
49211 --- a/drivers/usb/dwc3/gadget.c
49212 +++ b/drivers/usb/dwc3/gadget.c
49213 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49214 if (!usb_endpoint_xfer_isoc(desc))
49215 return 0;
49216
49217 - memset(&trb_link, 0, sizeof(trb_link));
49218 -
49219 /* Link TRB for ISOC. The HWO bit is never reset */
49220 trb_st_hw = &dep->trb_pool[0];
49221
49222 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49223 index 5e29dde..eca992f 100644
49224 --- a/drivers/usb/early/ehci-dbgp.c
49225 +++ b/drivers/usb/early/ehci-dbgp.c
49226 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49227
49228 #ifdef CONFIG_KGDB
49229 static struct kgdb_io kgdbdbgp_io_ops;
49230 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49231 +static struct kgdb_io kgdbdbgp_io_ops_console;
49232 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49233 #else
49234 #define dbgp_kgdb_mode (0)
49235 #endif
49236 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49237 .write_char = kgdbdbgp_write_char,
49238 };
49239
49240 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49241 + .name = "kgdbdbgp",
49242 + .read_char = kgdbdbgp_read_char,
49243 + .write_char = kgdbdbgp_write_char,
49244 + .is_console = 1
49245 +};
49246 +
49247 static int kgdbdbgp_wait_time;
49248
49249 static int __init kgdbdbgp_parse_config(char *str)
49250 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49251 ptr++;
49252 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49253 }
49254 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49255 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49256 + if (early_dbgp_console.index != -1)
49257 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49258 + else
49259 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49260
49261 return 0;
49262 }
49263 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49264 index b369292..9f3ba40 100644
49265 --- a/drivers/usb/gadget/u_serial.c
49266 +++ b/drivers/usb/gadget/u_serial.c
49267 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49268 spin_lock_irq(&port->port_lock);
49269
49270 /* already open? Great. */
49271 - if (port->port.count) {
49272 + if (atomic_read(&port->port.count)) {
49273 status = 0;
49274 - port->port.count++;
49275 + atomic_inc(&port->port.count);
49276
49277 /* currently opening/closing? wait ... */
49278 } else if (port->openclose) {
49279 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49280 tty->driver_data = port;
49281 port->port.tty = tty;
49282
49283 - port->port.count = 1;
49284 + atomic_set(&port->port.count, 1);
49285 port->openclose = false;
49286
49287 /* if connected, start the I/O stream */
49288 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49289
49290 spin_lock_irq(&port->port_lock);
49291
49292 - if (port->port.count != 1) {
49293 - if (port->port.count == 0)
49294 + if (atomic_read(&port->port.count) != 1) {
49295 + if (atomic_read(&port->port.count) == 0)
49296 WARN_ON(1);
49297 else
49298 - --port->port.count;
49299 + atomic_dec(&port->port.count);
49300 goto exit;
49301 }
49302
49303 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49304 * and sleep if necessary
49305 */
49306 port->openclose = true;
49307 - port->port.count = 0;
49308 + atomic_set(&port->port.count, 0);
49309
49310 gser = port->port_usb;
49311 if (gser && gser->disconnect)
49312 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49313 int cond;
49314
49315 spin_lock_irq(&port->port_lock);
49316 - cond = (port->port.count == 0) && !port->openclose;
49317 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49318 spin_unlock_irq(&port->port_lock);
49319 return cond;
49320 }
49321 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49322 /* if it's already open, start I/O ... and notify the serial
49323 * protocol about open/close status (connect/disconnect).
49324 */
49325 - if (port->port.count) {
49326 + if (atomic_read(&port->port.count)) {
49327 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49328 gs_start_io(port);
49329 if (gser->connect)
49330 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49331
49332 port->port_usb = NULL;
49333 gser->ioport = NULL;
49334 - if (port->port.count > 0 || port->openclose) {
49335 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49336 wake_up_interruptible(&port->drain_wait);
49337 if (port->port.tty)
49338 tty_hangup(port->port.tty);
49339 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49340
49341 /* finally, free any unused/unusable I/O buffers */
49342 spin_lock_irqsave(&port->port_lock, flags);
49343 - if (port->port.count == 0 && !port->openclose)
49344 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49345 gs_buf_free(&port->port_write_buf);
49346 gs_free_requests(gser->out, &port->read_pool, NULL);
49347 gs_free_requests(gser->out, &port->read_queue, NULL);
49348 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49349 index ba6a5d6..f88f7f3 100644
49350 --- a/drivers/usb/misc/appledisplay.c
49351 +++ b/drivers/usb/misc/appledisplay.c
49352 @@ -83,7 +83,7 @@ struct appledisplay {
49353 spinlock_t lock;
49354 };
49355
49356 -static atomic_t count_displays = ATOMIC_INIT(0);
49357 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49358 static struct workqueue_struct *wq;
49359
49360 static void appledisplay_complete(struct urb *urb)
49361 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49362
49363 /* Register backlight device */
49364 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49365 - atomic_inc_return(&count_displays) - 1);
49366 + atomic_inc_return_unchecked(&count_displays) - 1);
49367 memset(&props, 0, sizeof(struct backlight_properties));
49368 props.type = BACKLIGHT_RAW;
49369 props.max_brightness = 0xff;
49370 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49371 index afb50ea..7b0b1cf 100644
49372 --- a/drivers/usb/serial/console.c
49373 +++ b/drivers/usb/serial/console.c
49374 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49375
49376 info->port = port;
49377
49378 - ++port->port.count;
49379 + atomic_inc(&port->port.count);
49380 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49381 if (serial->type->set_termios) {
49382 /*
49383 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49384 }
49385 /* Now that any required fake tty operations are completed restore
49386 * the tty port count */
49387 - --port->port.count;
49388 + atomic_dec(&port->port.count);
49389 /* The console is special in terms of closing the device so
49390 * indicate this port is now acting as a system console. */
49391 port->port.console = 1;
49392 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49393 free_tty:
49394 kfree(tty);
49395 reset_open_count:
49396 - port->port.count = 0;
49397 + atomic_set(&port->port.count, 0);
49398 usb_autopm_put_interface(serial->interface);
49399 error_get_interface:
49400 usb_serial_put(serial);
49401 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49402 index 75f70f0..d467e1a 100644
49403 --- a/drivers/usb/storage/usb.h
49404 +++ b/drivers/usb/storage/usb.h
49405 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49406 __u8 useProtocol;
49407 __u8 useTransport;
49408 int (*initFunction)(struct us_data *);
49409 -};
49410 +} __do_const;
49411
49412
49413 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49414 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49415 index d6bea3e..60b250e 100644
49416 --- a/drivers/usb/wusbcore/wa-hc.h
49417 +++ b/drivers/usb/wusbcore/wa-hc.h
49418 @@ -192,7 +192,7 @@ struct wahc {
49419 struct list_head xfer_delayed_list;
49420 spinlock_t xfer_list_lock;
49421 struct work_struct xfer_work;
49422 - atomic_t xfer_id_count;
49423 + atomic_unchecked_t xfer_id_count;
49424 };
49425
49426
49427 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49428 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49429 spin_lock_init(&wa->xfer_list_lock);
49430 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49431 - atomic_set(&wa->xfer_id_count, 1);
49432 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49433 }
49434
49435 /**
49436 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49437 index d3493ca..0c33b7e 100644
49438 --- a/drivers/usb/wusbcore/wa-xfer.c
49439 +++ b/drivers/usb/wusbcore/wa-xfer.c
49440 @@ -297,7 +297,7 @@ out:
49441 */
49442 static void wa_xfer_id_init(struct wa_xfer *xfer)
49443 {
49444 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49445 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49446 }
49447
49448 /*
49449 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49450 index 842f450..d1d7409 100644
49451 --- a/drivers/vfio/vfio.c
49452 +++ b/drivers/vfio/vfio.c
49453 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49454 return 0;
49455
49456 /* TODO Prevent device auto probing */
49457 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49458 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49459 iommu_group_id(group->iommu_group));
49460
49461 return 0;
49462 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49463 index 5174eba..86e764a 100644
49464 --- a/drivers/vhost/vringh.c
49465 +++ b/drivers/vhost/vringh.c
49466 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49467
49468 static inline int putu16_kern(u16 *p, u16 val)
49469 {
49470 - ACCESS_ONCE(*p) = val;
49471 + ACCESS_ONCE_RW(*p) = val;
49472 return 0;
49473 }
49474
49475 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49476 index a4dfe8c..297ddd9 100644
49477 --- a/drivers/video/aty/aty128fb.c
49478 +++ b/drivers/video/aty/aty128fb.c
49479 @@ -149,7 +149,7 @@ enum {
49480 };
49481
49482 /* Must match above enum */
49483 -static char * const r128_family[] = {
49484 +static const char * const r128_family[] = {
49485 "AGP",
49486 "PCI",
49487 "PRO AGP",
49488 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49489 index 9b0f12c..024673d 100644
49490 --- a/drivers/video/aty/atyfb_base.c
49491 +++ b/drivers/video/aty/atyfb_base.c
49492 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49493 par->accel_flags = var->accel_flags; /* hack */
49494
49495 if (var->accel_flags) {
49496 - info->fbops->fb_sync = atyfb_sync;
49497 + pax_open_kernel();
49498 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49499 + pax_close_kernel();
49500 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49501 } else {
49502 - info->fbops->fb_sync = NULL;
49503 + pax_open_kernel();
49504 + *(void **)&info->fbops->fb_sync = NULL;
49505 + pax_close_kernel();
49506 info->flags |= FBINFO_HWACCEL_DISABLED;
49507 }
49508
49509 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49510 index 95ec042..e6affdd 100644
49511 --- a/drivers/video/aty/mach64_cursor.c
49512 +++ b/drivers/video/aty/mach64_cursor.c
49513 @@ -7,6 +7,7 @@
49514 #include <linux/string.h>
49515
49516 #include <asm/io.h>
49517 +#include <asm/pgtable.h>
49518
49519 #ifdef __sparc__
49520 #include <asm/fbio.h>
49521 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49522 info->sprite.buf_align = 16; /* and 64 lines tall. */
49523 info->sprite.flags = FB_PIXMAP_IO;
49524
49525 - info->fbops->fb_cursor = atyfb_cursor;
49526 + pax_open_kernel();
49527 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49528 + pax_close_kernel();
49529
49530 return 0;
49531 }
49532 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49533 index bca6ccc..252107e 100644
49534 --- a/drivers/video/backlight/kb3886_bl.c
49535 +++ b/drivers/video/backlight/kb3886_bl.c
49536 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49537 static unsigned long kb3886bl_flags;
49538 #define KB3886BL_SUSPENDED 0x01
49539
49540 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49541 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49542 {
49543 .ident = "Sahara Touch-iT",
49544 .matches = {
49545 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49546 index 900aa4e..6d49418 100644
49547 --- a/drivers/video/fb_defio.c
49548 +++ b/drivers/video/fb_defio.c
49549 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49550
49551 BUG_ON(!fbdefio);
49552 mutex_init(&fbdefio->lock);
49553 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49554 + pax_open_kernel();
49555 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49556 + pax_close_kernel();
49557 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49558 INIT_LIST_HEAD(&fbdefio->pagelist);
49559 if (fbdefio->delay == 0) /* set a default of 1 s */
49560 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49561 page->mapping = NULL;
49562 }
49563
49564 - info->fbops->fb_mmap = NULL;
49565 + *(void **)&info->fbops->fb_mmap = NULL;
49566 mutex_destroy(&fbdefio->lock);
49567 }
49568 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49569 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49570 index 5c3960d..15cf8fc 100644
49571 --- a/drivers/video/fbcmap.c
49572 +++ b/drivers/video/fbcmap.c
49573 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49574 rc = -ENODEV;
49575 goto out;
49576 }
49577 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49578 - !info->fbops->fb_setcmap)) {
49579 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49580 rc = -EINVAL;
49581 goto out1;
49582 }
49583 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49584 index 36e1fe2..c744820 100644
49585 --- a/drivers/video/fbmem.c
49586 +++ b/drivers/video/fbmem.c
49587 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49588 image->dx += image->width + 8;
49589 }
49590 } else if (rotate == FB_ROTATE_UD) {
49591 - for (x = 0; x < num && image->dx >= 0; x++) {
49592 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49593 info->fbops->fb_imageblit(info, image);
49594 image->dx -= image->width + 8;
49595 }
49596 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49597 image->dy += image->height + 8;
49598 }
49599 } else if (rotate == FB_ROTATE_CCW) {
49600 - for (x = 0; x < num && image->dy >= 0; x++) {
49601 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49602 info->fbops->fb_imageblit(info, image);
49603 image->dy -= image->height + 8;
49604 }
49605 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49606 return -EFAULT;
49607 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49608 return -EINVAL;
49609 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49610 + if (con2fb.framebuffer >= FB_MAX)
49611 return -EINVAL;
49612 if (!registered_fb[con2fb.framebuffer])
49613 request_module("fb%d", con2fb.framebuffer);
49614 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49615 index d4d2c5f..ebbd113 100644
49616 --- a/drivers/video/hyperv_fb.c
49617 +++ b/drivers/video/hyperv_fb.c
49618 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49619 static inline int synthvid_send(struct hv_device *hdev,
49620 struct synthvid_msg *msg)
49621 {
49622 - static atomic64_t request_id = ATOMIC64_INIT(0);
49623 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49624 int ret;
49625
49626 msg->pipe_hdr.type = PIPE_MSG_DATA;
49627 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49628
49629 ret = vmbus_sendpacket(hdev->channel, msg,
49630 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49631 - atomic64_inc_return(&request_id),
49632 + atomic64_inc_return_unchecked(&request_id),
49633 VM_PKT_DATA_INBAND, 0);
49634
49635 if (ret)
49636 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49637 index 7672d2e..b56437f 100644
49638 --- a/drivers/video/i810/i810_accel.c
49639 +++ b/drivers/video/i810/i810_accel.c
49640 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49641 }
49642 }
49643 printk("ringbuffer lockup!!!\n");
49644 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49645 i810_report_error(mmio);
49646 par->dev_flags |= LOCKUP;
49647 info->pixmap.scan_align = 1;
49648 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49649 index 285d552..eafa544 100644
49650 --- a/drivers/video/logo/logo_linux_clut224.ppm
49651 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49652 @@ -1,883 +1,1123 @@
49653 P3
49654 80 80
49655 255
49656 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49657 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49658 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49659 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49660 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49661 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49667 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49668 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49669 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49670 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49671 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49672 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49678 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49679 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49680 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49681 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49682 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49683 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49684 -6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49689 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49690 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49691 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49692 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49693 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49694 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49695 -14 14 14 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49700 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49701 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49702 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49703 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49704 -50 50 50 82 82 82 58 58 58 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 6 6 6 54 54 54 86 86 86 66 66 66
49706 -38 38 38 18 18 18 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49711 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49712 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49713 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49714 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49715 -78 78 78 34 34 34 2 2 6 2 2 6 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 2 2 6 6 6 6 70 70 70
49717 -78 78 78 46 46 46 22 22 22 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49722 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49723 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49724 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49725 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49726 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49727 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49728 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49733 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49734 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49735 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49736 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49737 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49738 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49739 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49744 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49745 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49746 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49747 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49748 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49749 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49750 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49755 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49756 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49757 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49758 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49759 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49760 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49761 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49766 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49767 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49768 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49769 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49770 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49771 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49772 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49777 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49778 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49779 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49780 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49781 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49782 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49783 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49788 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49789 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49790 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49791 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49792 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49793 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49794 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49799 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49800 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49801 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49802 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49803 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49804 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49805 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49810 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49811 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49812 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49813 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49814 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49815 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49816 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49821 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49822 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49823 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49824 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49825 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49826 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49827 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49832 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49833 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49834 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49835 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49836 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49837 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49838 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49843 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49844 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49845 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49846 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49847 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49848 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49849 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49854 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49855 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49856 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49857 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49858 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49859 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49860 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49865 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49866 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49867 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49868 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49869 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49870 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49871 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49876 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49877 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49878 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49879 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49880 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49881 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49882 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49887 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49888 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49889 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49890 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49891 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49892 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49893 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49898 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49899 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49900 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49901 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49902 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49903 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49904 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49909 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49910 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49911 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49912 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49913 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49914 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49915 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49920 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49921 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49922 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49923 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49924 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49925 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49926 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49927 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49928 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49931 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49932 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49933 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49934 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49935 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49936 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49937 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49938 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49939 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
49942 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49943 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49944 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49945 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49946 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49947 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49948 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49949 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49950 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49951 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49952 -
49953 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49954 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49955 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49956 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49957 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49958 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49959 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49960 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49961 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49962 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49963 -
49964 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49965 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49966 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49967 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49968 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49969 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49970 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49971 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49972 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49973 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49974 -
49975 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49976 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49977 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49978 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49979 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49980 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49981 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49982 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49983 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49984 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49985 -
49986 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49987 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49988 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49989 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49990 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49991 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49992 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49993 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49994 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49995 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49996 -
49997 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49998 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49999 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50000 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
50001 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
50002 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50003 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50004 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50005 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50006 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50007 -
50008 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
50009 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50010 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50011 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
50012 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
50013 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50014 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50015 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
50016 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50017 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50018 -
50019 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50020 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50021 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50022 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
50023 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
50024 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50025 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50026 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
50027 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50028 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50029 -
50030 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50031 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50032 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
50033 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
50034 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
50035 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50036 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50037 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
50038 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50039 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50040 -
50041 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50042 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
50043 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
50044 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
50045 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50046 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50047 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50048 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
50049 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50050 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50051 -
50052 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50053 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
50054 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
50055 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
50056 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
50057 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
50058 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
50059 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
50060 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50061 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50062 -
50063 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50064 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
50065 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
50066 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
50067 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
50068 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
50069 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
50070 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
50071 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50072 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50073 -
50074 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50075 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50076 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50077 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50078 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50080 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50081 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50082 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50083 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50084 -
50085 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50086 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50087 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50088 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50089 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50090 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50091 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50092 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50093 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50094 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50095 -
50096 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50097 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50098 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50099 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50100 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50101 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50102 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50103 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50104 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50105 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50106 -
50107 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50108 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50109 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50110 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50111 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50112 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50113 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50114 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50115 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50118 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50119 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50120 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50121 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50122 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50123 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50124 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50125 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50126 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50129 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50130 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50131 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50132 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50133 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50134 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50135 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50136 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50137 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50140 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50141 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50142 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50143 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50144 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50145 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50146 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50147 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50148 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50151 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50152 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50153 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50154 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50155 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50156 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50158 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50159 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50162 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50163 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50164 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50165 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50166 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50167 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50168 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50169 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50170 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
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 -
50173 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50174 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50175 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50176 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50180 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50181 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50182 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50183 -
50184 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50185 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50186 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50187 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50188 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50189 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50190 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50191 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50192 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50193 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50194 -
50195 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50196 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50197 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50198 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50202 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50203 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50204 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50205 -
50206 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50207 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50208 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50209 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50210 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50212 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50213 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50214 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50215 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50216 -
50217 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50218 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50219 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50220 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50223 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50224 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50225 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50226 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50227 -
50228 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50229 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50230 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50231 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50232 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50233 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50234 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50235 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50236 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50237 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50238 -
50239 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50240 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50241 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50242 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50243 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50244 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50245 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50246 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50247 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50248 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50249 -
50250 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50251 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50252 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50253 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50254 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50255 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50257 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50258 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50259 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50260 -
50261 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50262 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50263 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50264 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50265 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50266 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50267 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50268 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50269 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50270 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50271 -
50272 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50273 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50274 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50275 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50278 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50279 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50280 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50281 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50282 -
50283 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50284 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50285 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50286 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50287 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50288 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50289 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50290 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50291 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50292 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50293 -
50294 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50295 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50296 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50297 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50298 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50299 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50301 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50302 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50303 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50304 -
50305 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50306 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50307 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50308 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50309 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50310 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50311 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50312 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50313 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50314 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50315 -
50316 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50317 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50318 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50319 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50320 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50321 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50323 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50324 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50325 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50326 -
50327 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50328 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50329 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50330 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50331 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50332 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50333 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50334 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50335 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50336 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50337 -
50338 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50339 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50340 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50341 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50342 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50343 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50344 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50345 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50346 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50347 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50348 -
50349 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50350 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50351 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50352 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50353 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50354 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50355 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50356 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50357 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50358 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50359 -
50360 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50361 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50362 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50363 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50364 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50365 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50366 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50367 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50368 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50369 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50370 -
50371 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50372 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50373 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50374 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50375 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50376 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50377 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50378 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50379 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50380 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50381 -
50382 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50383 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50384 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50385 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50386 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50387 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50388 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50389 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50390 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50391 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50392 -
50393 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50394 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50395 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50396 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50397 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50398 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50399 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50400 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50401 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50402 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50403 -
50404 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50405 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50406 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50407 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50408 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50409 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50410 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50411 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50412 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50413 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50414 -
50415 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50416 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50417 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50418 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50419 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50420 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50421 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50422 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50423 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50424 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50425 -
50426 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50427 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50428 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50429 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50430 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50431 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50432 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50433 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50434 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50435 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50436 -
50437 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50438 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50439 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50440 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50441 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50442 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50443 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50444 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50445 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50446 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50447 -
50448 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50449 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50450 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50451 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50452 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50453 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50454 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50455 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50456 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50457 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50458 -
50459 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50460 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50461 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50462 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50463 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50464 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50465 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50466 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50467 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50468 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50469 -
50470 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50471 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50472 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50473 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50474 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50475 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50476 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50477 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50478 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50479 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50480 -
50481 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50482 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50483 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50484 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50485 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50486 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50487 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50488 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50489 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50490 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50491 -
50492 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50493 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50494 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50495 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50496 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50497 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50498 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50499 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50500 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50501 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50502 -
50503 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50504 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50505 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50506 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50507 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50508 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50509 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50510 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50511 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50512 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50513 -
50514 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50515 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50516 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50517 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50518 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50519 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50520 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50521 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50522 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50523 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50524 -
50525 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50526 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50527 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50528 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50529 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50530 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50531 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50532 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50533 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50534 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50535 -
50536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50549 +4 4 4 4 4 4
50550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50563 +4 4 4 4 4 4
50564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50577 +4 4 4 4 4 4
50578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50591 +4 4 4 4 4 4
50592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50599 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50605 +4 4 4 4 4 4
50606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50613 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50619 +4 4 4 4 4 4
50620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50624 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50625 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 1 1 1 0 0 0
50630 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50631 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50633 +4 4 4 4 4 4
50634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50638 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50639 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50640 +5 5 5 4 4 4 4 4 4 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 3 3 3 0 0 0 1 1 1 6 6 6
50644 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50645 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50646 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50647 +4 4 4 4 4 4
50648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50652 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50653 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50654 +0 0 0 3 3 3 4 4 4 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 0 0 0 4 4 4 41 54 63 125 124 125
50658 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50659 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50660 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50661 +4 4 4 4 4 4
50662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50665 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50666 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50667 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50668 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
50671 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50672 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50673 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50674 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50675 +4 4 4 4 4 4
50676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50679 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50680 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50681 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50682 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50683 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50684 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50685 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50686 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50687 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50688 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50689 +4 4 4 4 4 4
50690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50693 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50694 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50695 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50696 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50697 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50698 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50699 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50700 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50701 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50702 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50703 +4 4 4 4 4 4
50704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50706 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50707 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50708 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50709 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50710 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50711 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50712 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50713 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50714 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50715 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50716 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50717 +4 4 4 4 4 4
50718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50720 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50721 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50722 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50723 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50724 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50725 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50726 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50727 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50728 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50729 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50730 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50731 +4 4 4 4 4 4
50732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50734 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50735 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50736 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50737 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50738 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50739 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50740 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50741 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50742 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50743 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50744 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50745 +4 4 4 4 4 4
50746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50748 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50749 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50750 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50751 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50752 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50753 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50754 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50755 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50756 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50757 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50758 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50759 +4 4 4 4 4 4
50760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50761 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50762 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50763 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50764 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50765 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50766 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50767 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50768 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50769 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50770 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50771 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50772 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50773 +4 4 4 4 4 4
50774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50775 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50776 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50777 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50778 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50779 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50780 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50781 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50782 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50783 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50784 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50785 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50786 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50787 +0 0 0 4 4 4
50788 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50789 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50790 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50791 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50792 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50793 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50794 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50795 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50796 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50797 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50798 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50799 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50800 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50801 +2 0 0 0 0 0
50802 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50803 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50804 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50805 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50806 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50807 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50808 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50809 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50810 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50811 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50812 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50813 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50814 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50815 +37 38 37 0 0 0
50816 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50817 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50818 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50819 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50820 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50821 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50822 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50823 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50824 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50825 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50826 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50827 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50828 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50829 +85 115 134 4 0 0
50830 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50831 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50832 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50833 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50834 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50835 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50836 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50837 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50838 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50839 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50840 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50841 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50842 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50843 +60 73 81 4 0 0
50844 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50845 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50846 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50847 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50848 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50849 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50850 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50851 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50852 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50853 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50854 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50855 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50856 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50857 +16 19 21 4 0 0
50858 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50859 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50860 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50861 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50862 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50863 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50864 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50865 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50866 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50867 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50868 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50869 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50870 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50871 +4 0 0 4 3 3
50872 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50873 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50874 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50876 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50877 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50878 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50879 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50880 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50881 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50882 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50883 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50884 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50885 +3 2 2 4 4 4
50886 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50887 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50888 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50889 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50890 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50891 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50892 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50893 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50894 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50895 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50896 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50897 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50898 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50899 +4 4 4 4 4 4
50900 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50901 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50902 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50903 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50904 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50905 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50906 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50907 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50908 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50909 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50910 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50911 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50912 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50913 +4 4 4 4 4 4
50914 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50915 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50916 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50917 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50918 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50919 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50920 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50921 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50922 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50923 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50924 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50925 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50926 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50927 +5 5 5 5 5 5
50928 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50929 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50930 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50931 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50932 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50933 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50934 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50935 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50936 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50937 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50938 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50939 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50940 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50941 +5 5 5 4 4 4
50942 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50943 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50944 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50945 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50946 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50947 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50948 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50949 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50950 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50951 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50952 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50953 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50955 +4 4 4 4 4 4
50956 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50957 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50958 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50959 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50960 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50961 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50962 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50963 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50964 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50965 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50966 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50967 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50969 +4 4 4 4 4 4
50970 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50971 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50972 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50973 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50974 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50975 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50976 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50977 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50978 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50979 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50980 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50983 +4 4 4 4 4 4
50984 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50985 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50986 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50987 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50988 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50989 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50990 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50991 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50992 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50993 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50994 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50997 +4 4 4 4 4 4
50998 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50999 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51000 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51001 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51002 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51003 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51004 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51005 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51006 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51007 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51008 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51011 +4 4 4 4 4 4
51012 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51013 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51014 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51015 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51016 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51017 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51018 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51019 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51020 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51021 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51022 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51025 +4 4 4 4 4 4
51026 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51027 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51028 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51029 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51030 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51031 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51032 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51033 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51034 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51035 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51036 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51039 +4 4 4 4 4 4
51040 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51041 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51042 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51043 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51044 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51045 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51046 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51047 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51048 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51049 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51050 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51051 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51053 +4 4 4 4 4 4
51054 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51055 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51056 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51057 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51058 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51059 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51060 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51061 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51062 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51063 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51064 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51065 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51067 +4 4 4 4 4 4
51068 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51069 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51070 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51071 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51072 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51073 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51074 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51075 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51076 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51077 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51078 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51081 +4 4 4 4 4 4
51082 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51083 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51084 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51085 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51086 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51087 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51088 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51089 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51090 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51091 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51092 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51095 +4 4 4 4 4 4
51096 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51097 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51098 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51099 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51100 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51101 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51102 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51103 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51104 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51105 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51106 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51109 +4 4 4 4 4 4
51110 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51111 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51112 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51113 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51114 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51115 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51116 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51117 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51118 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51119 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51120 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51123 +4 4 4 4 4 4
51124 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51125 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51126 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51127 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51128 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51129 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51130 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51131 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51132 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51133 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51134 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51137 +4 4 4 4 4 4
51138 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51139 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51140 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51141 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51142 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51143 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51144 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51145 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51146 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51147 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51148 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51149 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51151 +4 4 4 4 4 4
51152 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51153 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51154 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51155 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51156 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51157 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51158 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51159 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51160 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51161 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51162 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51165 +4 4 4 4 4 4
51166 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51167 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51168 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51169 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51170 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51171 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51172 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51173 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51174 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51175 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51176 +0 0 0 3 3 3 5 5 5 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 4 4 4
51179 +4 4 4 4 4 4
51180 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51181 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51182 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51183 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51184 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51185 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51186 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51187 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51188 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51189 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51190 +0 0 0 3 3 3 5 5 5 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 4 4 4
51194 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51195 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51196 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51197 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51198 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51199 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51200 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51201 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51202 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51203 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51204 +0 0 0 3 3 3 5 5 5 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
51208 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51209 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51210 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51211 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51212 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51213 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51214 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51215 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51216 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51217 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51218 +0 0 0 3 3 3 5 5 5 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
51222 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51223 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51224 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51225 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51226 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51227 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51228 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51229 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51230 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51231 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51232 +0 0 0 3 3 3 5 5 5 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
51236 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51237 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51238 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51239 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51240 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51241 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51242 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51243 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51244 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51245 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51246 +0 0 0 3 3 3 5 5 5 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
51250 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51251 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51252 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51253 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51254 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51255 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51256 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51257 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51258 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51259 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51260 +0 0 0 3 3 3 5 5 5 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
51264 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51265 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51266 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51267 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51268 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51269 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51270 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51271 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51272 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51273 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51274 +0 0 0 3 3 3 5 5 5 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
51278 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51279 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51280 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51281 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51282 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51283 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51284 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51285 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51286 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51287 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51288 +0 0 0 3 3 3 5 5 5 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
51292 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51293 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51294 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51295 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51296 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51297 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51298 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51299 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51300 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51301 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51302 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51305 +4 4 4 4 4 4
51306 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51307 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51308 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51309 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51310 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51311 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51312 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51313 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51314 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51315 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51316 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51319 +4 4 4 4 4 4
51320 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51321 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51322 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51323 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51324 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51325 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51326 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51328 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51329 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51330 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51333 +4 4 4 4 4 4
51334 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51335 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51336 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51337 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51338 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51339 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51340 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51341 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51342 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51343 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51344 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51347 +4 4 4 4 4 4
51348 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51349 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51350 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51351 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51352 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51353 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51354 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51355 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51356 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51357 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51361 +4 4 4 4 4 4
51362 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51363 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51364 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51365 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51366 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51367 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51368 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51369 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51370 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51371 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51375 +4 4 4 4 4 4
51376 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51377 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51378 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51379 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51380 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51381 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51382 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51383 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51384 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51385 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4
51390 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51391 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51392 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51393 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51394 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51395 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51396 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51397 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51398 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51399 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4
51404 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51405 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51406 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51407 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51408 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51409 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51410 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51411 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51412 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4
51418 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51419 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51420 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51421 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51422 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51423 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51424 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51425 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51426 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4
51432 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51433 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51434 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51435 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51436 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51437 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51438 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51439 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51440 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4
51446 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51447 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51448 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51449 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51450 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51451 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51452 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51453 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4
51460 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51461 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51462 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51463 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51464 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51465 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51466 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51467 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4
51474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51475 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51476 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51477 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51478 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51479 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51480 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51481 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4
51488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51489 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51490 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51491 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51492 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51493 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51494 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51495 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4
51502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51503 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51504 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51505 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51506 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51507 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51508 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51509 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4
51516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51518 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51519 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51520 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51521 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51522 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51523 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4
51530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51533 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51534 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51535 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51536 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4
51544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51547 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51548 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51549 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51550 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51562 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51563 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51564 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51575 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51576 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51577 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51578 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4
51586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51590 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51591 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51592 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4
51600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51604 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51605 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51606 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4
51614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51618 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51619 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51620 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4
51628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51632 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51633 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4
51642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51646 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51647 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4
51656 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51657 index fe92eed..106e085 100644
51658 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51659 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51660 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51661 struct mb862xxfb_par *par = info->par;
51662
51663 if (info->var.bits_per_pixel == 32) {
51664 - info->fbops->fb_fillrect = cfb_fillrect;
51665 - info->fbops->fb_copyarea = cfb_copyarea;
51666 - info->fbops->fb_imageblit = cfb_imageblit;
51667 + pax_open_kernel();
51668 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51669 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51670 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51671 + pax_close_kernel();
51672 } else {
51673 outreg(disp, GC_L0EM, 3);
51674 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51675 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51676 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51677 + pax_open_kernel();
51678 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51679 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51680 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51681 + pax_close_kernel();
51682 }
51683 outreg(draw, GDC_REG_DRAW_BASE, 0);
51684 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51685 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51686 index ff22871..b129bed 100644
51687 --- a/drivers/video/nvidia/nvidia.c
51688 +++ b/drivers/video/nvidia/nvidia.c
51689 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51690 info->fix.line_length = (info->var.xres_virtual *
51691 info->var.bits_per_pixel) >> 3;
51692 if (info->var.accel_flags) {
51693 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51694 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51695 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51696 - info->fbops->fb_sync = nvidiafb_sync;
51697 + pax_open_kernel();
51698 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51699 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51700 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51701 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51702 + pax_close_kernel();
51703 info->pixmap.scan_align = 4;
51704 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51705 info->flags |= FBINFO_READS_FAST;
51706 NVResetGraphics(info);
51707 } else {
51708 - info->fbops->fb_imageblit = cfb_imageblit;
51709 - info->fbops->fb_fillrect = cfb_fillrect;
51710 - info->fbops->fb_copyarea = cfb_copyarea;
51711 - info->fbops->fb_sync = NULL;
51712 + pax_open_kernel();
51713 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51714 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51715 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51716 + *(void **)&info->fbops->fb_sync = NULL;
51717 + pax_close_kernel();
51718 info->pixmap.scan_align = 1;
51719 info->flags |= FBINFO_HWACCEL_DISABLED;
51720 info->flags &= ~FBINFO_READS_FAST;
51721 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51722 info->pixmap.size = 8 * 1024;
51723 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51724
51725 - if (!hwcur)
51726 - info->fbops->fb_cursor = NULL;
51727 + if (!hwcur) {
51728 + pax_open_kernel();
51729 + *(void **)&info->fbops->fb_cursor = NULL;
51730 + pax_close_kernel();
51731 + }
51732
51733 info->var.accel_flags = (!noaccel);
51734
51735 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51736 index 05c2dc3..ea1f391 100644
51737 --- a/drivers/video/s1d13xxxfb.c
51738 +++ b/drivers/video/s1d13xxxfb.c
51739 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51740
51741 switch(prod_id) {
51742 case S1D13506_PROD_ID: /* activate acceleration */
51743 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51744 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51745 + pax_open_kernel();
51746 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51747 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51748 + pax_close_kernel();
51749 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51750 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51751 break;
51752 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51753 index e188ada..aac63c8 100644
51754 --- a/drivers/video/smscufx.c
51755 +++ b/drivers/video/smscufx.c
51756 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51757 fb_deferred_io_cleanup(info);
51758 kfree(info->fbdefio);
51759 info->fbdefio = NULL;
51760 - info->fbops->fb_mmap = ufx_ops_mmap;
51761 + pax_open_kernel();
51762 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51763 + pax_close_kernel();
51764 }
51765
51766 pr_debug("released /dev/fb%d user=%d count=%d",
51767 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51768 index d2e5bc3..4cb05d1 100644
51769 --- a/drivers/video/udlfb.c
51770 +++ b/drivers/video/udlfb.c
51771 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51772 dlfb_urb_completion(urb);
51773
51774 error:
51775 - atomic_add(bytes_sent, &dev->bytes_sent);
51776 - atomic_add(bytes_identical, &dev->bytes_identical);
51777 - atomic_add(width*height*2, &dev->bytes_rendered);
51778 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51779 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51780 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51781 end_cycles = get_cycles();
51782 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51783 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51784 >> 10)), /* Kcycles */
51785 &dev->cpu_kcycles_used);
51786
51787 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51788 dlfb_urb_completion(urb);
51789
51790 error:
51791 - atomic_add(bytes_sent, &dev->bytes_sent);
51792 - atomic_add(bytes_identical, &dev->bytes_identical);
51793 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51794 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51795 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51796 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51797 end_cycles = get_cycles();
51798 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51799 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51800 >> 10)), /* Kcycles */
51801 &dev->cpu_kcycles_used);
51802 }
51803 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51804 fb_deferred_io_cleanup(info);
51805 kfree(info->fbdefio);
51806 info->fbdefio = NULL;
51807 - info->fbops->fb_mmap = dlfb_ops_mmap;
51808 + pax_open_kernel();
51809 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51810 + pax_close_kernel();
51811 }
51812
51813 pr_warn("released /dev/fb%d user=%d count=%d\n",
51814 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51815 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51816 struct dlfb_data *dev = fb_info->par;
51817 return snprintf(buf, PAGE_SIZE, "%u\n",
51818 - atomic_read(&dev->bytes_rendered));
51819 + atomic_read_unchecked(&dev->bytes_rendered));
51820 }
51821
51822 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51823 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51824 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51825 struct dlfb_data *dev = fb_info->par;
51826 return snprintf(buf, PAGE_SIZE, "%u\n",
51827 - atomic_read(&dev->bytes_identical));
51828 + atomic_read_unchecked(&dev->bytes_identical));
51829 }
51830
51831 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51832 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51833 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51834 struct dlfb_data *dev = fb_info->par;
51835 return snprintf(buf, PAGE_SIZE, "%u\n",
51836 - atomic_read(&dev->bytes_sent));
51837 + atomic_read_unchecked(&dev->bytes_sent));
51838 }
51839
51840 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51841 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51842 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51843 struct dlfb_data *dev = fb_info->par;
51844 return snprintf(buf, PAGE_SIZE, "%u\n",
51845 - atomic_read(&dev->cpu_kcycles_used));
51846 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51847 }
51848
51849 static ssize_t edid_show(
51850 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51851 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51852 struct dlfb_data *dev = fb_info->par;
51853
51854 - atomic_set(&dev->bytes_rendered, 0);
51855 - atomic_set(&dev->bytes_identical, 0);
51856 - atomic_set(&dev->bytes_sent, 0);
51857 - atomic_set(&dev->cpu_kcycles_used, 0);
51858 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51859 + atomic_set_unchecked(&dev->bytes_identical, 0);
51860 + atomic_set_unchecked(&dev->bytes_sent, 0);
51861 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51862
51863 return count;
51864 }
51865 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51866 index 7aec6f3..e3b2d55 100644
51867 --- a/drivers/video/uvesafb.c
51868 +++ b/drivers/video/uvesafb.c
51869 @@ -19,6 +19,7 @@
51870 #include <linux/io.h>
51871 #include <linux/mutex.h>
51872 #include <linux/slab.h>
51873 +#include <linux/moduleloader.h>
51874 #include <video/edid.h>
51875 #include <video/uvesafb.h>
51876 #ifdef CONFIG_X86
51877 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51878 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51879 par->pmi_setpal = par->ypan = 0;
51880 } else {
51881 +
51882 +#ifdef CONFIG_PAX_KERNEXEC
51883 +#ifdef CONFIG_MODULES
51884 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51885 +#endif
51886 + if (!par->pmi_code) {
51887 + par->pmi_setpal = par->ypan = 0;
51888 + return 0;
51889 + }
51890 +#endif
51891 +
51892 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51893 + task->t.regs.edi);
51894 +
51895 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51896 + pax_open_kernel();
51897 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51898 + pax_close_kernel();
51899 +
51900 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51901 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51902 +#else
51903 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51904 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51905 +#endif
51906 +
51907 printk(KERN_INFO "uvesafb: protected mode interface info at "
51908 "%04x:%04x\n",
51909 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51910 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51911 par->ypan = ypan;
51912
51913 if (par->pmi_setpal || par->ypan) {
51914 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51915 if (__supported_pte_mask & _PAGE_NX) {
51916 par->pmi_setpal = par->ypan = 0;
51917 printk(KERN_WARNING "uvesafb: NX protection is active, "
51918 "better not use the PMI.\n");
51919 - } else {
51920 + } else
51921 +#endif
51922 uvesafb_vbe_getpmi(task, par);
51923 - }
51924 }
51925 #else
51926 /* The protected mode interface is not available on non-x86. */
51927 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51928 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51929
51930 /* Disable blanking if the user requested so. */
51931 - if (!blank)
51932 - info->fbops->fb_blank = NULL;
51933 + if (!blank) {
51934 + pax_open_kernel();
51935 + *(void **)&info->fbops->fb_blank = NULL;
51936 + pax_close_kernel();
51937 + }
51938
51939 /*
51940 * Find out how much IO memory is required for the mode with
51941 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51942 info->flags = FBINFO_FLAG_DEFAULT |
51943 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51944
51945 - if (!par->ypan)
51946 - info->fbops->fb_pan_display = NULL;
51947 + if (!par->ypan) {
51948 + pax_open_kernel();
51949 + *(void **)&info->fbops->fb_pan_display = NULL;
51950 + pax_close_kernel();
51951 + }
51952 }
51953
51954 static void uvesafb_init_mtrr(struct fb_info *info)
51955 @@ -1796,6 +1826,11 @@ out:
51956 if (par->vbe_modes)
51957 kfree(par->vbe_modes);
51958
51959 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51960 + if (par->pmi_code)
51961 + module_free_exec(NULL, par->pmi_code);
51962 +#endif
51963 +
51964 framebuffer_release(info);
51965 return err;
51966 }
51967 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51968 kfree(par->vbe_state_orig);
51969 if (par->vbe_state_saved)
51970 kfree(par->vbe_state_saved);
51971 +
51972 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51973 + if (par->pmi_code)
51974 + module_free_exec(NULL, par->pmi_code);
51975 +#endif
51976 +
51977 }
51978
51979 framebuffer_release(info);
51980 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51981 index 501b340..d80aa17 100644
51982 --- a/drivers/video/vesafb.c
51983 +++ b/drivers/video/vesafb.c
51984 @@ -9,6 +9,7 @@
51985 */
51986
51987 #include <linux/module.h>
51988 +#include <linux/moduleloader.h>
51989 #include <linux/kernel.h>
51990 #include <linux/errno.h>
51991 #include <linux/string.h>
51992 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51993 static int vram_total __initdata; /* Set total amount of memory */
51994 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51995 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51996 -static void (*pmi_start)(void) __read_mostly;
51997 -static void (*pmi_pal) (void) __read_mostly;
51998 +static void (*pmi_start)(void) __read_only;
51999 +static void (*pmi_pal) (void) __read_only;
52000 static int depth __read_mostly;
52001 static int vga_compat __read_mostly;
52002 /* --------------------------------------------------------------------- */
52003 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
52004 unsigned int size_vmode;
52005 unsigned int size_remap;
52006 unsigned int size_total;
52007 + void *pmi_code = NULL;
52008
52009 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
52010 return -ENODEV;
52011 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
52012 size_remap = size_total;
52013 vesafb_fix.smem_len = size_remap;
52014
52015 -#ifndef __i386__
52016 - screen_info.vesapm_seg = 0;
52017 -#endif
52018 -
52019 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52020 printk(KERN_WARNING
52021 "vesafb: cannot reserve video memory at 0x%lx\n",
52022 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
52023 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52024 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52025
52026 +#ifdef __i386__
52027 +
52028 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52029 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52030 + if (!pmi_code)
52031 +#elif !defined(CONFIG_PAX_KERNEXEC)
52032 + if (0)
52033 +#endif
52034 +
52035 +#endif
52036 + screen_info.vesapm_seg = 0;
52037 +
52038 if (screen_info.vesapm_seg) {
52039 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52040 - screen_info.vesapm_seg,screen_info.vesapm_off);
52041 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52042 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52043 }
52044
52045 if (screen_info.vesapm_seg < 0xc000)
52046 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
52047
52048 if (ypan || pmi_setpal) {
52049 unsigned short *pmi_base;
52050 +
52051 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52052 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52053 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52054 +
52055 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52056 + pax_open_kernel();
52057 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52058 +#else
52059 + pmi_code = pmi_base;
52060 +#endif
52061 +
52062 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52063 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52064 +
52065 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52066 + pmi_start = ktva_ktla(pmi_start);
52067 + pmi_pal = ktva_ktla(pmi_pal);
52068 + pax_close_kernel();
52069 +#endif
52070 +
52071 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52072 if (pmi_base[3]) {
52073 printk(KERN_INFO "vesafb: pmi: ports = ");
52074 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52075 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52076 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52077
52078 - if (!ypan)
52079 - info->fbops->fb_pan_display = NULL;
52080 + if (!ypan) {
52081 + pax_open_kernel();
52082 + *(void **)&info->fbops->fb_pan_display = NULL;
52083 + pax_close_kernel();
52084 + }
52085
52086 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52087 err = -ENOMEM;
52088 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52089 info->node, info->fix.id);
52090 return 0;
52091 err:
52092 +
52093 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52094 + module_free_exec(NULL, pmi_code);
52095 +#endif
52096 +
52097 if (info->screen_base)
52098 iounmap(info->screen_base);
52099 framebuffer_release(info);
52100 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52101 index 88714ae..16c2e11 100644
52102 --- a/drivers/video/via/via_clock.h
52103 +++ b/drivers/video/via/via_clock.h
52104 @@ -56,7 +56,7 @@ struct via_clock {
52105
52106 void (*set_engine_pll_state)(u8 state);
52107 void (*set_engine_pll)(struct via_pll_config config);
52108 -};
52109 +} __no_const;
52110
52111
52112 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52113 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52114 index fef20db..d28b1ab 100644
52115 --- a/drivers/xen/xenfs/xenstored.c
52116 +++ b/drivers/xen/xenfs/xenstored.c
52117 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52118 static int xsd_kva_open(struct inode *inode, struct file *file)
52119 {
52120 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52121 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52122 + NULL);
52123 +#else
52124 xen_store_interface);
52125 +#endif
52126 +
52127 if (!file->private_data)
52128 return -ENOMEM;
52129 return 0;
52130 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52131 index 9ff073f..05cef23 100644
52132 --- a/fs/9p/vfs_addr.c
52133 +++ b/fs/9p/vfs_addr.c
52134 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52135
52136 retval = v9fs_file_write_internal(inode,
52137 v9inode->writeback_fid,
52138 - (__force const char __user *)buffer,
52139 + (const char __force_user *)buffer,
52140 len, &offset, 0);
52141 if (retval > 0)
52142 retval = 0;
52143 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52144 index 25b018e..b941525 100644
52145 --- a/fs/9p/vfs_inode.c
52146 +++ b/fs/9p/vfs_inode.c
52147 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52148 void
52149 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52150 {
52151 - char *s = nd_get_link(nd);
52152 + const char *s = nd_get_link(nd);
52153
52154 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52155 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52156 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52157 index 370b24c..ff0be7b 100644
52158 --- a/fs/Kconfig.binfmt
52159 +++ b/fs/Kconfig.binfmt
52160 @@ -103,7 +103,7 @@ config HAVE_AOUT
52161
52162 config BINFMT_AOUT
52163 tristate "Kernel support for a.out and ECOFF binaries"
52164 - depends on HAVE_AOUT
52165 + depends on HAVE_AOUT && BROKEN
52166 ---help---
52167 A.out (Assembler.OUTput) is a set of formats for libraries and
52168 executables used in the earliest versions of UNIX. Linux used
52169 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52170 index 789bc25..fafaeea 100644
52171 --- a/fs/afs/inode.c
52172 +++ b/fs/afs/inode.c
52173 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52174 struct afs_vnode *vnode;
52175 struct super_block *sb;
52176 struct inode *inode;
52177 - static atomic_t afs_autocell_ino;
52178 + static atomic_unchecked_t afs_autocell_ino;
52179
52180 _enter("{%x:%u},%*.*s,",
52181 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52182 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52183 data.fid.unique = 0;
52184 data.fid.vnode = 0;
52185
52186 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52187 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52188 afs_iget5_autocell_test, afs_iget5_set,
52189 &data);
52190 if (!inode) {
52191 diff --git a/fs/aio.c b/fs/aio.c
52192 index 9b5ca11..c530886 100644
52193 --- a/fs/aio.c
52194 +++ b/fs/aio.c
52195 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52196 size += sizeof(struct io_event) * nr_events;
52197 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52198
52199 - if (nr_pages < 0)
52200 + if (nr_pages <= 0)
52201 return -EINVAL;
52202
52203 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52204 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52205 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52206 {
52207 ssize_t ret;
52208 + struct iovec iovstack;
52209
52210 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52211
52212 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52213 if (compat)
52214 ret = compat_rw_copy_check_uvector(rw,
52215 (struct compat_iovec __user *)kiocb->ki_buf,
52216 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52217 + kiocb->ki_nr_segs, 1, &iovstack,
52218 &kiocb->ki_iovec);
52219 else
52220 #endif
52221 ret = rw_copy_check_uvector(rw,
52222 (struct iovec __user *)kiocb->ki_buf,
52223 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52224 + kiocb->ki_nr_segs, 1, &iovstack,
52225 &kiocb->ki_iovec);
52226 if (ret < 0)
52227 return ret;
52228
52229 + if (kiocb->ki_iovec == &iovstack) {
52230 + kiocb->ki_inline_vec = iovstack;
52231 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52232 + }
52233 +
52234 /* ki_nbytes now reflect bytes instead of segs */
52235 kiocb->ki_nbytes = ret;
52236 return 0;
52237 diff --git a/fs/attr.c b/fs/attr.c
52238 index 1449adb..a2038c2 100644
52239 --- a/fs/attr.c
52240 +++ b/fs/attr.c
52241 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52242 unsigned long limit;
52243
52244 limit = rlimit(RLIMIT_FSIZE);
52245 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52246 if (limit != RLIM_INFINITY && offset > limit)
52247 goto out_sig;
52248 if (offset > inode->i_sb->s_maxbytes)
52249 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52250 index 3db70da..7aeec5b 100644
52251 --- a/fs/autofs4/waitq.c
52252 +++ b/fs/autofs4/waitq.c
52253 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52254 {
52255 unsigned long sigpipe, flags;
52256 mm_segment_t fs;
52257 - const char *data = (const char *)addr;
52258 + const char __user *data = (const char __force_user *)addr;
52259 ssize_t wr = 0;
52260
52261 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52262 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52263 return 1;
52264 }
52265
52266 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52267 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52268 +#endif
52269 +
52270 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52271 enum autofs_notify notify)
52272 {
52273 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52274
52275 /* If this is a direct mount request create a dummy name */
52276 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52277 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52278 + /* this name does get written to userland via autofs4_write() */
52279 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52280 +#else
52281 qstr.len = sprintf(name, "%p", dentry);
52282 +#endif
52283 else {
52284 qstr.len = autofs4_getpath(sbi, dentry, &name);
52285 if (!qstr.len) {
52286 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52287 index 2722387..c8dd2a7 100644
52288 --- a/fs/befs/endian.h
52289 +++ b/fs/befs/endian.h
52290 @@ -11,7 +11,7 @@
52291
52292 #include <asm/byteorder.h>
52293
52294 -static inline u64
52295 +static inline u64 __intentional_overflow(-1)
52296 fs64_to_cpu(const struct super_block *sb, fs64 n)
52297 {
52298 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52299 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52300 return (__force fs64)cpu_to_be64(n);
52301 }
52302
52303 -static inline u32
52304 +static inline u32 __intentional_overflow(-1)
52305 fs32_to_cpu(const struct super_block *sb, fs32 n)
52306 {
52307 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52308 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52309 index e9c75e2..1baece1 100644
52310 --- a/fs/befs/linuxvfs.c
52311 +++ b/fs/befs/linuxvfs.c
52312 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52313 {
52314 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52315 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52316 - char *link = nd_get_link(nd);
52317 + const char *link = nd_get_link(nd);
52318 if (!IS_ERR(link))
52319 kfree(link);
52320 }
52321 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52322 index 89dec7f..361b0d75 100644
52323 --- a/fs/binfmt_aout.c
52324 +++ b/fs/binfmt_aout.c
52325 @@ -16,6 +16,7 @@
52326 #include <linux/string.h>
52327 #include <linux/fs.h>
52328 #include <linux/file.h>
52329 +#include <linux/security.h>
52330 #include <linux/stat.h>
52331 #include <linux/fcntl.h>
52332 #include <linux/ptrace.h>
52333 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52334 #endif
52335 # define START_STACK(u) ((void __user *)u.start_stack)
52336
52337 + memset(&dump, 0, sizeof(dump));
52338 +
52339 fs = get_fs();
52340 set_fs(KERNEL_DS);
52341 has_dumped = 1;
52342 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52343
52344 /* If the size of the dump file exceeds the rlimit, then see what would happen
52345 if we wrote the stack, but not the data area. */
52346 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52347 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52348 dump.u_dsize = 0;
52349
52350 /* Make sure we have enough room to write the stack and data areas. */
52351 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52352 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52353 dump.u_ssize = 0;
52354
52355 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52356 rlim = rlimit(RLIMIT_DATA);
52357 if (rlim >= RLIM_INFINITY)
52358 rlim = ~0;
52359 +
52360 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52361 if (ex.a_data + ex.a_bss > rlim)
52362 return -ENOMEM;
52363
52364 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52365
52366 install_exec_creds(bprm);
52367
52368 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52369 + current->mm->pax_flags = 0UL;
52370 +#endif
52371 +
52372 +#ifdef CONFIG_PAX_PAGEEXEC
52373 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52374 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52375 +
52376 +#ifdef CONFIG_PAX_EMUTRAMP
52377 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52378 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52379 +#endif
52380 +
52381 +#ifdef CONFIG_PAX_MPROTECT
52382 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52383 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52384 +#endif
52385 +
52386 + }
52387 +#endif
52388 +
52389 if (N_MAGIC(ex) == OMAGIC) {
52390 unsigned long text_addr, map_size;
52391 loff_t pos;
52392 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52393 }
52394
52395 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52396 - PROT_READ | PROT_WRITE | PROT_EXEC,
52397 + PROT_READ | PROT_WRITE,
52398 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52399 fd_offset + ex.a_text);
52400 if (error != N_DATADDR(ex)) {
52401 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52402 index 100edcc..244db37 100644
52403 --- a/fs/binfmt_elf.c
52404 +++ b/fs/binfmt_elf.c
52405 @@ -34,6 +34,7 @@
52406 #include <linux/utsname.h>
52407 #include <linux/coredump.h>
52408 #include <linux/sched.h>
52409 +#include <linux/xattr.h>
52410 #include <asm/uaccess.h>
52411 #include <asm/param.h>
52412 #include <asm/page.h>
52413 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52414 #define elf_core_dump NULL
52415 #endif
52416
52417 +#ifdef CONFIG_PAX_MPROTECT
52418 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52419 +#endif
52420 +
52421 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52422 +static void elf_handle_mmap(struct file *file);
52423 +#endif
52424 +
52425 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52426 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52427 #else
52428 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52429 .load_binary = load_elf_binary,
52430 .load_shlib = load_elf_library,
52431 .core_dump = elf_core_dump,
52432 +
52433 +#ifdef CONFIG_PAX_MPROTECT
52434 + .handle_mprotect= elf_handle_mprotect,
52435 +#endif
52436 +
52437 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52438 + .handle_mmap = elf_handle_mmap,
52439 +#endif
52440 +
52441 .min_coredump = ELF_EXEC_PAGESIZE,
52442 };
52443
52444 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52445
52446 static int set_brk(unsigned long start, unsigned long end)
52447 {
52448 + unsigned long e = end;
52449 +
52450 start = ELF_PAGEALIGN(start);
52451 end = ELF_PAGEALIGN(end);
52452 if (end > start) {
52453 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52454 if (BAD_ADDR(addr))
52455 return addr;
52456 }
52457 - current->mm->start_brk = current->mm->brk = end;
52458 + current->mm->start_brk = current->mm->brk = e;
52459 return 0;
52460 }
52461
52462 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52463 elf_addr_t __user *u_rand_bytes;
52464 const char *k_platform = ELF_PLATFORM;
52465 const char *k_base_platform = ELF_BASE_PLATFORM;
52466 - unsigned char k_rand_bytes[16];
52467 + u32 k_rand_bytes[4];
52468 int items;
52469 elf_addr_t *elf_info;
52470 int ei_index = 0;
52471 const struct cred *cred = current_cred();
52472 struct vm_area_struct *vma;
52473 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52474
52475 /*
52476 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52477 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52478 * Generate 16 random bytes for userspace PRNG seeding.
52479 */
52480 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52481 - u_rand_bytes = (elf_addr_t __user *)
52482 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52483 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52484 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52485 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52486 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52487 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52488 + u_rand_bytes = (elf_addr_t __user *) p;
52489 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52490 return -EFAULT;
52491
52492 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52493 return -EFAULT;
52494 current->mm->env_end = p;
52495
52496 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52497 +
52498 /* Put the elf_info on the stack in the right place. */
52499 sp = (elf_addr_t __user *)envp + 1;
52500 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52501 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52502 return -EFAULT;
52503 return 0;
52504 }
52505 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52506 an ELF header */
52507
52508 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52509 - struct file *interpreter, unsigned long *interp_map_addr,
52510 - unsigned long no_base)
52511 + struct file *interpreter, unsigned long no_base)
52512 {
52513 struct elf_phdr *elf_phdata;
52514 struct elf_phdr *eppnt;
52515 - unsigned long load_addr = 0;
52516 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52517 int load_addr_set = 0;
52518 unsigned long last_bss = 0, elf_bss = 0;
52519 - unsigned long error = ~0UL;
52520 + unsigned long error = -EINVAL;
52521 unsigned long total_size;
52522 int retval, i, size;
52523
52524 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52525 goto out_close;
52526 }
52527
52528 +#ifdef CONFIG_PAX_SEGMEXEC
52529 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52530 + pax_task_size = SEGMEXEC_TASK_SIZE;
52531 +#endif
52532 +
52533 eppnt = elf_phdata;
52534 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52535 if (eppnt->p_type == PT_LOAD) {
52536 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52537 map_addr = elf_map(interpreter, load_addr + vaddr,
52538 eppnt, elf_prot, elf_type, total_size);
52539 total_size = 0;
52540 - if (!*interp_map_addr)
52541 - *interp_map_addr = map_addr;
52542 error = map_addr;
52543 if (BAD_ADDR(map_addr))
52544 goto out_close;
52545 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52546 k = load_addr + eppnt->p_vaddr;
52547 if (BAD_ADDR(k) ||
52548 eppnt->p_filesz > eppnt->p_memsz ||
52549 - eppnt->p_memsz > TASK_SIZE ||
52550 - TASK_SIZE - eppnt->p_memsz < k) {
52551 + eppnt->p_memsz > pax_task_size ||
52552 + pax_task_size - eppnt->p_memsz < k) {
52553 error = -ENOMEM;
52554 goto out_close;
52555 }
52556 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52557 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52558
52559 /* Map the last of the bss segment */
52560 - error = vm_brk(elf_bss, last_bss - elf_bss);
52561 - if (BAD_ADDR(error))
52562 - goto out_close;
52563 + if (last_bss > elf_bss) {
52564 + error = vm_brk(elf_bss, last_bss - elf_bss);
52565 + if (BAD_ADDR(error))
52566 + goto out_close;
52567 + }
52568 }
52569
52570 error = load_addr;
52571 @@ -538,6 +569,315 @@ out:
52572 return error;
52573 }
52574
52575 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52576 +#ifdef CONFIG_PAX_SOFTMODE
52577 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52578 +{
52579 + unsigned long pax_flags = 0UL;
52580 +
52581 +#ifdef CONFIG_PAX_PAGEEXEC
52582 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52583 + pax_flags |= MF_PAX_PAGEEXEC;
52584 +#endif
52585 +
52586 +#ifdef CONFIG_PAX_SEGMEXEC
52587 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52588 + pax_flags |= MF_PAX_SEGMEXEC;
52589 +#endif
52590 +
52591 +#ifdef CONFIG_PAX_EMUTRAMP
52592 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52593 + pax_flags |= MF_PAX_EMUTRAMP;
52594 +#endif
52595 +
52596 +#ifdef CONFIG_PAX_MPROTECT
52597 + if (elf_phdata->p_flags & PF_MPROTECT)
52598 + pax_flags |= MF_PAX_MPROTECT;
52599 +#endif
52600 +
52601 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52602 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52603 + pax_flags |= MF_PAX_RANDMMAP;
52604 +#endif
52605 +
52606 + return pax_flags;
52607 +}
52608 +#endif
52609 +
52610 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52611 +{
52612 + unsigned long pax_flags = 0UL;
52613 +
52614 +#ifdef CONFIG_PAX_PAGEEXEC
52615 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52616 + pax_flags |= MF_PAX_PAGEEXEC;
52617 +#endif
52618 +
52619 +#ifdef CONFIG_PAX_SEGMEXEC
52620 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52621 + pax_flags |= MF_PAX_SEGMEXEC;
52622 +#endif
52623 +
52624 +#ifdef CONFIG_PAX_EMUTRAMP
52625 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52626 + pax_flags |= MF_PAX_EMUTRAMP;
52627 +#endif
52628 +
52629 +#ifdef CONFIG_PAX_MPROTECT
52630 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52631 + pax_flags |= MF_PAX_MPROTECT;
52632 +#endif
52633 +
52634 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52635 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52636 + pax_flags |= MF_PAX_RANDMMAP;
52637 +#endif
52638 +
52639 + return pax_flags;
52640 +}
52641 +#endif
52642 +
52643 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52644 +#ifdef CONFIG_PAX_SOFTMODE
52645 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52646 +{
52647 + unsigned long pax_flags = 0UL;
52648 +
52649 +#ifdef CONFIG_PAX_PAGEEXEC
52650 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52651 + pax_flags |= MF_PAX_PAGEEXEC;
52652 +#endif
52653 +
52654 +#ifdef CONFIG_PAX_SEGMEXEC
52655 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52656 + pax_flags |= MF_PAX_SEGMEXEC;
52657 +#endif
52658 +
52659 +#ifdef CONFIG_PAX_EMUTRAMP
52660 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52661 + pax_flags |= MF_PAX_EMUTRAMP;
52662 +#endif
52663 +
52664 +#ifdef CONFIG_PAX_MPROTECT
52665 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52666 + pax_flags |= MF_PAX_MPROTECT;
52667 +#endif
52668 +
52669 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52670 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52671 + pax_flags |= MF_PAX_RANDMMAP;
52672 +#endif
52673 +
52674 + return pax_flags;
52675 +}
52676 +#endif
52677 +
52678 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52679 +{
52680 + unsigned long pax_flags = 0UL;
52681 +
52682 +#ifdef CONFIG_PAX_PAGEEXEC
52683 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52684 + pax_flags |= MF_PAX_PAGEEXEC;
52685 +#endif
52686 +
52687 +#ifdef CONFIG_PAX_SEGMEXEC
52688 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52689 + pax_flags |= MF_PAX_SEGMEXEC;
52690 +#endif
52691 +
52692 +#ifdef CONFIG_PAX_EMUTRAMP
52693 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52694 + pax_flags |= MF_PAX_EMUTRAMP;
52695 +#endif
52696 +
52697 +#ifdef CONFIG_PAX_MPROTECT
52698 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52699 + pax_flags |= MF_PAX_MPROTECT;
52700 +#endif
52701 +
52702 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52703 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52704 + pax_flags |= MF_PAX_RANDMMAP;
52705 +#endif
52706 +
52707 + return pax_flags;
52708 +}
52709 +#endif
52710 +
52711 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52712 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52713 +{
52714 + unsigned long pax_flags = 0UL;
52715 +
52716 +#ifdef CONFIG_PAX_EI_PAX
52717 +
52718 +#ifdef CONFIG_PAX_PAGEEXEC
52719 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52720 + pax_flags |= MF_PAX_PAGEEXEC;
52721 +#endif
52722 +
52723 +#ifdef CONFIG_PAX_SEGMEXEC
52724 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52725 + pax_flags |= MF_PAX_SEGMEXEC;
52726 +#endif
52727 +
52728 +#ifdef CONFIG_PAX_EMUTRAMP
52729 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52730 + pax_flags |= MF_PAX_EMUTRAMP;
52731 +#endif
52732 +
52733 +#ifdef CONFIG_PAX_MPROTECT
52734 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52735 + pax_flags |= MF_PAX_MPROTECT;
52736 +#endif
52737 +
52738 +#ifdef CONFIG_PAX_ASLR
52739 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52740 + pax_flags |= MF_PAX_RANDMMAP;
52741 +#endif
52742 +
52743 +#else
52744 +
52745 +#ifdef CONFIG_PAX_PAGEEXEC
52746 + pax_flags |= MF_PAX_PAGEEXEC;
52747 +#endif
52748 +
52749 +#ifdef CONFIG_PAX_SEGMEXEC
52750 + pax_flags |= MF_PAX_SEGMEXEC;
52751 +#endif
52752 +
52753 +#ifdef CONFIG_PAX_MPROTECT
52754 + pax_flags |= MF_PAX_MPROTECT;
52755 +#endif
52756 +
52757 +#ifdef CONFIG_PAX_RANDMMAP
52758 + if (randomize_va_space)
52759 + pax_flags |= MF_PAX_RANDMMAP;
52760 +#endif
52761 +
52762 +#endif
52763 +
52764 + return pax_flags;
52765 +}
52766 +
52767 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52768 +{
52769 +
52770 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52771 + unsigned long i;
52772 +
52773 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52774 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52775 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52776 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52777 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52778 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52779 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52780 + return ~0UL;
52781 +
52782 +#ifdef CONFIG_PAX_SOFTMODE
52783 + if (pax_softmode)
52784 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52785 + else
52786 +#endif
52787 +
52788 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52789 + break;
52790 + }
52791 +#endif
52792 +
52793 + return ~0UL;
52794 +}
52795 +
52796 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52797 +{
52798 +
52799 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52800 + ssize_t xattr_size, i;
52801 + unsigned char xattr_value[sizeof("pemrs") - 1];
52802 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52803 +
52804 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52805 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52806 + return ~0UL;
52807 +
52808 + for (i = 0; i < xattr_size; i++)
52809 + switch (xattr_value[i]) {
52810 + default:
52811 + return ~0UL;
52812 +
52813 +#define parse_flag(option1, option2, flag) \
52814 + case option1: \
52815 + if (pax_flags_hardmode & MF_PAX_##flag) \
52816 + return ~0UL; \
52817 + pax_flags_hardmode |= MF_PAX_##flag; \
52818 + break; \
52819 + case option2: \
52820 + if (pax_flags_softmode & MF_PAX_##flag) \
52821 + return ~0UL; \
52822 + pax_flags_softmode |= MF_PAX_##flag; \
52823 + break;
52824 +
52825 + parse_flag('p', 'P', PAGEEXEC);
52826 + parse_flag('e', 'E', EMUTRAMP);
52827 + parse_flag('m', 'M', MPROTECT);
52828 + parse_flag('r', 'R', RANDMMAP);
52829 + parse_flag('s', 'S', SEGMEXEC);
52830 +
52831 +#undef parse_flag
52832 + }
52833 +
52834 + if (pax_flags_hardmode & pax_flags_softmode)
52835 + return ~0UL;
52836 +
52837 +#ifdef CONFIG_PAX_SOFTMODE
52838 + if (pax_softmode)
52839 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52840 + else
52841 +#endif
52842 +
52843 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52844 +#else
52845 + return ~0UL;
52846 +#endif
52847 +
52848 +}
52849 +
52850 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52851 +{
52852 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52853 +
52854 + pax_flags = pax_parse_ei_pax(elf_ex);
52855 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52856 + xattr_pax_flags = pax_parse_xattr_pax(file);
52857 +
52858 + if (pt_pax_flags == ~0UL)
52859 + pt_pax_flags = xattr_pax_flags;
52860 + else if (xattr_pax_flags == ~0UL)
52861 + xattr_pax_flags = pt_pax_flags;
52862 + if (pt_pax_flags != xattr_pax_flags)
52863 + return -EINVAL;
52864 + if (pt_pax_flags != ~0UL)
52865 + pax_flags = pt_pax_flags;
52866 +
52867 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52868 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52869 + if ((__supported_pte_mask & _PAGE_NX))
52870 + pax_flags &= ~MF_PAX_SEGMEXEC;
52871 + else
52872 + pax_flags &= ~MF_PAX_PAGEEXEC;
52873 + }
52874 +#endif
52875 +
52876 + if (0 > pax_check_flags(&pax_flags))
52877 + return -EINVAL;
52878 +
52879 + current->mm->pax_flags = pax_flags;
52880 + return 0;
52881 +}
52882 +#endif
52883 +
52884 /*
52885 * These are the functions used to load ELF style executables and shared
52886 * libraries. There is no binary dependent code anywhere else.
52887 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52888 {
52889 unsigned int random_variable = 0;
52890
52891 +#ifdef CONFIG_PAX_RANDUSTACK
52892 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52893 + return stack_top - current->mm->delta_stack;
52894 +#endif
52895 +
52896 if ((current->flags & PF_RANDOMIZE) &&
52897 !(current->personality & ADDR_NO_RANDOMIZE)) {
52898 random_variable = get_random_int() & STACK_RND_MASK;
52899 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52900 unsigned long load_addr = 0, load_bias = 0;
52901 int load_addr_set = 0;
52902 char * elf_interpreter = NULL;
52903 - unsigned long error;
52904 + unsigned long error = 0;
52905 struct elf_phdr *elf_ppnt, *elf_phdata;
52906 unsigned long elf_bss, elf_brk;
52907 int retval, i;
52908 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52909 unsigned long start_code, end_code, start_data, end_data;
52910 unsigned long reloc_func_desc __maybe_unused = 0;
52911 int executable_stack = EXSTACK_DEFAULT;
52912 - unsigned long def_flags = 0;
52913 struct pt_regs *regs = current_pt_regs();
52914 struct {
52915 struct elfhdr elf_ex;
52916 struct elfhdr interp_elf_ex;
52917 } *loc;
52918 + unsigned long pax_task_size = TASK_SIZE;
52919
52920 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52921 if (!loc) {
52922 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52923 goto out_free_dentry;
52924
52925 /* OK, This is the point of no return */
52926 - current->mm->def_flags = def_flags;
52927 +
52928 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52929 + current->mm->pax_flags = 0UL;
52930 +#endif
52931 +
52932 +#ifdef CONFIG_PAX_DLRESOLVE
52933 + current->mm->call_dl_resolve = 0UL;
52934 +#endif
52935 +
52936 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52937 + current->mm->call_syscall = 0UL;
52938 +#endif
52939 +
52940 +#ifdef CONFIG_PAX_ASLR
52941 + current->mm->delta_mmap = 0UL;
52942 + current->mm->delta_stack = 0UL;
52943 +#endif
52944 +
52945 + current->mm->def_flags = 0;
52946 +
52947 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52948 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52949 + send_sig(SIGKILL, current, 0);
52950 + goto out_free_dentry;
52951 + }
52952 +#endif
52953 +
52954 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52955 + pax_set_initial_flags(bprm);
52956 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52957 + if (pax_set_initial_flags_func)
52958 + (pax_set_initial_flags_func)(bprm);
52959 +#endif
52960 +
52961 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52962 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52963 + current->mm->context.user_cs_limit = PAGE_SIZE;
52964 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52965 + }
52966 +#endif
52967 +
52968 +#ifdef CONFIG_PAX_SEGMEXEC
52969 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52970 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52971 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52972 + pax_task_size = SEGMEXEC_TASK_SIZE;
52973 + current->mm->def_flags |= VM_NOHUGEPAGE;
52974 + }
52975 +#endif
52976 +
52977 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52978 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52979 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52980 + put_cpu();
52981 + }
52982 +#endif
52983
52984 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52985 may depend on the personality. */
52986 SET_PERSONALITY(loc->elf_ex);
52987 +
52988 +#ifdef CONFIG_PAX_ASLR
52989 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52990 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52991 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52992 + }
52993 +#endif
52994 +
52995 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52996 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52997 + executable_stack = EXSTACK_DISABLE_X;
52998 + current->personality &= ~READ_IMPLIES_EXEC;
52999 + } else
53000 +#endif
53001 +
53002 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53003 current->personality |= READ_IMPLIES_EXEC;
53004
53005 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53006 #else
53007 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53008 #endif
53009 +
53010 +#ifdef CONFIG_PAX_RANDMMAP
53011 + /* PaX: randomize base address at the default exe base if requested */
53012 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53013 +#ifdef CONFIG_SPARC64
53014 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53015 +#else
53016 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53017 +#endif
53018 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53019 + elf_flags |= MAP_FIXED;
53020 + }
53021 +#endif
53022 +
53023 }
53024
53025 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53026 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53027 * allowed task size. Note that p_filesz must always be
53028 * <= p_memsz so it is only necessary to check p_memsz.
53029 */
53030 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53031 - elf_ppnt->p_memsz > TASK_SIZE ||
53032 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53033 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53034 + elf_ppnt->p_memsz > pax_task_size ||
53035 + pax_task_size - elf_ppnt->p_memsz < k) {
53036 /* set_brk can never work. Avoid overflows. */
53037 send_sig(SIGKILL, current, 0);
53038 retval = -EINVAL;
53039 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53040 goto out_free_dentry;
53041 }
53042 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53043 - send_sig(SIGSEGV, current, 0);
53044 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53045 - goto out_free_dentry;
53046 + /*
53047 + * This bss-zeroing can fail if the ELF
53048 + * file specifies odd protections. So
53049 + * we don't check the return value
53050 + */
53051 }
53052
53053 +#ifdef CONFIG_PAX_RANDMMAP
53054 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53055 + unsigned long start, size, flags;
53056 + vm_flags_t vm_flags;
53057 +
53058 + start = ELF_PAGEALIGN(elf_brk);
53059 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53060 + flags = MAP_FIXED | MAP_PRIVATE;
53061 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53062 +
53063 + down_write(&current->mm->mmap_sem);
53064 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53065 + retval = -ENOMEM;
53066 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53067 +// if (current->personality & ADDR_NO_RANDOMIZE)
53068 +// vm_flags |= VM_READ | VM_MAYREAD;
53069 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53070 + retval = IS_ERR_VALUE(start) ? start : 0;
53071 + }
53072 + up_write(&current->mm->mmap_sem);
53073 + if (retval == 0)
53074 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53075 + if (retval < 0) {
53076 + send_sig(SIGKILL, current, 0);
53077 + goto out_free_dentry;
53078 + }
53079 + }
53080 +#endif
53081 +
53082 if (elf_interpreter) {
53083 - unsigned long interp_map_addr = 0;
53084 -
53085 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53086 interpreter,
53087 - &interp_map_addr,
53088 load_bias);
53089 if (!IS_ERR((void *)elf_entry)) {
53090 /*
53091 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53092 * Decide what to dump of a segment, part, all or none.
53093 */
53094 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53095 - unsigned long mm_flags)
53096 + unsigned long mm_flags, long signr)
53097 {
53098 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53099
53100 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53101 if (vma->vm_file == NULL)
53102 return 0;
53103
53104 - if (FILTER(MAPPED_PRIVATE))
53105 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53106 goto whole;
53107
53108 /*
53109 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53110 {
53111 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53112 int i = 0;
53113 - do
53114 + do {
53115 i += 2;
53116 - while (auxv[i - 2] != AT_NULL);
53117 + } while (auxv[i - 2] != AT_NULL);
53118 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53119 }
53120
53121 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53122 {
53123 mm_segment_t old_fs = get_fs();
53124 set_fs(KERNEL_DS);
53125 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53126 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53127 set_fs(old_fs);
53128 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53129 }
53130 @@ -2017,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53131 }
53132
53133 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53134 - unsigned long mm_flags)
53135 + struct coredump_params *cprm)
53136 {
53137 struct vm_area_struct *vma;
53138 size_t size = 0;
53139
53140 for (vma = first_vma(current, gate_vma); vma != NULL;
53141 vma = next_vma(vma, gate_vma))
53142 - size += vma_dump_size(vma, mm_flags);
53143 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53144 return size;
53145 }
53146
53147 @@ -2117,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53148
53149 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53150
53151 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53152 + offset += elf_core_vma_data_size(gate_vma, cprm);
53153 offset += elf_core_extra_data_size();
53154 e_shoff = offset;
53155
53156 @@ -2131,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53157 offset = dataoff;
53158
53159 size += sizeof(*elf);
53160 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53161 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53162 goto end_coredump;
53163
53164 size += sizeof(*phdr4note);
53165 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53166 if (size > cprm->limit
53167 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53168 goto end_coredump;
53169 @@ -2148,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53170 phdr.p_offset = offset;
53171 phdr.p_vaddr = vma->vm_start;
53172 phdr.p_paddr = 0;
53173 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53174 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53175 phdr.p_memsz = vma->vm_end - vma->vm_start;
53176 offset += phdr.p_filesz;
53177 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53178 @@ -2159,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53179 phdr.p_align = ELF_EXEC_PAGESIZE;
53180
53181 size += sizeof(phdr);
53182 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53183 if (size > cprm->limit
53184 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53185 goto end_coredump;
53186 @@ -2183,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53187 unsigned long addr;
53188 unsigned long end;
53189
53190 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53191 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53192
53193 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53194 struct page *page;
53195 @@ -2192,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53196 page = get_dump_page(addr);
53197 if (page) {
53198 void *kaddr = kmap(page);
53199 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53200 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53201 !dump_write(cprm->file, kaddr,
53202 PAGE_SIZE);
53203 @@ -2209,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53204
53205 if (e_phnum == PN_XNUM) {
53206 size += sizeof(*shdr4extnum);
53207 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53208 if (size > cprm->limit
53209 || !dump_write(cprm->file, shdr4extnum,
53210 sizeof(*shdr4extnum)))
53211 @@ -2229,6 +2691,167 @@ out:
53212
53213 #endif /* CONFIG_ELF_CORE */
53214
53215 +#ifdef CONFIG_PAX_MPROTECT
53216 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53217 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53218 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53219 + *
53220 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53221 + * basis because we want to allow the common case and not the special ones.
53222 + */
53223 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53224 +{
53225 + struct elfhdr elf_h;
53226 + struct elf_phdr elf_p;
53227 + unsigned long i;
53228 + unsigned long oldflags;
53229 + bool is_textrel_rw, is_textrel_rx, is_relro;
53230 +
53231 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53232 + return;
53233 +
53234 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53235 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53236 +
53237 +#ifdef CONFIG_PAX_ELFRELOCS
53238 + /* possible TEXTREL */
53239 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53240 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53241 +#else
53242 + is_textrel_rw = false;
53243 + is_textrel_rx = false;
53244 +#endif
53245 +
53246 + /* possible RELRO */
53247 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53248 +
53249 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53250 + return;
53251 +
53252 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53253 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53254 +
53255 +#ifdef CONFIG_PAX_ETEXECRELOCS
53256 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53257 +#else
53258 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53259 +#endif
53260 +
53261 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53262 + !elf_check_arch(&elf_h) ||
53263 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53264 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53265 + return;
53266 +
53267 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53268 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53269 + return;
53270 + switch (elf_p.p_type) {
53271 + case PT_DYNAMIC:
53272 + if (!is_textrel_rw && !is_textrel_rx)
53273 + continue;
53274 + i = 0UL;
53275 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53276 + elf_dyn dyn;
53277 +
53278 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53279 + break;
53280 + if (dyn.d_tag == DT_NULL)
53281 + break;
53282 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53283 + gr_log_textrel(vma);
53284 + if (is_textrel_rw)
53285 + vma->vm_flags |= VM_MAYWRITE;
53286 + else
53287 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53288 + vma->vm_flags &= ~VM_MAYWRITE;
53289 + break;
53290 + }
53291 + i++;
53292 + }
53293 + is_textrel_rw = false;
53294 + is_textrel_rx = false;
53295 + continue;
53296 +
53297 + case PT_GNU_RELRO:
53298 + if (!is_relro)
53299 + continue;
53300 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53301 + vma->vm_flags &= ~VM_MAYWRITE;
53302 + is_relro = false;
53303 + continue;
53304 +
53305 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53306 + case PT_PAX_FLAGS: {
53307 + const char *msg_mprotect = "", *msg_emutramp = "";
53308 + char *buffer_lib, *buffer_exe;
53309 +
53310 + if (elf_p.p_flags & PF_NOMPROTECT)
53311 + msg_mprotect = "MPROTECT disabled";
53312 +
53313 +#ifdef CONFIG_PAX_EMUTRAMP
53314 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53315 + msg_emutramp = "EMUTRAMP enabled";
53316 +#endif
53317 +
53318 + if (!msg_mprotect[0] && !msg_emutramp[0])
53319 + continue;
53320 +
53321 + if (!printk_ratelimit())
53322 + continue;
53323 +
53324 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53325 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53326 + if (buffer_lib && buffer_exe) {
53327 + char *path_lib, *path_exe;
53328 +
53329 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53330 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53331 +
53332 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53333 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53334 +
53335 + }
53336 + free_page((unsigned long)buffer_exe);
53337 + free_page((unsigned long)buffer_lib);
53338 + continue;
53339 + }
53340 +#endif
53341 +
53342 + }
53343 + }
53344 +}
53345 +#endif
53346 +
53347 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53348 +
53349 +extern int grsec_enable_log_rwxmaps;
53350 +
53351 +static void elf_handle_mmap(struct file *file)
53352 +{
53353 + struct elfhdr elf_h;
53354 + struct elf_phdr elf_p;
53355 + unsigned long i;
53356 +
53357 + if (!grsec_enable_log_rwxmaps)
53358 + return;
53359 +
53360 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53361 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53362 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53363 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53364 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53365 + return;
53366 +
53367 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53368 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53369 + return;
53370 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53371 + gr_log_ptgnustack(file);
53372 + }
53373 +}
53374 +#endif
53375 +
53376 static int __init init_elf_binfmt(void)
53377 {
53378 register_binfmt(&elf_format);
53379 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53380 index d50bbe5..af3b649 100644
53381 --- a/fs/binfmt_flat.c
53382 +++ b/fs/binfmt_flat.c
53383 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53384 realdatastart = (unsigned long) -ENOMEM;
53385 printk("Unable to allocate RAM for process data, errno %d\n",
53386 (int)-realdatastart);
53387 + down_write(&current->mm->mmap_sem);
53388 vm_munmap(textpos, text_len);
53389 + up_write(&current->mm->mmap_sem);
53390 ret = realdatastart;
53391 goto err;
53392 }
53393 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53394 }
53395 if (IS_ERR_VALUE(result)) {
53396 printk("Unable to read data+bss, errno %d\n", (int)-result);
53397 + down_write(&current->mm->mmap_sem);
53398 vm_munmap(textpos, text_len);
53399 vm_munmap(realdatastart, len);
53400 + up_write(&current->mm->mmap_sem);
53401 ret = result;
53402 goto err;
53403 }
53404 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53405 }
53406 if (IS_ERR_VALUE(result)) {
53407 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53408 + down_write(&current->mm->mmap_sem);
53409 vm_munmap(textpos, text_len + data_len + extra +
53410 MAX_SHARED_LIBS * sizeof(unsigned long));
53411 + up_write(&current->mm->mmap_sem);
53412 ret = result;
53413 goto err;
53414 }
53415 diff --git a/fs/bio.c b/fs/bio.c
53416 index c5eae72..599e3cf 100644
53417 --- a/fs/bio.c
53418 +++ b/fs/bio.c
53419 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53420 /*
53421 * Overflow, abort
53422 */
53423 - if (end < start)
53424 + if (end < start || end - start > INT_MAX - nr_pages)
53425 return ERR_PTR(-EINVAL);
53426
53427 nr_pages += end - start;
53428 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53429 /*
53430 * Overflow, abort
53431 */
53432 - if (end < start)
53433 + if (end < start || end - start > INT_MAX - nr_pages)
53434 return ERR_PTR(-EINVAL);
53435
53436 nr_pages += end - start;
53437 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53438 const int read = bio_data_dir(bio) == READ;
53439 struct bio_map_data *bmd = bio->bi_private;
53440 int i;
53441 - char *p = bmd->sgvecs[0].iov_base;
53442 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53443
53444 bio_for_each_segment_all(bvec, bio, i) {
53445 char *addr = page_address(bvec->bv_page);
53446 diff --git a/fs/block_dev.c b/fs/block_dev.c
53447 index c7bda5c..2121e94 100644
53448 --- a/fs/block_dev.c
53449 +++ b/fs/block_dev.c
53450 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53451 else if (bdev->bd_contains == bdev)
53452 return true; /* is a whole device which isn't held */
53453
53454 - else if (whole->bd_holder == bd_may_claim)
53455 + else if (whole->bd_holder == (void *)bd_may_claim)
53456 return true; /* is a partition of a device that is being partitioned */
53457 else if (whole->bd_holder != NULL)
53458 return false; /* is a partition of a held device */
53459 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53460 index ed50460..fe84385 100644
53461 --- a/fs/btrfs/ctree.c
53462 +++ b/fs/btrfs/ctree.c
53463 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53464 free_extent_buffer(buf);
53465 add_root_to_dirty_list(root);
53466 } else {
53467 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53468 - parent_start = parent->start;
53469 - else
53470 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53471 + if (parent)
53472 + parent_start = parent->start;
53473 + else
53474 + parent_start = 0;
53475 + } else
53476 parent_start = 0;
53477
53478 WARN_ON(trans->transid != btrfs_header_generation(parent));
53479 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53480 index 3755109..e3d457f 100644
53481 --- a/fs/btrfs/delayed-inode.c
53482 +++ b/fs/btrfs/delayed-inode.c
53483 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53484
53485 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53486 {
53487 - int seq = atomic_inc_return(&delayed_root->items_seq);
53488 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53489 if ((atomic_dec_return(&delayed_root->items) <
53490 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53491 waitqueue_active(&delayed_root->wait))
53492 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53493 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53494 int seq, int count)
53495 {
53496 - int val = atomic_read(&delayed_root->items_seq);
53497 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53498
53499 if (val < seq || val >= seq + count)
53500 return 1;
53501 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53502 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53503 return;
53504
53505 - seq = atomic_read(&delayed_root->items_seq);
53506 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53507
53508 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53509 int ret;
53510 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53511 index a4b38f9..f86a509 100644
53512 --- a/fs/btrfs/delayed-inode.h
53513 +++ b/fs/btrfs/delayed-inode.h
53514 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53515 */
53516 struct list_head prepare_list;
53517 atomic_t items; /* for delayed items */
53518 - atomic_t items_seq; /* for delayed items */
53519 + atomic_unchecked_t items_seq; /* for delayed items */
53520 int nodes; /* for delayed nodes */
53521 wait_queue_head_t wait;
53522 };
53523 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53524 struct btrfs_delayed_root *delayed_root)
53525 {
53526 atomic_set(&delayed_root->items, 0);
53527 - atomic_set(&delayed_root->items_seq, 0);
53528 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53529 delayed_root->nodes = 0;
53530 spin_lock_init(&delayed_root->lock);
53531 init_waitqueue_head(&delayed_root->wait);
53532 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53533 index 9877a2a..7ebf9ab 100644
53534 --- a/fs/btrfs/ioctl.c
53535 +++ b/fs/btrfs/ioctl.c
53536 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53537 for (i = 0; i < num_types; i++) {
53538 struct btrfs_space_info *tmp;
53539
53540 + /* Don't copy in more than we allocated */
53541 if (!slot_count)
53542 break;
53543
53544 + slot_count--;
53545 +
53546 info = NULL;
53547 rcu_read_lock();
53548 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53549 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53550 memcpy(dest, &space, sizeof(space));
53551 dest++;
53552 space_args.total_spaces++;
53553 - slot_count--;
53554 }
53555 - if (!slot_count)
53556 - break;
53557 }
53558 up_read(&info->groups_sem);
53559 }
53560 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53561 index 8eb6191..eda91e2 100644
53562 --- a/fs/btrfs/super.c
53563 +++ b/fs/btrfs/super.c
53564 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53565 function, line, errstr);
53566 return;
53567 }
53568 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53569 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53570 /* Wake up anybody who may be waiting on this transaction */
53571 wake_up(&root->fs_info->transaction_wait);
53572 wake_up(&root->fs_info->transaction_blocked_wait);
53573 diff --git a/fs/buffer.c b/fs/buffer.c
53574 index 4d74335..b0df7f9 100644
53575 --- a/fs/buffer.c
53576 +++ b/fs/buffer.c
53577 @@ -3416,7 +3416,7 @@ void __init buffer_init(void)
53578 bh_cachep = kmem_cache_create("buffer_head",
53579 sizeof(struct buffer_head), 0,
53580 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53581 - SLAB_MEM_SPREAD),
53582 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53583 NULL);
53584
53585 /*
53586 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53587 index 622f469..e8d2d55 100644
53588 --- a/fs/cachefiles/bind.c
53589 +++ b/fs/cachefiles/bind.c
53590 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53591 args);
53592
53593 /* start by checking things over */
53594 - ASSERT(cache->fstop_percent >= 0 &&
53595 - cache->fstop_percent < cache->fcull_percent &&
53596 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53597 cache->fcull_percent < cache->frun_percent &&
53598 cache->frun_percent < 100);
53599
53600 - ASSERT(cache->bstop_percent >= 0 &&
53601 - cache->bstop_percent < cache->bcull_percent &&
53602 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53603 cache->bcull_percent < cache->brun_percent &&
53604 cache->brun_percent < 100);
53605
53606 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53607 index 0a1467b..6a53245 100644
53608 --- a/fs/cachefiles/daemon.c
53609 +++ b/fs/cachefiles/daemon.c
53610 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53611 if (n > buflen)
53612 return -EMSGSIZE;
53613
53614 - if (copy_to_user(_buffer, buffer, n) != 0)
53615 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53616 return -EFAULT;
53617
53618 return n;
53619 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53620 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53621 return -EIO;
53622
53623 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53624 + if (datalen > PAGE_SIZE - 1)
53625 return -EOPNOTSUPP;
53626
53627 /* drag the command string into the kernel so we can parse it */
53628 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53629 if (args[0] != '%' || args[1] != '\0')
53630 return -EINVAL;
53631
53632 - if (fstop < 0 || fstop >= cache->fcull_percent)
53633 + if (fstop >= cache->fcull_percent)
53634 return cachefiles_daemon_range_error(cache, args);
53635
53636 cache->fstop_percent = fstop;
53637 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53638 if (args[0] != '%' || args[1] != '\0')
53639 return -EINVAL;
53640
53641 - if (bstop < 0 || bstop >= cache->bcull_percent)
53642 + if (bstop >= cache->bcull_percent)
53643 return cachefiles_daemon_range_error(cache, args);
53644
53645 cache->bstop_percent = bstop;
53646 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53647 index 4938251..7e01445 100644
53648 --- a/fs/cachefiles/internal.h
53649 +++ b/fs/cachefiles/internal.h
53650 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53651 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53652 struct rb_root active_nodes; /* active nodes (can't be culled) */
53653 rwlock_t active_lock; /* lock for active_nodes */
53654 - atomic_t gravecounter; /* graveyard uniquifier */
53655 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53656 unsigned frun_percent; /* when to stop culling (% files) */
53657 unsigned fcull_percent; /* when to start culling (% files) */
53658 unsigned fstop_percent; /* when to stop allocating (% files) */
53659 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53660 * proc.c
53661 */
53662 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53663 -extern atomic_t cachefiles_lookup_histogram[HZ];
53664 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53665 -extern atomic_t cachefiles_create_histogram[HZ];
53666 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53667 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53668 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53669
53670 extern int __init cachefiles_proc_init(void);
53671 extern void cachefiles_proc_cleanup(void);
53672 static inline
53673 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53674 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53675 {
53676 unsigned long jif = jiffies - start_jif;
53677 if (jif >= HZ)
53678 jif = HZ - 1;
53679 - atomic_inc(&histogram[jif]);
53680 + atomic_inc_unchecked(&histogram[jif]);
53681 }
53682
53683 #else
53684 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53685 index 25badd1..d70d918 100644
53686 --- a/fs/cachefiles/namei.c
53687 +++ b/fs/cachefiles/namei.c
53688 @@ -317,7 +317,7 @@ try_again:
53689 /* first step is to make up a grave dentry in the graveyard */
53690 sprintf(nbuffer, "%08x%08x",
53691 (uint32_t) get_seconds(),
53692 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53693 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53694
53695 /* do the multiway lock magic */
53696 trap = lock_rename(cache->graveyard, dir);
53697 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53698 index eccd339..4c1d995 100644
53699 --- a/fs/cachefiles/proc.c
53700 +++ b/fs/cachefiles/proc.c
53701 @@ -14,9 +14,9 @@
53702 #include <linux/seq_file.h>
53703 #include "internal.h"
53704
53705 -atomic_t cachefiles_lookup_histogram[HZ];
53706 -atomic_t cachefiles_mkdir_histogram[HZ];
53707 -atomic_t cachefiles_create_histogram[HZ];
53708 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53709 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53710 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53711
53712 /*
53713 * display the latency histogram
53714 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53715 return 0;
53716 default:
53717 index = (unsigned long) v - 3;
53718 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53719 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53720 - z = atomic_read(&cachefiles_create_histogram[index]);
53721 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53722 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53723 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53724 if (x == 0 && y == 0 && z == 0)
53725 return 0;
53726
53727 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53728 index ebaff36..7e3ea26 100644
53729 --- a/fs/cachefiles/rdwr.c
53730 +++ b/fs/cachefiles/rdwr.c
53731 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53732 old_fs = get_fs();
53733 set_fs(KERNEL_DS);
53734 ret = file->f_op->write(
53735 - file, (const void __user *) data, len, &pos);
53736 + file, (const void __force_user *) data, len, &pos);
53737 set_fs(old_fs);
53738 kunmap(page);
53739 file_end_write(file);
53740 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53741 index a40ceda..f43d17c 100644
53742 --- a/fs/ceph/dir.c
53743 +++ b/fs/ceph/dir.c
53744 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53745 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53746 struct ceph_mds_client *mdsc = fsc->mdsc;
53747 unsigned frag = fpos_frag(ctx->pos);
53748 - int off = fpos_off(ctx->pos);
53749 + unsigned int off = fpos_off(ctx->pos);
53750 int err;
53751 u32 ftype;
53752 struct ceph_mds_reply_info_parsed *rinfo;
53753 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53754 index 6627b26..634ec4b 100644
53755 --- a/fs/ceph/super.c
53756 +++ b/fs/ceph/super.c
53757 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53758 /*
53759 * construct our own bdi so we can control readahead, etc.
53760 */
53761 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53762 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53763
53764 static int ceph_register_bdi(struct super_block *sb,
53765 struct ceph_fs_client *fsc)
53766 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53767 default_backing_dev_info.ra_pages;
53768
53769 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53770 - atomic_long_inc_return(&bdi_seq));
53771 + atomic_long_inc_return_unchecked(&bdi_seq));
53772 if (!err)
53773 sb->s_bdi = &fsc->backing_dev_info;
53774 return err;
53775 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53776 index f3ac415..3d2420c 100644
53777 --- a/fs/cifs/cifs_debug.c
53778 +++ b/fs/cifs/cifs_debug.c
53779 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53780
53781 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53782 #ifdef CONFIG_CIFS_STATS2
53783 - atomic_set(&totBufAllocCount, 0);
53784 - atomic_set(&totSmBufAllocCount, 0);
53785 + atomic_set_unchecked(&totBufAllocCount, 0);
53786 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53787 #endif /* CONFIG_CIFS_STATS2 */
53788 spin_lock(&cifs_tcp_ses_lock);
53789 list_for_each(tmp1, &cifs_tcp_ses_list) {
53790 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53791 tcon = list_entry(tmp3,
53792 struct cifs_tcon,
53793 tcon_list);
53794 - atomic_set(&tcon->num_smbs_sent, 0);
53795 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53796 if (server->ops->clear_stats)
53797 server->ops->clear_stats(tcon);
53798 }
53799 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53800 smBufAllocCount.counter, cifs_min_small);
53801 #ifdef CONFIG_CIFS_STATS2
53802 seq_printf(m, "Total Large %d Small %d Allocations\n",
53803 - atomic_read(&totBufAllocCount),
53804 - atomic_read(&totSmBufAllocCount));
53805 + atomic_read_unchecked(&totBufAllocCount),
53806 + atomic_read_unchecked(&totSmBufAllocCount));
53807 #endif /* CONFIG_CIFS_STATS2 */
53808
53809 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53810 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53811 if (tcon->need_reconnect)
53812 seq_puts(m, "\tDISCONNECTED ");
53813 seq_printf(m, "\nSMBs: %d",
53814 - atomic_read(&tcon->num_smbs_sent));
53815 + atomic_read_unchecked(&tcon->num_smbs_sent));
53816 if (server->ops->print_stats)
53817 server->ops->print_stats(m, tcon);
53818 }
53819 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53820 index 85ea98d..b3ed4d6 100644
53821 --- a/fs/cifs/cifsfs.c
53822 +++ b/fs/cifs/cifsfs.c
53823 @@ -1037,7 +1037,7 @@ cifs_init_request_bufs(void)
53824 */
53825 cifs_req_cachep = kmem_cache_create("cifs_request",
53826 CIFSMaxBufSize + max_hdr_size, 0,
53827 - SLAB_HWCACHE_ALIGN, NULL);
53828 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53829 if (cifs_req_cachep == NULL)
53830 return -ENOMEM;
53831
53832 @@ -1064,7 +1064,7 @@ cifs_init_request_bufs(void)
53833 efficient to alloc 1 per page off the slab compared to 17K (5page)
53834 alloc of large cifs buffers even when page debugging is on */
53835 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53836 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53837 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53838 NULL);
53839 if (cifs_sm_req_cachep == NULL) {
53840 mempool_destroy(cifs_req_poolp);
53841 @@ -1149,8 +1149,8 @@ init_cifs(void)
53842 atomic_set(&bufAllocCount, 0);
53843 atomic_set(&smBufAllocCount, 0);
53844 #ifdef CONFIG_CIFS_STATS2
53845 - atomic_set(&totBufAllocCount, 0);
53846 - atomic_set(&totSmBufAllocCount, 0);
53847 + atomic_set_unchecked(&totBufAllocCount, 0);
53848 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53849 #endif /* CONFIG_CIFS_STATS2 */
53850
53851 atomic_set(&midCount, 0);
53852 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53853 index 52ca861..47f309c 100644
53854 --- a/fs/cifs/cifsglob.h
53855 +++ b/fs/cifs/cifsglob.h
53856 @@ -756,35 +756,35 @@ struct cifs_tcon {
53857 __u16 Flags; /* optional support bits */
53858 enum statusEnum tidStatus;
53859 #ifdef CONFIG_CIFS_STATS
53860 - atomic_t num_smbs_sent;
53861 + atomic_unchecked_t num_smbs_sent;
53862 union {
53863 struct {
53864 - atomic_t num_writes;
53865 - atomic_t num_reads;
53866 - atomic_t num_flushes;
53867 - atomic_t num_oplock_brks;
53868 - atomic_t num_opens;
53869 - atomic_t num_closes;
53870 - atomic_t num_deletes;
53871 - atomic_t num_mkdirs;
53872 - atomic_t num_posixopens;
53873 - atomic_t num_posixmkdirs;
53874 - atomic_t num_rmdirs;
53875 - atomic_t num_renames;
53876 - atomic_t num_t2renames;
53877 - atomic_t num_ffirst;
53878 - atomic_t num_fnext;
53879 - atomic_t num_fclose;
53880 - atomic_t num_hardlinks;
53881 - atomic_t num_symlinks;
53882 - atomic_t num_locks;
53883 - atomic_t num_acl_get;
53884 - atomic_t num_acl_set;
53885 + atomic_unchecked_t num_writes;
53886 + atomic_unchecked_t num_reads;
53887 + atomic_unchecked_t num_flushes;
53888 + atomic_unchecked_t num_oplock_brks;
53889 + atomic_unchecked_t num_opens;
53890 + atomic_unchecked_t num_closes;
53891 + atomic_unchecked_t num_deletes;
53892 + atomic_unchecked_t num_mkdirs;
53893 + atomic_unchecked_t num_posixopens;
53894 + atomic_unchecked_t num_posixmkdirs;
53895 + atomic_unchecked_t num_rmdirs;
53896 + atomic_unchecked_t num_renames;
53897 + atomic_unchecked_t num_t2renames;
53898 + atomic_unchecked_t num_ffirst;
53899 + atomic_unchecked_t num_fnext;
53900 + atomic_unchecked_t num_fclose;
53901 + atomic_unchecked_t num_hardlinks;
53902 + atomic_unchecked_t num_symlinks;
53903 + atomic_unchecked_t num_locks;
53904 + atomic_unchecked_t num_acl_get;
53905 + atomic_unchecked_t num_acl_set;
53906 } cifs_stats;
53907 #ifdef CONFIG_CIFS_SMB2
53908 struct {
53909 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53910 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53911 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53912 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53913 } smb2_stats;
53914 #endif /* CONFIG_CIFS_SMB2 */
53915 } stats;
53916 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53917 }
53918
53919 #ifdef CONFIG_CIFS_STATS
53920 -#define cifs_stats_inc atomic_inc
53921 +#define cifs_stats_inc atomic_inc_unchecked
53922
53923 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53924 unsigned int bytes)
53925 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53926 /* Various Debug counters */
53927 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53928 #ifdef CONFIG_CIFS_STATS2
53929 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53930 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53931 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53932 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53933 #endif
53934 GLOBAL_EXTERN atomic_t smBufAllocCount;
53935 GLOBAL_EXTERN atomic_t midCount;
53936 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53937 index 562044f..4af6a17 100644
53938 --- a/fs/cifs/link.c
53939 +++ b/fs/cifs/link.c
53940 @@ -638,7 +638,7 @@ symlink_exit:
53941
53942 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53943 {
53944 - char *p = nd_get_link(nd);
53945 + const char *p = nd_get_link(nd);
53946 if (!IS_ERR(p))
53947 kfree(p);
53948 }
53949 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53950 index f7d4b22..1254377 100644
53951 --- a/fs/cifs/misc.c
53952 +++ b/fs/cifs/misc.c
53953 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53954 memset(ret_buf, 0, buf_size + 3);
53955 atomic_inc(&bufAllocCount);
53956 #ifdef CONFIG_CIFS_STATS2
53957 - atomic_inc(&totBufAllocCount);
53958 + atomic_inc_unchecked(&totBufAllocCount);
53959 #endif /* CONFIG_CIFS_STATS2 */
53960 }
53961
53962 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53963 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53964 atomic_inc(&smBufAllocCount);
53965 #ifdef CONFIG_CIFS_STATS2
53966 - atomic_inc(&totSmBufAllocCount);
53967 + atomic_inc_unchecked(&totSmBufAllocCount);
53968 #endif /* CONFIG_CIFS_STATS2 */
53969
53970 }
53971 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53972 index 6094397..51e576f 100644
53973 --- a/fs/cifs/smb1ops.c
53974 +++ b/fs/cifs/smb1ops.c
53975 @@ -590,27 +590,27 @@ static void
53976 cifs_clear_stats(struct cifs_tcon *tcon)
53977 {
53978 #ifdef CONFIG_CIFS_STATS
53979 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53980 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53981 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53982 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53983 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53984 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53985 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53986 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53987 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53988 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53989 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53990 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53991 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53992 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53993 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53994 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53995 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53996 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53997 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53998 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53999 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54000 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54001 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54002 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54003 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54004 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54005 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54006 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54007 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54008 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54009 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54010 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54011 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54012 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54013 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54014 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54015 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54016 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54017 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54018 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54019 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54020 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54021 #endif
54022 }
54023
54024 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54025 {
54026 #ifdef CONFIG_CIFS_STATS
54027 seq_printf(m, " Oplocks breaks: %d",
54028 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54030 seq_printf(m, "\nReads: %d Bytes: %llu",
54031 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54032 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54033 (long long)(tcon->bytes_read));
54034 seq_printf(m, "\nWrites: %d Bytes: %llu",
54035 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54036 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54037 (long long)(tcon->bytes_written));
54038 seq_printf(m, "\nFlushes: %d",
54039 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54040 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54041 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54042 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54043 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54044 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54045 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54046 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54047 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54048 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54049 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54050 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54051 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54052 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54053 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54054 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54055 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54056 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54057 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54058 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54059 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54060 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54061 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54062 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54063 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54064 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54065 seq_printf(m, "\nRenames: %d T2 Renames %d",
54066 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54067 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54068 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54069 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54070 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54071 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54072 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54073 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54074 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54075 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54076 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54077 #endif
54078 }
54079
54080 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54081 index f259e6c..ca948ff 100644
54082 --- a/fs/cifs/smb2ops.c
54083 +++ b/fs/cifs/smb2ops.c
54084 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54085 #ifdef CONFIG_CIFS_STATS
54086 int i;
54087 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54088 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54089 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54090 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54091 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54092 }
54093 #endif
54094 }
54095 @@ -310,65 +310,65 @@ static void
54096 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54097 {
54098 #ifdef CONFIG_CIFS_STATS
54099 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54100 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54101 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54102 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54103 seq_printf(m, "\nNegotiates: %d sent %d failed",
54104 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54105 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54106 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54107 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54108 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54109 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54110 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54111 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54112 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54113 seq_printf(m, "\nLogoffs: %d sent %d failed",
54114 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54115 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54116 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54117 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54118 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54119 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54120 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54121 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54122 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54123 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54124 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54125 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54126 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54127 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54128 seq_printf(m, "\nCreates: %d sent %d failed",
54129 - atomic_read(&sent[SMB2_CREATE_HE]),
54130 - atomic_read(&failed[SMB2_CREATE_HE]));
54131 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54132 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54133 seq_printf(m, "\nCloses: %d sent %d failed",
54134 - atomic_read(&sent[SMB2_CLOSE_HE]),
54135 - atomic_read(&failed[SMB2_CLOSE_HE]));
54136 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54137 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54138 seq_printf(m, "\nFlushes: %d sent %d failed",
54139 - atomic_read(&sent[SMB2_FLUSH_HE]),
54140 - atomic_read(&failed[SMB2_FLUSH_HE]));
54141 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54142 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54143 seq_printf(m, "\nReads: %d sent %d failed",
54144 - atomic_read(&sent[SMB2_READ_HE]),
54145 - atomic_read(&failed[SMB2_READ_HE]));
54146 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54147 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54148 seq_printf(m, "\nWrites: %d sent %d failed",
54149 - atomic_read(&sent[SMB2_WRITE_HE]),
54150 - atomic_read(&failed[SMB2_WRITE_HE]));
54151 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54152 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54153 seq_printf(m, "\nLocks: %d sent %d failed",
54154 - atomic_read(&sent[SMB2_LOCK_HE]),
54155 - atomic_read(&failed[SMB2_LOCK_HE]));
54156 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54157 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54158 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54159 - atomic_read(&sent[SMB2_IOCTL_HE]),
54160 - atomic_read(&failed[SMB2_IOCTL_HE]));
54161 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54162 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54163 seq_printf(m, "\nCancels: %d sent %d failed",
54164 - atomic_read(&sent[SMB2_CANCEL_HE]),
54165 - atomic_read(&failed[SMB2_CANCEL_HE]));
54166 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54167 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54168 seq_printf(m, "\nEchos: %d sent %d failed",
54169 - atomic_read(&sent[SMB2_ECHO_HE]),
54170 - atomic_read(&failed[SMB2_ECHO_HE]));
54171 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54172 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54173 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54174 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54175 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54176 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54177 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54178 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54179 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54180 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54181 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54182 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54183 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54184 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54185 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54186 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54187 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54188 seq_printf(m, "\nSetInfos: %d sent %d failed",
54189 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54190 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54191 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54192 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54193 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54194 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54195 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54196 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54197 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54198 #endif
54199 }
54200
54201 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54202 index abc9c28..3fdae28 100644
54203 --- a/fs/cifs/smb2pdu.c
54204 +++ b/fs/cifs/smb2pdu.c
54205 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54206 default:
54207 cifs_dbg(VFS, "info level %u isn't supported\n",
54208 srch_inf->info_level);
54209 - rc = -EINVAL;
54210 - goto qdir_exit;
54211 + return -EINVAL;
54212 }
54213
54214 req->FileIndex = cpu_to_le32(index);
54215 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54216 index 1da168c..8bc7ff6 100644
54217 --- a/fs/coda/cache.c
54218 +++ b/fs/coda/cache.c
54219 @@ -24,7 +24,7 @@
54220 #include "coda_linux.h"
54221 #include "coda_cache.h"
54222
54223 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54224 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54225
54226 /* replace or extend an acl cache hit */
54227 void coda_cache_enter(struct inode *inode, int mask)
54228 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54229 struct coda_inode_info *cii = ITOC(inode);
54230
54231 spin_lock(&cii->c_lock);
54232 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54233 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54234 if (!uid_eq(cii->c_uid, current_fsuid())) {
54235 cii->c_uid = current_fsuid();
54236 cii->c_cached_perm = mask;
54237 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54238 {
54239 struct coda_inode_info *cii = ITOC(inode);
54240 spin_lock(&cii->c_lock);
54241 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54242 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54243 spin_unlock(&cii->c_lock);
54244 }
54245
54246 /* remove all acl caches */
54247 void coda_cache_clear_all(struct super_block *sb)
54248 {
54249 - atomic_inc(&permission_epoch);
54250 + atomic_inc_unchecked(&permission_epoch);
54251 }
54252
54253
54254 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54255 spin_lock(&cii->c_lock);
54256 hit = (mask & cii->c_cached_perm) == mask &&
54257 uid_eq(cii->c_uid, current_fsuid()) &&
54258 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54259 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54260 spin_unlock(&cii->c_lock);
54261
54262 return hit;
54263 diff --git a/fs/compat.c b/fs/compat.c
54264 index 6af20de..fec3fbb 100644
54265 --- a/fs/compat.c
54266 +++ b/fs/compat.c
54267 @@ -54,7 +54,7 @@
54268 #include <asm/ioctls.h>
54269 #include "internal.h"
54270
54271 -int compat_log = 1;
54272 +int compat_log = 0;
54273
54274 int compat_printk(const char *fmt, ...)
54275 {
54276 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54277
54278 set_fs(KERNEL_DS);
54279 /* The __user pointer cast is valid because of the set_fs() */
54280 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54281 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54282 set_fs(oldfs);
54283 /* truncating is ok because it's a user address */
54284 if (!ret)
54285 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54286 goto out;
54287
54288 ret = -EINVAL;
54289 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54290 + if (nr_segs > UIO_MAXIOV)
54291 goto out;
54292 if (nr_segs > fast_segs) {
54293 ret = -ENOMEM;
54294 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54295 struct compat_readdir_callback {
54296 struct dir_context ctx;
54297 struct compat_old_linux_dirent __user *dirent;
54298 + struct file * file;
54299 int result;
54300 };
54301
54302 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54303 buf->result = -EOVERFLOW;
54304 return -EOVERFLOW;
54305 }
54306 +
54307 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54308 + return 0;
54309 +
54310 buf->result++;
54311 dirent = buf->dirent;
54312 if (!access_ok(VERIFY_WRITE, dirent,
54313 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54314 if (!f.file)
54315 return -EBADF;
54316
54317 + buf.file = f.file;
54318 error = iterate_dir(f.file, &buf.ctx);
54319 if (buf.result)
54320 error = buf.result;
54321 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54322 struct dir_context ctx;
54323 struct compat_linux_dirent __user *current_dir;
54324 struct compat_linux_dirent __user *previous;
54325 + struct file * file;
54326 int count;
54327 int error;
54328 };
54329 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54330 buf->error = -EOVERFLOW;
54331 return -EOVERFLOW;
54332 }
54333 +
54334 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54335 + return 0;
54336 +
54337 dirent = buf->previous;
54338 if (dirent) {
54339 if (__put_user(offset, &dirent->d_off))
54340 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54341 if (!f.file)
54342 return -EBADF;
54343
54344 + buf.file = f.file;
54345 error = iterate_dir(f.file, &buf.ctx);
54346 if (error >= 0)
54347 error = buf.error;
54348 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54349 struct dir_context ctx;
54350 struct linux_dirent64 __user *current_dir;
54351 struct linux_dirent64 __user *previous;
54352 + struct file * file;
54353 int count;
54354 int error;
54355 };
54356 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54357 buf->error = -EINVAL; /* only used if we fail.. */
54358 if (reclen > buf->count)
54359 return -EINVAL;
54360 +
54361 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54362 + return 0;
54363 +
54364 dirent = buf->previous;
54365
54366 if (dirent) {
54367 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54368 if (!f.file)
54369 return -EBADF;
54370
54371 + buf.file = f.file;
54372 error = iterate_dir(f.file, &buf.ctx);
54373 if (error >= 0)
54374 error = buf.error;
54375 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54376 index a81147e..20bf2b5 100644
54377 --- a/fs/compat_binfmt_elf.c
54378 +++ b/fs/compat_binfmt_elf.c
54379 @@ -30,11 +30,13 @@
54380 #undef elf_phdr
54381 #undef elf_shdr
54382 #undef elf_note
54383 +#undef elf_dyn
54384 #undef elf_addr_t
54385 #define elfhdr elf32_hdr
54386 #define elf_phdr elf32_phdr
54387 #define elf_shdr elf32_shdr
54388 #define elf_note elf32_note
54389 +#define elf_dyn Elf32_Dyn
54390 #define elf_addr_t Elf32_Addr
54391
54392 /*
54393 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54394 index 5d19acf..9ab093b 100644
54395 --- a/fs/compat_ioctl.c
54396 +++ b/fs/compat_ioctl.c
54397 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54398 return -EFAULT;
54399 if (__get_user(udata, &ss32->iomem_base))
54400 return -EFAULT;
54401 - ss.iomem_base = compat_ptr(udata);
54402 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54403 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54404 __get_user(ss.port_high, &ss32->port_high))
54405 return -EFAULT;
54406 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54407 for (i = 0; i < nmsgs; i++) {
54408 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54409 return -EFAULT;
54410 - if (get_user(datap, &umsgs[i].buf) ||
54411 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54412 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54413 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54414 return -EFAULT;
54415 }
54416 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54417 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54418 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54419 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54420 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54421 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54422 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54423 return -EFAULT;
54424
54425 return ioctl_preallocate(file, p);
54426 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54427 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54428 {
54429 unsigned int a, b;
54430 - a = *(unsigned int *)p;
54431 - b = *(unsigned int *)q;
54432 + a = *(const unsigned int *)p;
54433 + b = *(const unsigned int *)q;
54434 if (a > b)
54435 return 1;
54436 if (a < b)
54437 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54438 index 277bd1b..f312c9e 100644
54439 --- a/fs/configfs/dir.c
54440 +++ b/fs/configfs/dir.c
54441 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54442 }
54443 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54444 struct configfs_dirent *next;
54445 - const char *name;
54446 + const unsigned char * name;
54447 + char d_name[sizeof(next->s_dentry->d_iname)];
54448 int len;
54449 struct inode *inode = NULL;
54450
54451 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54452 continue;
54453
54454 name = configfs_get_name(next);
54455 - len = strlen(name);
54456 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54457 + len = next->s_dentry->d_name.len;
54458 + memcpy(d_name, name, len);
54459 + name = d_name;
54460 + } else
54461 + len = strlen(name);
54462
54463 /*
54464 * We'll have a dentry and an inode for
54465 diff --git a/fs/coredump.c b/fs/coredump.c
54466 index 72f816d..1ba8eff 100644
54467 --- a/fs/coredump.c
54468 +++ b/fs/coredump.c
54469 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54470 struct pipe_inode_info *pipe = file->private_data;
54471
54472 pipe_lock(pipe);
54473 - pipe->readers++;
54474 - pipe->writers--;
54475 + atomic_inc(&pipe->readers);
54476 + atomic_dec(&pipe->writers);
54477 wake_up_interruptible_sync(&pipe->wait);
54478 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54479 pipe_unlock(pipe);
54480 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54481 * We actually want wait_event_freezable() but then we need
54482 * to clear TIF_SIGPENDING and improve dump_interrupted().
54483 */
54484 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54485 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54486
54487 pipe_lock(pipe);
54488 - pipe->readers--;
54489 - pipe->writers++;
54490 + atomic_dec(&pipe->readers);
54491 + atomic_inc(&pipe->writers);
54492 pipe_unlock(pipe);
54493 }
54494
54495 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54496 struct files_struct *displaced;
54497 bool need_nonrelative = false;
54498 bool core_dumped = false;
54499 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54500 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54501 + long signr = siginfo->si_signo;
54502 struct coredump_params cprm = {
54503 .siginfo = siginfo,
54504 .regs = signal_pt_regs(),
54505 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54506 .mm_flags = mm->flags,
54507 };
54508
54509 - audit_core_dumps(siginfo->si_signo);
54510 + audit_core_dumps(signr);
54511 +
54512 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54513 + gr_handle_brute_attach(cprm.mm_flags);
54514
54515 binfmt = mm->binfmt;
54516 if (!binfmt || !binfmt->core_dump)
54517 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54518 need_nonrelative = true;
54519 }
54520
54521 - retval = coredump_wait(siginfo->si_signo, &core_state);
54522 + retval = coredump_wait(signr, &core_state);
54523 if (retval < 0)
54524 goto fail_creds;
54525
54526 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54527 }
54528 cprm.limit = RLIM_INFINITY;
54529
54530 - dump_count = atomic_inc_return(&core_dump_count);
54531 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54532 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54533 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54534 task_tgid_vnr(current), current->comm);
54535 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54536 } else {
54537 struct inode *inode;
54538
54539 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54540 +
54541 if (cprm.limit < binfmt->min_coredump)
54542 goto fail_unlock;
54543
54544 @@ -664,7 +670,7 @@ close_fail:
54545 filp_close(cprm.file, NULL);
54546 fail_dropcount:
54547 if (ispipe)
54548 - atomic_dec(&core_dump_count);
54549 + atomic_dec_unchecked(&core_dump_count);
54550 fail_unlock:
54551 kfree(cn.corename);
54552 coredump_finish(mm, core_dumped);
54553 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54554 {
54555 return !dump_interrupted() &&
54556 access_ok(VERIFY_READ, addr, nr) &&
54557 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54558 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54559 }
54560 EXPORT_SYMBOL(dump_write);
54561
54562 diff --git a/fs/dcache.c b/fs/dcache.c
54563 index b949af8..5978926 100644
54564 --- a/fs/dcache.c
54565 +++ b/fs/dcache.c
54566 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54567 mempages -= reserve;
54568
54569 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54570 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54571 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54572 + SLAB_NO_SANITIZE, NULL);
54573
54574 dcache_init();
54575 inode_init();
54576 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54577 index c7c83ff..bda9461 100644
54578 --- a/fs/debugfs/inode.c
54579 +++ b/fs/debugfs/inode.c
54580 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54581 */
54582 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54583 {
54584 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54585 + return __create_file(name, S_IFDIR | S_IRWXU,
54586 +#else
54587 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54588 +#endif
54589 parent, NULL, NULL);
54590 }
54591 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54592 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54593 index 67e9b63..a9adb68 100644
54594 --- a/fs/ecryptfs/inode.c
54595 +++ b/fs/ecryptfs/inode.c
54596 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54597 old_fs = get_fs();
54598 set_fs(get_ds());
54599 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54600 - (char __user *)lower_buf,
54601 + (char __force_user *)lower_buf,
54602 PATH_MAX);
54603 set_fs(old_fs);
54604 if (rc < 0)
54605 @@ -706,7 +706,7 @@ out:
54606 static void
54607 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54608 {
54609 - char *buf = nd_get_link(nd);
54610 + const char *buf = nd_get_link(nd);
54611 if (!IS_ERR(buf)) {
54612 /* Free the char* */
54613 kfree(buf);
54614 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54615 index e4141f2..d8263e8 100644
54616 --- a/fs/ecryptfs/miscdev.c
54617 +++ b/fs/ecryptfs/miscdev.c
54618 @@ -304,7 +304,7 @@ check_list:
54619 goto out_unlock_msg_ctx;
54620 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54621 if (msg_ctx->msg) {
54622 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54623 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54624 goto out_unlock_msg_ctx;
54625 i += packet_length_size;
54626 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54627 diff --git a/fs/exec.c b/fs/exec.c
54628 index fd774c7..1c6a7bf 100644
54629 --- a/fs/exec.c
54630 +++ b/fs/exec.c
54631 @@ -55,8 +55,20 @@
54632 #include <linux/pipe_fs_i.h>
54633 #include <linux/oom.h>
54634 #include <linux/compat.h>
54635 +#include <linux/random.h>
54636 +#include <linux/seq_file.h>
54637 +#include <linux/coredump.h>
54638 +#include <linux/mman.h>
54639 +
54640 +#ifdef CONFIG_PAX_REFCOUNT
54641 +#include <linux/kallsyms.h>
54642 +#include <linux/kdebug.h>
54643 +#endif
54644 +
54645 +#include <trace/events/fs.h>
54646
54647 #include <asm/uaccess.h>
54648 +#include <asm/sections.h>
54649 #include <asm/mmu_context.h>
54650 #include <asm/tlb.h>
54651
54652 @@ -66,17 +78,32 @@
54653
54654 #include <trace/events/sched.h>
54655
54656 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54657 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54658 +{
54659 + 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");
54660 +}
54661 +#endif
54662 +
54663 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54664 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54665 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54666 +#endif
54667 +
54668 int suid_dumpable = 0;
54669
54670 static LIST_HEAD(formats);
54671 static DEFINE_RWLOCK(binfmt_lock);
54672
54673 +extern int gr_process_kernel_exec_ban(void);
54674 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54675 +
54676 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54677 {
54678 BUG_ON(!fmt);
54679 write_lock(&binfmt_lock);
54680 - insert ? list_add(&fmt->lh, &formats) :
54681 - list_add_tail(&fmt->lh, &formats);
54682 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54683 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54684 write_unlock(&binfmt_lock);
54685 }
54686
54687 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54688 void unregister_binfmt(struct linux_binfmt * fmt)
54689 {
54690 write_lock(&binfmt_lock);
54691 - list_del(&fmt->lh);
54692 + pax_list_del((struct list_head *)&fmt->lh);
54693 write_unlock(&binfmt_lock);
54694 }
54695
54696 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54697 int write)
54698 {
54699 struct page *page;
54700 - int ret;
54701
54702 -#ifdef CONFIG_STACK_GROWSUP
54703 - if (write) {
54704 - ret = expand_downwards(bprm->vma, pos);
54705 - if (ret < 0)
54706 - return NULL;
54707 - }
54708 -#endif
54709 - ret = get_user_pages(current, bprm->mm, pos,
54710 - 1, write, 1, &page, NULL);
54711 - if (ret <= 0)
54712 + if (0 > expand_downwards(bprm->vma, pos))
54713 + return NULL;
54714 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54715 return NULL;
54716
54717 if (write) {
54718 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54719 if (size <= ARG_MAX)
54720 return page;
54721
54722 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54723 + // only allow 512KB for argv+env on suid/sgid binaries
54724 + // to prevent easy ASLR exhaustion
54725 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54726 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54727 + (size > (512 * 1024))) {
54728 + put_page(page);
54729 + return NULL;
54730 + }
54731 +#endif
54732 +
54733 /*
54734 * Limit to 1/4-th the stack size for the argv+env strings.
54735 * This ensures that:
54736 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54737 vma->vm_end = STACK_TOP_MAX;
54738 vma->vm_start = vma->vm_end - PAGE_SIZE;
54739 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54740 +
54741 +#ifdef CONFIG_PAX_SEGMEXEC
54742 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54743 +#endif
54744 +
54745 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54746 INIT_LIST_HEAD(&vma->anon_vma_chain);
54747
54748 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54749 mm->stack_vm = mm->total_vm = 1;
54750 up_write(&mm->mmap_sem);
54751 bprm->p = vma->vm_end - sizeof(void *);
54752 +
54753 +#ifdef CONFIG_PAX_RANDUSTACK
54754 + if (randomize_va_space)
54755 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54756 +#endif
54757 +
54758 return 0;
54759 err:
54760 up_write(&mm->mmap_sem);
54761 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54762 } ptr;
54763 };
54764
54765 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54766 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54767 {
54768 const char __user *native;
54769
54770 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54771 compat_uptr_t compat;
54772
54773 if (get_user(compat, argv.ptr.compat + nr))
54774 - return ERR_PTR(-EFAULT);
54775 + return (const char __force_user *)ERR_PTR(-EFAULT);
54776
54777 return compat_ptr(compat);
54778 }
54779 #endif
54780
54781 if (get_user(native, argv.ptr.native + nr))
54782 - return ERR_PTR(-EFAULT);
54783 + return (const char __force_user *)ERR_PTR(-EFAULT);
54784
54785 return native;
54786 }
54787 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54788 if (!p)
54789 break;
54790
54791 - if (IS_ERR(p))
54792 + if (IS_ERR((const char __force_kernel *)p))
54793 return -EFAULT;
54794
54795 if (i >= max)
54796 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54797
54798 ret = -EFAULT;
54799 str = get_user_arg_ptr(argv, argc);
54800 - if (IS_ERR(str))
54801 + if (IS_ERR((const char __force_kernel *)str))
54802 goto out;
54803
54804 len = strnlen_user(str, MAX_ARG_STRLEN);
54805 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54806 int r;
54807 mm_segment_t oldfs = get_fs();
54808 struct user_arg_ptr argv = {
54809 - .ptr.native = (const char __user *const __user *)__argv,
54810 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54811 };
54812
54813 set_fs(KERNEL_DS);
54814 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54815 unsigned long new_end = old_end - shift;
54816 struct mmu_gather tlb;
54817
54818 - BUG_ON(new_start > new_end);
54819 + if (new_start >= new_end || new_start < mmap_min_addr)
54820 + return -ENOMEM;
54821
54822 /*
54823 * ensure there are no vmas between where we want to go
54824 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54825 if (vma != find_vma(mm, new_start))
54826 return -EFAULT;
54827
54828 +#ifdef CONFIG_PAX_SEGMEXEC
54829 + BUG_ON(pax_find_mirror_vma(vma));
54830 +#endif
54831 +
54832 /*
54833 * cover the whole range: [new_start, old_end)
54834 */
54835 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54836 stack_top = arch_align_stack(stack_top);
54837 stack_top = PAGE_ALIGN(stack_top);
54838
54839 - if (unlikely(stack_top < mmap_min_addr) ||
54840 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54841 - return -ENOMEM;
54842 -
54843 stack_shift = vma->vm_end - stack_top;
54844
54845 bprm->p -= stack_shift;
54846 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54847 bprm->exec -= stack_shift;
54848
54849 down_write(&mm->mmap_sem);
54850 +
54851 + /* Move stack pages down in memory. */
54852 + if (stack_shift) {
54853 + ret = shift_arg_pages(vma, stack_shift);
54854 + if (ret)
54855 + goto out_unlock;
54856 + }
54857 +
54858 vm_flags = VM_STACK_FLAGS;
54859
54860 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54861 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54862 + vm_flags &= ~VM_EXEC;
54863 +
54864 +#ifdef CONFIG_PAX_MPROTECT
54865 + if (mm->pax_flags & MF_PAX_MPROTECT)
54866 + vm_flags &= ~VM_MAYEXEC;
54867 +#endif
54868 +
54869 + }
54870 +#endif
54871 +
54872 /*
54873 * Adjust stack execute permissions; explicitly enable for
54874 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54875 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54876 goto out_unlock;
54877 BUG_ON(prev != vma);
54878
54879 - /* Move stack pages down in memory. */
54880 - if (stack_shift) {
54881 - ret = shift_arg_pages(vma, stack_shift);
54882 - if (ret)
54883 - goto out_unlock;
54884 - }
54885 -
54886 /* mprotect_fixup is overkill to remove the temporary stack flags */
54887 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54888
54889 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54890 #endif
54891 current->mm->start_stack = bprm->p;
54892 ret = expand_stack(vma, stack_base);
54893 +
54894 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54895 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54896 + unsigned long size;
54897 + vm_flags_t vm_flags;
54898 +
54899 + size = STACK_TOP - vma->vm_end;
54900 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54901 +
54902 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54903 +
54904 +#ifdef CONFIG_X86
54905 + if (!ret) {
54906 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54907 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54908 + }
54909 +#endif
54910 +
54911 + }
54912 +#endif
54913 +
54914 if (ret)
54915 ret = -EFAULT;
54916
54917 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54918
54919 fsnotify_open(file);
54920
54921 + trace_open_exec(name);
54922 +
54923 err = deny_write_access(file);
54924 if (err)
54925 goto exit;
54926 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54927 old_fs = get_fs();
54928 set_fs(get_ds());
54929 /* The cast to a user pointer is valid due to the set_fs() */
54930 - result = vfs_read(file, (void __user *)addr, count, &pos);
54931 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54932 set_fs(old_fs);
54933 return result;
54934 }
54935 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54936 }
54937 rcu_read_unlock();
54938
54939 - if (p->fs->users > n_fs) {
54940 + if (atomic_read(&p->fs->users) > n_fs) {
54941 bprm->unsafe |= LSM_UNSAFE_SHARE;
54942 } else {
54943 res = -EAGAIN;
54944 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54945
54946 EXPORT_SYMBOL(search_binary_handler);
54947
54948 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54949 +static DEFINE_PER_CPU(u64, exec_counter);
54950 +static int __init init_exec_counters(void)
54951 +{
54952 + unsigned int cpu;
54953 +
54954 + for_each_possible_cpu(cpu) {
54955 + per_cpu(exec_counter, cpu) = (u64)cpu;
54956 + }
54957 +
54958 + return 0;
54959 +}
54960 +early_initcall(init_exec_counters);
54961 +static inline void increment_exec_counter(void)
54962 +{
54963 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54964 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54965 +}
54966 +#else
54967 +static inline void increment_exec_counter(void) {}
54968 +#endif
54969 +
54970 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54971 + struct user_arg_ptr argv);
54972 +
54973 /*
54974 * sys_execve() executes a new program.
54975 */
54976 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54977 struct user_arg_ptr argv,
54978 struct user_arg_ptr envp)
54979 {
54980 +#ifdef CONFIG_GRKERNSEC
54981 + struct file *old_exec_file;
54982 + struct acl_subject_label *old_acl;
54983 + struct rlimit old_rlim[RLIM_NLIMITS];
54984 +#endif
54985 struct linux_binprm *bprm;
54986 struct file *file;
54987 struct files_struct *displaced;
54988 bool clear_in_exec;
54989 int retval;
54990
54991 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54992 +
54993 /*
54994 * We move the actual failure in case of RLIMIT_NPROC excess from
54995 * set*uid() to execve() because too many poorly written programs
54996 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54997 if (IS_ERR(file))
54998 goto out_unmark;
54999
55000 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55001 + retval = -EPERM;
55002 + goto out_file;
55003 + }
55004 +
55005 sched_exec();
55006
55007 bprm->file = file;
55008 bprm->filename = filename;
55009 bprm->interp = filename;
55010
55011 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55012 + retval = -EACCES;
55013 + goto out_file;
55014 + }
55015 +
55016 retval = bprm_mm_init(bprm);
55017 if (retval)
55018 goto out_file;
55019 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
55020 if (retval < 0)
55021 goto out;
55022
55023 +#ifdef CONFIG_GRKERNSEC
55024 + old_acl = current->acl;
55025 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55026 + old_exec_file = current->exec_file;
55027 + get_file(file);
55028 + current->exec_file = file;
55029 +#endif
55030 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55031 + /* limit suid stack to 8MB
55032 + * we saved the old limits above and will restore them if this exec fails
55033 + */
55034 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55035 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55036 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55037 +#endif
55038 +
55039 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55040 + retval = -EPERM;
55041 + goto out_fail;
55042 + }
55043 +
55044 + if (!gr_tpe_allow(file)) {
55045 + retval = -EACCES;
55046 + goto out_fail;
55047 + }
55048 +
55049 + if (gr_check_crash_exec(file)) {
55050 + retval = -EACCES;
55051 + goto out_fail;
55052 + }
55053 +
55054 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55055 + bprm->unsafe);
55056 + if (retval < 0)
55057 + goto out_fail;
55058 +
55059 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55060 if (retval < 0)
55061 - goto out;
55062 + goto out_fail;
55063
55064 bprm->exec = bprm->p;
55065 retval = copy_strings(bprm->envc, envp, bprm);
55066 if (retval < 0)
55067 - goto out;
55068 + goto out_fail;
55069
55070 retval = copy_strings(bprm->argc, argv, bprm);
55071 if (retval < 0)
55072 - goto out;
55073 + goto out_fail;
55074 +
55075 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55076 +
55077 + gr_handle_exec_args(bprm, argv);
55078
55079 retval = search_binary_handler(bprm);
55080 if (retval < 0)
55081 - goto out;
55082 + goto out_fail;
55083 +#ifdef CONFIG_GRKERNSEC
55084 + if (old_exec_file)
55085 + fput(old_exec_file);
55086 +#endif
55087
55088 /* execve succeeded */
55089 +
55090 + increment_exec_counter();
55091 current->fs->in_exec = 0;
55092 current->in_execve = 0;
55093 acct_update_integrals(current);
55094 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55095 put_files_struct(displaced);
55096 return retval;
55097
55098 +out_fail:
55099 +#ifdef CONFIG_GRKERNSEC
55100 + current->acl = old_acl;
55101 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55102 + fput(current->exec_file);
55103 + current->exec_file = old_exec_file;
55104 +#endif
55105 +
55106 out:
55107 if (bprm->mm) {
55108 acct_arg_size(bprm, 0);
55109 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55110 return error;
55111 }
55112 #endif
55113 +
55114 +int pax_check_flags(unsigned long *flags)
55115 +{
55116 + int retval = 0;
55117 +
55118 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55119 + if (*flags & MF_PAX_SEGMEXEC)
55120 + {
55121 + *flags &= ~MF_PAX_SEGMEXEC;
55122 + retval = -EINVAL;
55123 + }
55124 +#endif
55125 +
55126 + if ((*flags & MF_PAX_PAGEEXEC)
55127 +
55128 +#ifdef CONFIG_PAX_PAGEEXEC
55129 + && (*flags & MF_PAX_SEGMEXEC)
55130 +#endif
55131 +
55132 + )
55133 + {
55134 + *flags &= ~MF_PAX_PAGEEXEC;
55135 + retval = -EINVAL;
55136 + }
55137 +
55138 + if ((*flags & MF_PAX_MPROTECT)
55139 +
55140 +#ifdef CONFIG_PAX_MPROTECT
55141 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55142 +#endif
55143 +
55144 + )
55145 + {
55146 + *flags &= ~MF_PAX_MPROTECT;
55147 + retval = -EINVAL;
55148 + }
55149 +
55150 + if ((*flags & MF_PAX_EMUTRAMP)
55151 +
55152 +#ifdef CONFIG_PAX_EMUTRAMP
55153 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55154 +#endif
55155 +
55156 + )
55157 + {
55158 + *flags &= ~MF_PAX_EMUTRAMP;
55159 + retval = -EINVAL;
55160 + }
55161 +
55162 + return retval;
55163 +}
55164 +
55165 +EXPORT_SYMBOL(pax_check_flags);
55166 +
55167 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55168 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55169 +{
55170 + char *pathname = d_path(path, buf, buflen);
55171 +
55172 + if (IS_ERR(pathname))
55173 + goto toolong;
55174 +
55175 + pathname = mangle_path(buf, pathname, "\t\n\\");
55176 + if (!pathname)
55177 + goto toolong;
55178 +
55179 + *pathname = 0;
55180 + return buf;
55181 +
55182 +toolong:
55183 + return "<path too long>";
55184 +}
55185 +EXPORT_SYMBOL(pax_get_path);
55186 +
55187 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55188 +{
55189 + struct task_struct *tsk = current;
55190 + struct mm_struct *mm = current->mm;
55191 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55192 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55193 + char *path_exec = NULL;
55194 + char *path_fault = NULL;
55195 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55196 + siginfo_t info = { };
55197 +
55198 + if (buffer_exec && buffer_fault) {
55199 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55200 +
55201 + down_read(&mm->mmap_sem);
55202 + vma = mm->mmap;
55203 + while (vma && (!vma_exec || !vma_fault)) {
55204 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55205 + vma_exec = vma;
55206 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55207 + vma_fault = vma;
55208 + vma = vma->vm_next;
55209 + }
55210 + if (vma_exec)
55211 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55212 + if (vma_fault) {
55213 + start = vma_fault->vm_start;
55214 + end = vma_fault->vm_end;
55215 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55216 + if (vma_fault->vm_file)
55217 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55218 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55219 + path_fault = "<heap>";
55220 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55221 + path_fault = "<stack>";
55222 + else
55223 + path_fault = "<anonymous mapping>";
55224 + }
55225 + up_read(&mm->mmap_sem);
55226 + }
55227 + if (tsk->signal->curr_ip)
55228 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55229 + else
55230 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55231 + 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),
55232 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55233 + free_page((unsigned long)buffer_exec);
55234 + free_page((unsigned long)buffer_fault);
55235 + pax_report_insns(regs, pc, sp);
55236 + info.si_signo = SIGKILL;
55237 + info.si_errno = 0;
55238 + info.si_code = SI_KERNEL;
55239 + info.si_pid = 0;
55240 + info.si_uid = 0;
55241 + do_coredump(&info);
55242 +}
55243 +#endif
55244 +
55245 +#ifdef CONFIG_PAX_REFCOUNT
55246 +void pax_report_refcount_overflow(struct pt_regs *regs)
55247 +{
55248 + if (current->signal->curr_ip)
55249 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55250 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55251 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55252 + else
55253 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55254 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55255 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55256 + preempt_disable();
55257 + show_regs(regs);
55258 + preempt_enable();
55259 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55260 +}
55261 +#endif
55262 +
55263 +#ifdef CONFIG_PAX_USERCOPY
55264 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55265 +static noinline int check_stack_object(const void *obj, unsigned long len)
55266 +{
55267 + const void * const stack = task_stack_page(current);
55268 + const void * const stackend = stack + THREAD_SIZE;
55269 +
55270 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55271 + const void *frame = NULL;
55272 + const void *oldframe;
55273 +#endif
55274 +
55275 + if (obj + len < obj)
55276 + return -1;
55277 +
55278 + if (obj + len <= stack || stackend <= obj)
55279 + return 0;
55280 +
55281 + if (obj < stack || stackend < obj + len)
55282 + return -1;
55283 +
55284 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55285 + oldframe = __builtin_frame_address(1);
55286 + if (oldframe)
55287 + frame = __builtin_frame_address(2);
55288 + /*
55289 + low ----------------------------------------------> high
55290 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55291 + ^----------------^
55292 + allow copies only within here
55293 + */
55294 + while (stack <= frame && frame < stackend) {
55295 + /* if obj + len extends past the last frame, this
55296 + check won't pass and the next frame will be 0,
55297 + causing us to bail out and correctly report
55298 + the copy as invalid
55299 + */
55300 + if (obj + len <= frame)
55301 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55302 + oldframe = frame;
55303 + frame = *(const void * const *)frame;
55304 + }
55305 + return -1;
55306 +#else
55307 + return 1;
55308 +#endif
55309 +}
55310 +
55311 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55312 +{
55313 + if (current->signal->curr_ip)
55314 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55315 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55316 + else
55317 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55318 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55319 + dump_stack();
55320 + gr_handle_kernel_exploit();
55321 + do_group_exit(SIGKILL);
55322 +}
55323 +#endif
55324 +
55325 +#ifdef CONFIG_PAX_USERCOPY
55326 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55327 +{
55328 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55329 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55330 +#ifdef CONFIG_MODULES
55331 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55332 +#else
55333 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55334 +#endif
55335 +
55336 +#else
55337 + unsigned long textlow = (unsigned long)_stext;
55338 + unsigned long texthigh = (unsigned long)_etext;
55339 +#endif
55340 +
55341 + if (high <= textlow || low > texthigh)
55342 + return false;
55343 + else
55344 + return true;
55345 +}
55346 +#endif
55347 +
55348 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55349 +{
55350 +
55351 +#ifdef CONFIG_PAX_USERCOPY
55352 + const char *type;
55353 +
55354 + if (!n)
55355 + return;
55356 +
55357 + type = check_heap_object(ptr, n);
55358 + if (!type) {
55359 + int ret = check_stack_object(ptr, n);
55360 + if (ret == 1 || ret == 2)
55361 + return;
55362 + if (ret == 0) {
55363 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55364 + type = "<kernel text>";
55365 + else
55366 + return;
55367 + } else
55368 + type = "<process stack>";
55369 + }
55370 +
55371 + pax_report_usercopy(ptr, n, to_user, type);
55372 +#endif
55373 +
55374 +}
55375 +EXPORT_SYMBOL(__check_object_size);
55376 +
55377 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55378 +void pax_track_stack(void)
55379 +{
55380 + unsigned long sp = (unsigned long)&sp;
55381 + if (sp < current_thread_info()->lowest_stack &&
55382 + sp > (unsigned long)task_stack_page(current))
55383 + current_thread_info()->lowest_stack = sp;
55384 +}
55385 +EXPORT_SYMBOL(pax_track_stack);
55386 +#endif
55387 +
55388 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55389 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55390 +{
55391 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55392 + dump_stack();
55393 + do_group_exit(SIGKILL);
55394 +}
55395 +EXPORT_SYMBOL(report_size_overflow);
55396 +#endif
55397 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55398 index 9f9992b..8b59411 100644
55399 --- a/fs/ext2/balloc.c
55400 +++ b/fs/ext2/balloc.c
55401 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55402
55403 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55404 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55405 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55406 + if (free_blocks < root_blocks + 1 &&
55407 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55408 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55409 - !in_group_p (sbi->s_resgid))) {
55410 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55411 return 0;
55412 }
55413 return 1;
55414 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55415 index 22548f5..41521d8 100644
55416 --- a/fs/ext3/balloc.c
55417 +++ b/fs/ext3/balloc.c
55418 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55419
55420 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55421 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55422 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55423 + if (free_blocks < root_blocks + 1 &&
55424 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55425 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55426 - !in_group_p (sbi->s_resgid))) {
55427 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55428 return 0;
55429 }
55430 return 1;
55431 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55432 index ddd715e..c772f88 100644
55433 --- a/fs/ext4/balloc.c
55434 +++ b/fs/ext4/balloc.c
55435 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55436 /* Hm, nope. Are (enough) root reserved clusters available? */
55437 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55438 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55439 - capable(CAP_SYS_RESOURCE) ||
55440 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55441 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55442 + capable_nolog(CAP_SYS_RESOURCE)) {
55443
55444 if (free_clusters >= (nclusters + dirty_clusters +
55445 resv_clusters))
55446 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55447 index 0ab26fb..b6ecb39 100644
55448 --- a/fs/ext4/ext4.h
55449 +++ b/fs/ext4/ext4.h
55450 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55451 unsigned long s_mb_last_start;
55452
55453 /* stats for buddy allocator */
55454 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55455 - atomic_t s_bal_success; /* we found long enough chunks */
55456 - atomic_t s_bal_allocated; /* in blocks */
55457 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55458 - atomic_t s_bal_goals; /* goal hits */
55459 - atomic_t s_bal_breaks; /* too long searches */
55460 - atomic_t s_bal_2orders; /* 2^order hits */
55461 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55462 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55463 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55464 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55465 + atomic_unchecked_t s_bal_goals; /* goal hits */
55466 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55467 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55468 spinlock_t s_bal_lock;
55469 unsigned long s_mb_buddies_generated;
55470 unsigned long long s_mb_generation_time;
55471 - atomic_t s_mb_lost_chunks;
55472 - atomic_t s_mb_preallocated;
55473 - atomic_t s_mb_discarded;
55474 + atomic_unchecked_t s_mb_lost_chunks;
55475 + atomic_unchecked_t s_mb_preallocated;
55476 + atomic_unchecked_t s_mb_discarded;
55477 atomic_t s_lock_busy;
55478
55479 /* locality groups */
55480 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55481 index 4bbbf13b..dcceaeb 100644
55482 --- a/fs/ext4/mballoc.c
55483 +++ b/fs/ext4/mballoc.c
55484 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55485 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55486
55487 if (EXT4_SB(sb)->s_mb_stats)
55488 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55489 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55490
55491 break;
55492 }
55493 @@ -2171,7 +2171,7 @@ repeat:
55494 ac->ac_status = AC_STATUS_CONTINUE;
55495 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55496 cr = 3;
55497 - atomic_inc(&sbi->s_mb_lost_chunks);
55498 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55499 goto repeat;
55500 }
55501 }
55502 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55503 if (sbi->s_mb_stats) {
55504 ext4_msg(sb, KERN_INFO,
55505 "mballoc: %u blocks %u reqs (%u success)",
55506 - atomic_read(&sbi->s_bal_allocated),
55507 - atomic_read(&sbi->s_bal_reqs),
55508 - atomic_read(&sbi->s_bal_success));
55509 + atomic_read_unchecked(&sbi->s_bal_allocated),
55510 + atomic_read_unchecked(&sbi->s_bal_reqs),
55511 + atomic_read_unchecked(&sbi->s_bal_success));
55512 ext4_msg(sb, KERN_INFO,
55513 "mballoc: %u extents scanned, %u goal hits, "
55514 "%u 2^N hits, %u breaks, %u lost",
55515 - atomic_read(&sbi->s_bal_ex_scanned),
55516 - atomic_read(&sbi->s_bal_goals),
55517 - atomic_read(&sbi->s_bal_2orders),
55518 - atomic_read(&sbi->s_bal_breaks),
55519 - atomic_read(&sbi->s_mb_lost_chunks));
55520 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55521 + atomic_read_unchecked(&sbi->s_bal_goals),
55522 + atomic_read_unchecked(&sbi->s_bal_2orders),
55523 + atomic_read_unchecked(&sbi->s_bal_breaks),
55524 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55525 ext4_msg(sb, KERN_INFO,
55526 "mballoc: %lu generated and it took %Lu",
55527 sbi->s_mb_buddies_generated,
55528 sbi->s_mb_generation_time);
55529 ext4_msg(sb, KERN_INFO,
55530 "mballoc: %u preallocated, %u discarded",
55531 - atomic_read(&sbi->s_mb_preallocated),
55532 - atomic_read(&sbi->s_mb_discarded));
55533 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55534 + atomic_read_unchecked(&sbi->s_mb_discarded));
55535 }
55536
55537 free_percpu(sbi->s_locality_groups);
55538 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55539 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55540
55541 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55542 - atomic_inc(&sbi->s_bal_reqs);
55543 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55544 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55545 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55546 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55547 - atomic_inc(&sbi->s_bal_success);
55548 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55549 + atomic_inc_unchecked(&sbi->s_bal_success);
55550 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55551 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55552 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55553 - atomic_inc(&sbi->s_bal_goals);
55554 + atomic_inc_unchecked(&sbi->s_bal_goals);
55555 if (ac->ac_found > sbi->s_mb_max_to_scan)
55556 - atomic_inc(&sbi->s_bal_breaks);
55557 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55558 }
55559
55560 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55561 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55562 trace_ext4_mb_new_inode_pa(ac, pa);
55563
55564 ext4_mb_use_inode_pa(ac, pa);
55565 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55566 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55567
55568 ei = EXT4_I(ac->ac_inode);
55569 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55570 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55571 trace_ext4_mb_new_group_pa(ac, pa);
55572
55573 ext4_mb_use_group_pa(ac, pa);
55574 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55575 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55576
55577 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55578 lg = ac->ac_lg;
55579 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55580 * from the bitmap and continue.
55581 */
55582 }
55583 - atomic_add(free, &sbi->s_mb_discarded);
55584 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55585
55586 return err;
55587 }
55588 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55589 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55590 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55591 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55592 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55593 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55594 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55595
55596 return 0;
55597 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55598 index 214461e..3614c89 100644
55599 --- a/fs/ext4/mmp.c
55600 +++ b/fs/ext4/mmp.c
55601 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55602 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55603 const char *function, unsigned int line, const char *msg)
55604 {
55605 - __ext4_warning(sb, function, line, msg);
55606 + __ext4_warning(sb, function, line, "%s", msg);
55607 __ext4_warning(sb, function, line,
55608 "MMP failure info: last update time: %llu, last update "
55609 "node: %s, last update device: %s\n",
55610 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55611 index b59373b..f41c2b5 100644
55612 --- a/fs/ext4/super.c
55613 +++ b/fs/ext4/super.c
55614 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55615 }
55616
55617 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55618 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55619 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55620 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55621
55622 #ifdef CONFIG_QUOTA
55623 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55624 int offset;
55625 int deprecated_val;
55626 } u;
55627 -};
55628 +} __do_const;
55629
55630 static int parse_strtoull(const char *buf,
55631 unsigned long long max, unsigned long long *value)
55632 diff --git a/fs/fcntl.c b/fs/fcntl.c
55633 index 65343c3..9969dcf 100644
55634 --- a/fs/fcntl.c
55635 +++ b/fs/fcntl.c
55636 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55637 if (err)
55638 return err;
55639
55640 + if (gr_handle_chroot_fowner(pid, type))
55641 + return -ENOENT;
55642 + if (gr_check_protected_task_fowner(pid, type))
55643 + return -EACCES;
55644 +
55645 f_modown(filp, pid, type, force);
55646 return 0;
55647 }
55648 diff --git a/fs/fhandle.c b/fs/fhandle.c
55649 index 999ff5c..41f4109 100644
55650 --- a/fs/fhandle.c
55651 +++ b/fs/fhandle.c
55652 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55653 } else
55654 retval = 0;
55655 /* copy the mount id */
55656 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55657 - sizeof(*mnt_id)) ||
55658 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55659 copy_to_user(ufh, handle,
55660 sizeof(struct file_handle) + handle_bytes))
55661 retval = -EFAULT;
55662 diff --git a/fs/file.c b/fs/file.c
55663 index 4a78f98..9447397 100644
55664 --- a/fs/file.c
55665 +++ b/fs/file.c
55666 @@ -16,6 +16,7 @@
55667 #include <linux/slab.h>
55668 #include <linux/vmalloc.h>
55669 #include <linux/file.h>
55670 +#include <linux/security.h>
55671 #include <linux/fdtable.h>
55672 #include <linux/bitops.h>
55673 #include <linux/interrupt.h>
55674 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55675 if (!file)
55676 return __close_fd(files, fd);
55677
55678 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55679 if (fd >= rlimit(RLIMIT_NOFILE))
55680 return -EBADF;
55681
55682 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55683 if (unlikely(oldfd == newfd))
55684 return -EINVAL;
55685
55686 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55687 if (newfd >= rlimit(RLIMIT_NOFILE))
55688 return -EBADF;
55689
55690 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55691 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55692 {
55693 int err;
55694 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55695 if (from >= rlimit(RLIMIT_NOFILE))
55696 return -EINVAL;
55697 err = alloc_fd(from, flags);
55698 diff --git a/fs/filesystems.c b/fs/filesystems.c
55699 index 92567d9..fcd8cbf 100644
55700 --- a/fs/filesystems.c
55701 +++ b/fs/filesystems.c
55702 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55703 int len = dot ? dot - name : strlen(name);
55704
55705 fs = __get_fs_type(name, len);
55706 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55707 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55708 +#else
55709 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55710 +#endif
55711 fs = __get_fs_type(name, len);
55712
55713 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55714 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55715 index d8ac61d..79a36f0 100644
55716 --- a/fs/fs_struct.c
55717 +++ b/fs/fs_struct.c
55718 @@ -4,6 +4,7 @@
55719 #include <linux/path.h>
55720 #include <linux/slab.h>
55721 #include <linux/fs_struct.h>
55722 +#include <linux/grsecurity.h>
55723 #include "internal.h"
55724
55725 /*
55726 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55727 write_seqcount_begin(&fs->seq);
55728 old_root = fs->root;
55729 fs->root = *path;
55730 + gr_set_chroot_entries(current, path);
55731 write_seqcount_end(&fs->seq);
55732 spin_unlock(&fs->lock);
55733 if (old_root.dentry)
55734 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55735 int hits = 0;
55736 spin_lock(&fs->lock);
55737 write_seqcount_begin(&fs->seq);
55738 + /* this root replacement is only done by pivot_root,
55739 + leave grsec's chroot tagging alone for this task
55740 + so that a pivoted root isn't treated as a chroot
55741 + */
55742 hits += replace_path(&fs->root, old_root, new_root);
55743 hits += replace_path(&fs->pwd, old_root, new_root);
55744 write_seqcount_end(&fs->seq);
55745 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55746 task_lock(tsk);
55747 spin_lock(&fs->lock);
55748 tsk->fs = NULL;
55749 - kill = !--fs->users;
55750 + gr_clear_chroot_entries(tsk);
55751 + kill = !atomic_dec_return(&fs->users);
55752 spin_unlock(&fs->lock);
55753 task_unlock(tsk);
55754 if (kill)
55755 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55756 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55757 /* We don't need to lock fs - think why ;-) */
55758 if (fs) {
55759 - fs->users = 1;
55760 + atomic_set(&fs->users, 1);
55761 fs->in_exec = 0;
55762 spin_lock_init(&fs->lock);
55763 seqcount_init(&fs->seq);
55764 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55765 spin_lock(&old->lock);
55766 fs->root = old->root;
55767 path_get(&fs->root);
55768 + /* instead of calling gr_set_chroot_entries here,
55769 + we call it from every caller of this function
55770 + */
55771 fs->pwd = old->pwd;
55772 path_get(&fs->pwd);
55773 spin_unlock(&old->lock);
55774 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55775
55776 task_lock(current);
55777 spin_lock(&fs->lock);
55778 - kill = !--fs->users;
55779 + kill = !atomic_dec_return(&fs->users);
55780 current->fs = new_fs;
55781 + gr_set_chroot_entries(current, &new_fs->root);
55782 spin_unlock(&fs->lock);
55783 task_unlock(current);
55784
55785 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55786
55787 int current_umask(void)
55788 {
55789 - return current->fs->umask;
55790 + return current->fs->umask | gr_acl_umask();
55791 }
55792 EXPORT_SYMBOL(current_umask);
55793
55794 /* to be mentioned only in INIT_TASK */
55795 struct fs_struct init_fs = {
55796 - .users = 1,
55797 + .users = ATOMIC_INIT(1),
55798 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55799 .seq = SEQCNT_ZERO,
55800 .umask = 0022,
55801 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55802 index 0e91a3c..6c6d2e0 100644
55803 --- a/fs/fscache/cookie.c
55804 +++ b/fs/fscache/cookie.c
55805 @@ -19,7 +19,7 @@
55806
55807 struct kmem_cache *fscache_cookie_jar;
55808
55809 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55810 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55811
55812 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55813 static int fscache_alloc_object(struct fscache_cache *cache,
55814 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55815 parent ? (char *) parent->def->name : "<no-parent>",
55816 def->name, netfs_data);
55817
55818 - fscache_stat(&fscache_n_acquires);
55819 + fscache_stat_unchecked(&fscache_n_acquires);
55820
55821 /* if there's no parent cookie, then we don't create one here either */
55822 if (!parent) {
55823 - fscache_stat(&fscache_n_acquires_null);
55824 + fscache_stat_unchecked(&fscache_n_acquires_null);
55825 _leave(" [no parent]");
55826 return NULL;
55827 }
55828 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55829 /* allocate and initialise a cookie */
55830 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55831 if (!cookie) {
55832 - fscache_stat(&fscache_n_acquires_oom);
55833 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55834 _leave(" [ENOMEM]");
55835 return NULL;
55836 }
55837 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55838
55839 switch (cookie->def->type) {
55840 case FSCACHE_COOKIE_TYPE_INDEX:
55841 - fscache_stat(&fscache_n_cookie_index);
55842 + fscache_stat_unchecked(&fscache_n_cookie_index);
55843 break;
55844 case FSCACHE_COOKIE_TYPE_DATAFILE:
55845 - fscache_stat(&fscache_n_cookie_data);
55846 + fscache_stat_unchecked(&fscache_n_cookie_data);
55847 break;
55848 default:
55849 - fscache_stat(&fscache_n_cookie_special);
55850 + fscache_stat_unchecked(&fscache_n_cookie_special);
55851 break;
55852 }
55853
55854 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55855 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55856 atomic_dec(&parent->n_children);
55857 __fscache_cookie_put(cookie);
55858 - fscache_stat(&fscache_n_acquires_nobufs);
55859 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55860 _leave(" = NULL");
55861 return NULL;
55862 }
55863 }
55864
55865 - fscache_stat(&fscache_n_acquires_ok);
55866 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55867 _leave(" = %p", cookie);
55868 return cookie;
55869 }
55870 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55871 cache = fscache_select_cache_for_object(cookie->parent);
55872 if (!cache) {
55873 up_read(&fscache_addremove_sem);
55874 - fscache_stat(&fscache_n_acquires_no_cache);
55875 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55876 _leave(" = -ENOMEDIUM [no cache]");
55877 return -ENOMEDIUM;
55878 }
55879 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55880 object = cache->ops->alloc_object(cache, cookie);
55881 fscache_stat_d(&fscache_n_cop_alloc_object);
55882 if (IS_ERR(object)) {
55883 - fscache_stat(&fscache_n_object_no_alloc);
55884 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55885 ret = PTR_ERR(object);
55886 goto error;
55887 }
55888
55889 - fscache_stat(&fscache_n_object_alloc);
55890 + fscache_stat_unchecked(&fscache_n_object_alloc);
55891
55892 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55893 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55894
55895 _debug("ALLOC OBJ%x: %s {%lx}",
55896 object->debug_id, cookie->def->name, object->events);
55897 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55898
55899 _enter("{%s}", cookie->def->name);
55900
55901 - fscache_stat(&fscache_n_invalidates);
55902 + fscache_stat_unchecked(&fscache_n_invalidates);
55903
55904 /* Only permit invalidation of data files. Invalidating an index will
55905 * require the caller to release all its attachments to the tree rooted
55906 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55907 {
55908 struct fscache_object *object;
55909
55910 - fscache_stat(&fscache_n_updates);
55911 + fscache_stat_unchecked(&fscache_n_updates);
55912
55913 if (!cookie) {
55914 - fscache_stat(&fscache_n_updates_null);
55915 + fscache_stat_unchecked(&fscache_n_updates_null);
55916 _leave(" [no cookie]");
55917 return;
55918 }
55919 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55920 {
55921 struct fscache_object *object;
55922
55923 - fscache_stat(&fscache_n_relinquishes);
55924 + fscache_stat_unchecked(&fscache_n_relinquishes);
55925 if (retire)
55926 - fscache_stat(&fscache_n_relinquishes_retire);
55927 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55928
55929 if (!cookie) {
55930 - fscache_stat(&fscache_n_relinquishes_null);
55931 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55932 _leave(" [no cookie]");
55933 return;
55934 }
55935 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55936 index 12d505b..86473a3 100644
55937 --- a/fs/fscache/internal.h
55938 +++ b/fs/fscache/internal.h
55939 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55940 * stats.c
55941 */
55942 #ifdef CONFIG_FSCACHE_STATS
55943 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55944 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55945 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55946 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55947
55948 -extern atomic_t fscache_n_op_pend;
55949 -extern atomic_t fscache_n_op_run;
55950 -extern atomic_t fscache_n_op_enqueue;
55951 -extern atomic_t fscache_n_op_deferred_release;
55952 -extern atomic_t fscache_n_op_release;
55953 -extern atomic_t fscache_n_op_gc;
55954 -extern atomic_t fscache_n_op_cancelled;
55955 -extern atomic_t fscache_n_op_rejected;
55956 +extern atomic_unchecked_t fscache_n_op_pend;
55957 +extern atomic_unchecked_t fscache_n_op_run;
55958 +extern atomic_unchecked_t fscache_n_op_enqueue;
55959 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55960 +extern atomic_unchecked_t fscache_n_op_release;
55961 +extern atomic_unchecked_t fscache_n_op_gc;
55962 +extern atomic_unchecked_t fscache_n_op_cancelled;
55963 +extern atomic_unchecked_t fscache_n_op_rejected;
55964
55965 -extern atomic_t fscache_n_attr_changed;
55966 -extern atomic_t fscache_n_attr_changed_ok;
55967 -extern atomic_t fscache_n_attr_changed_nobufs;
55968 -extern atomic_t fscache_n_attr_changed_nomem;
55969 -extern atomic_t fscache_n_attr_changed_calls;
55970 +extern atomic_unchecked_t fscache_n_attr_changed;
55971 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55972 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55973 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55974 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55975
55976 -extern atomic_t fscache_n_allocs;
55977 -extern atomic_t fscache_n_allocs_ok;
55978 -extern atomic_t fscache_n_allocs_wait;
55979 -extern atomic_t fscache_n_allocs_nobufs;
55980 -extern atomic_t fscache_n_allocs_intr;
55981 -extern atomic_t fscache_n_allocs_object_dead;
55982 -extern atomic_t fscache_n_alloc_ops;
55983 -extern atomic_t fscache_n_alloc_op_waits;
55984 +extern atomic_unchecked_t fscache_n_allocs;
55985 +extern atomic_unchecked_t fscache_n_allocs_ok;
55986 +extern atomic_unchecked_t fscache_n_allocs_wait;
55987 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55988 +extern atomic_unchecked_t fscache_n_allocs_intr;
55989 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55990 +extern atomic_unchecked_t fscache_n_alloc_ops;
55991 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55992
55993 -extern atomic_t fscache_n_retrievals;
55994 -extern atomic_t fscache_n_retrievals_ok;
55995 -extern atomic_t fscache_n_retrievals_wait;
55996 -extern atomic_t fscache_n_retrievals_nodata;
55997 -extern atomic_t fscache_n_retrievals_nobufs;
55998 -extern atomic_t fscache_n_retrievals_intr;
55999 -extern atomic_t fscache_n_retrievals_nomem;
56000 -extern atomic_t fscache_n_retrievals_object_dead;
56001 -extern atomic_t fscache_n_retrieval_ops;
56002 -extern atomic_t fscache_n_retrieval_op_waits;
56003 +extern atomic_unchecked_t fscache_n_retrievals;
56004 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56005 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56006 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56007 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56008 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56009 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56010 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56011 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56012 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56013
56014 -extern atomic_t fscache_n_stores;
56015 -extern atomic_t fscache_n_stores_ok;
56016 -extern atomic_t fscache_n_stores_again;
56017 -extern atomic_t fscache_n_stores_nobufs;
56018 -extern atomic_t fscache_n_stores_oom;
56019 -extern atomic_t fscache_n_store_ops;
56020 -extern atomic_t fscache_n_store_calls;
56021 -extern atomic_t fscache_n_store_pages;
56022 -extern atomic_t fscache_n_store_radix_deletes;
56023 -extern atomic_t fscache_n_store_pages_over_limit;
56024 +extern atomic_unchecked_t fscache_n_stores;
56025 +extern atomic_unchecked_t fscache_n_stores_ok;
56026 +extern atomic_unchecked_t fscache_n_stores_again;
56027 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56028 +extern atomic_unchecked_t fscache_n_stores_oom;
56029 +extern atomic_unchecked_t fscache_n_store_ops;
56030 +extern atomic_unchecked_t fscache_n_store_calls;
56031 +extern atomic_unchecked_t fscache_n_store_pages;
56032 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56033 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56034
56035 -extern atomic_t fscache_n_store_vmscan_not_storing;
56036 -extern atomic_t fscache_n_store_vmscan_gone;
56037 -extern atomic_t fscache_n_store_vmscan_busy;
56038 -extern atomic_t fscache_n_store_vmscan_cancelled;
56039 -extern atomic_t fscache_n_store_vmscan_wait;
56040 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56041 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56042 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56043 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56044 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56045
56046 -extern atomic_t fscache_n_marks;
56047 -extern atomic_t fscache_n_uncaches;
56048 +extern atomic_unchecked_t fscache_n_marks;
56049 +extern atomic_unchecked_t fscache_n_uncaches;
56050
56051 -extern atomic_t fscache_n_acquires;
56052 -extern atomic_t fscache_n_acquires_null;
56053 -extern atomic_t fscache_n_acquires_no_cache;
56054 -extern atomic_t fscache_n_acquires_ok;
56055 -extern atomic_t fscache_n_acquires_nobufs;
56056 -extern atomic_t fscache_n_acquires_oom;
56057 +extern atomic_unchecked_t fscache_n_acquires;
56058 +extern atomic_unchecked_t fscache_n_acquires_null;
56059 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56060 +extern atomic_unchecked_t fscache_n_acquires_ok;
56061 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56062 +extern atomic_unchecked_t fscache_n_acquires_oom;
56063
56064 -extern atomic_t fscache_n_invalidates;
56065 -extern atomic_t fscache_n_invalidates_run;
56066 +extern atomic_unchecked_t fscache_n_invalidates;
56067 +extern atomic_unchecked_t fscache_n_invalidates_run;
56068
56069 -extern atomic_t fscache_n_updates;
56070 -extern atomic_t fscache_n_updates_null;
56071 -extern atomic_t fscache_n_updates_run;
56072 +extern atomic_unchecked_t fscache_n_updates;
56073 +extern atomic_unchecked_t fscache_n_updates_null;
56074 +extern atomic_unchecked_t fscache_n_updates_run;
56075
56076 -extern atomic_t fscache_n_relinquishes;
56077 -extern atomic_t fscache_n_relinquishes_null;
56078 -extern atomic_t fscache_n_relinquishes_waitcrt;
56079 -extern atomic_t fscache_n_relinquishes_retire;
56080 +extern atomic_unchecked_t fscache_n_relinquishes;
56081 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56082 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56083 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56084
56085 -extern atomic_t fscache_n_cookie_index;
56086 -extern atomic_t fscache_n_cookie_data;
56087 -extern atomic_t fscache_n_cookie_special;
56088 +extern atomic_unchecked_t fscache_n_cookie_index;
56089 +extern atomic_unchecked_t fscache_n_cookie_data;
56090 +extern atomic_unchecked_t fscache_n_cookie_special;
56091
56092 -extern atomic_t fscache_n_object_alloc;
56093 -extern atomic_t fscache_n_object_no_alloc;
56094 -extern atomic_t fscache_n_object_lookups;
56095 -extern atomic_t fscache_n_object_lookups_negative;
56096 -extern atomic_t fscache_n_object_lookups_positive;
56097 -extern atomic_t fscache_n_object_lookups_timed_out;
56098 -extern atomic_t fscache_n_object_created;
56099 -extern atomic_t fscache_n_object_avail;
56100 -extern atomic_t fscache_n_object_dead;
56101 +extern atomic_unchecked_t fscache_n_object_alloc;
56102 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56103 +extern atomic_unchecked_t fscache_n_object_lookups;
56104 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56105 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56106 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56107 +extern atomic_unchecked_t fscache_n_object_created;
56108 +extern atomic_unchecked_t fscache_n_object_avail;
56109 +extern atomic_unchecked_t fscache_n_object_dead;
56110
56111 -extern atomic_t fscache_n_checkaux_none;
56112 -extern atomic_t fscache_n_checkaux_okay;
56113 -extern atomic_t fscache_n_checkaux_update;
56114 -extern atomic_t fscache_n_checkaux_obsolete;
56115 +extern atomic_unchecked_t fscache_n_checkaux_none;
56116 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56117 +extern atomic_unchecked_t fscache_n_checkaux_update;
56118 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56119
56120 extern atomic_t fscache_n_cop_alloc_object;
56121 extern atomic_t fscache_n_cop_lookup_object;
56122 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56123 atomic_inc(stat);
56124 }
56125
56126 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56127 +{
56128 + atomic_inc_unchecked(stat);
56129 +}
56130 +
56131 static inline void fscache_stat_d(atomic_t *stat)
56132 {
56133 atomic_dec(stat);
56134 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56135
56136 #define __fscache_stat(stat) (NULL)
56137 #define fscache_stat(stat) do {} while (0)
56138 +#define fscache_stat_unchecked(stat) do {} while (0)
56139 #define fscache_stat_d(stat) do {} while (0)
56140 #endif
56141
56142 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56143 index 86d75a6..5f3d7a0 100644
56144 --- a/fs/fscache/object.c
56145 +++ b/fs/fscache/object.c
56146 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56147 _debug("LOOKUP \"%s\" in \"%s\"",
56148 cookie->def->name, object->cache->tag->name);
56149
56150 - fscache_stat(&fscache_n_object_lookups);
56151 + fscache_stat_unchecked(&fscache_n_object_lookups);
56152 fscache_stat(&fscache_n_cop_lookup_object);
56153 ret = object->cache->ops->lookup_object(object);
56154 fscache_stat_d(&fscache_n_cop_lookup_object);
56155 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56156 if (ret == -ETIMEDOUT) {
56157 /* probably stuck behind another object, so move this one to
56158 * the back of the queue */
56159 - fscache_stat(&fscache_n_object_lookups_timed_out);
56160 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56161 _leave(" [timeout]");
56162 return NO_TRANSIT;
56163 }
56164 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56165 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56166
56167 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56168 - fscache_stat(&fscache_n_object_lookups_negative);
56169 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56170
56171 /* Allow write requests to begin stacking up and read requests to begin
56172 * returning ENODATA.
56173 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56174 /* if we were still looking up, then we must have a positive lookup
56175 * result, in which case there may be data available */
56176 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56177 - fscache_stat(&fscache_n_object_lookups_positive);
56178 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56179
56180 /* We do (presumably) have data */
56181 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56182 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56183 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56184 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56185 } else {
56186 - fscache_stat(&fscache_n_object_created);
56187 + fscache_stat_unchecked(&fscache_n_object_created);
56188 }
56189
56190 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56191 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56192 fscache_stat_d(&fscache_n_cop_lookup_complete);
56193
56194 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56195 - fscache_stat(&fscache_n_object_avail);
56196 + fscache_stat_unchecked(&fscache_n_object_avail);
56197
56198 _leave("");
56199 return transit_to(JUMPSTART_DEPS);
56200 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56201
56202 /* this just shifts the object release to the work processor */
56203 fscache_put_object(object);
56204 - fscache_stat(&fscache_n_object_dead);
56205 + fscache_stat_unchecked(&fscache_n_object_dead);
56206
56207 _leave("");
56208 return transit_to(OBJECT_DEAD);
56209 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56210 enum fscache_checkaux result;
56211
56212 if (!object->cookie->def->check_aux) {
56213 - fscache_stat(&fscache_n_checkaux_none);
56214 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56215 return FSCACHE_CHECKAUX_OKAY;
56216 }
56217
56218 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56219 switch (result) {
56220 /* entry okay as is */
56221 case FSCACHE_CHECKAUX_OKAY:
56222 - fscache_stat(&fscache_n_checkaux_okay);
56223 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56224 break;
56225
56226 /* entry requires update */
56227 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56228 - fscache_stat(&fscache_n_checkaux_update);
56229 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56230 break;
56231
56232 /* entry requires deletion */
56233 case FSCACHE_CHECKAUX_OBSOLETE:
56234 - fscache_stat(&fscache_n_checkaux_obsolete);
56235 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56236 break;
56237
56238 default:
56239 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56240 {
56241 const struct fscache_state *s;
56242
56243 - fscache_stat(&fscache_n_invalidates_run);
56244 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56245 fscache_stat(&fscache_n_cop_invalidate_object);
56246 s = _fscache_invalidate_object(object, event);
56247 fscache_stat_d(&fscache_n_cop_invalidate_object);
56248 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56249 {
56250 _enter("{OBJ%x},%d", object->debug_id, event);
56251
56252 - fscache_stat(&fscache_n_updates_run);
56253 + fscache_stat_unchecked(&fscache_n_updates_run);
56254 fscache_stat(&fscache_n_cop_update_object);
56255 object->cache->ops->update_object(object);
56256 fscache_stat_d(&fscache_n_cop_update_object);
56257 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56258 index 318071a..379938b 100644
56259 --- a/fs/fscache/operation.c
56260 +++ b/fs/fscache/operation.c
56261 @@ -17,7 +17,7 @@
56262 #include <linux/slab.h>
56263 #include "internal.h"
56264
56265 -atomic_t fscache_op_debug_id;
56266 +atomic_unchecked_t fscache_op_debug_id;
56267 EXPORT_SYMBOL(fscache_op_debug_id);
56268
56269 /**
56270 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56271 ASSERTCMP(atomic_read(&op->usage), >, 0);
56272 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56273
56274 - fscache_stat(&fscache_n_op_enqueue);
56275 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56276 switch (op->flags & FSCACHE_OP_TYPE) {
56277 case FSCACHE_OP_ASYNC:
56278 _debug("queue async");
56279 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56280 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56281 if (op->processor)
56282 fscache_enqueue_operation(op);
56283 - fscache_stat(&fscache_n_op_run);
56284 + fscache_stat_unchecked(&fscache_n_op_run);
56285 }
56286
56287 /*
56288 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56289 if (object->n_in_progress > 0) {
56290 atomic_inc(&op->usage);
56291 list_add_tail(&op->pend_link, &object->pending_ops);
56292 - fscache_stat(&fscache_n_op_pend);
56293 + fscache_stat_unchecked(&fscache_n_op_pend);
56294 } else if (!list_empty(&object->pending_ops)) {
56295 atomic_inc(&op->usage);
56296 list_add_tail(&op->pend_link, &object->pending_ops);
56297 - fscache_stat(&fscache_n_op_pend);
56298 + fscache_stat_unchecked(&fscache_n_op_pend);
56299 fscache_start_operations(object);
56300 } else {
56301 ASSERTCMP(object->n_in_progress, ==, 0);
56302 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56303 object->n_exclusive++; /* reads and writes must wait */
56304 atomic_inc(&op->usage);
56305 list_add_tail(&op->pend_link, &object->pending_ops);
56306 - fscache_stat(&fscache_n_op_pend);
56307 + fscache_stat_unchecked(&fscache_n_op_pend);
56308 ret = 0;
56309 } else {
56310 /* If we're in any other state, there must have been an I/O
56311 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56312 if (object->n_exclusive > 0) {
56313 atomic_inc(&op->usage);
56314 list_add_tail(&op->pend_link, &object->pending_ops);
56315 - fscache_stat(&fscache_n_op_pend);
56316 + fscache_stat_unchecked(&fscache_n_op_pend);
56317 } else if (!list_empty(&object->pending_ops)) {
56318 atomic_inc(&op->usage);
56319 list_add_tail(&op->pend_link, &object->pending_ops);
56320 - fscache_stat(&fscache_n_op_pend);
56321 + fscache_stat_unchecked(&fscache_n_op_pend);
56322 fscache_start_operations(object);
56323 } else {
56324 ASSERTCMP(object->n_exclusive, ==, 0);
56325 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56326 object->n_ops++;
56327 atomic_inc(&op->usage);
56328 list_add_tail(&op->pend_link, &object->pending_ops);
56329 - fscache_stat(&fscache_n_op_pend);
56330 + fscache_stat_unchecked(&fscache_n_op_pend);
56331 ret = 0;
56332 } else if (fscache_object_is_dying(object)) {
56333 - fscache_stat(&fscache_n_op_rejected);
56334 + fscache_stat_unchecked(&fscache_n_op_rejected);
56335 op->state = FSCACHE_OP_ST_CANCELLED;
56336 ret = -ENOBUFS;
56337 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56338 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56339 ret = -EBUSY;
56340 if (op->state == FSCACHE_OP_ST_PENDING) {
56341 ASSERT(!list_empty(&op->pend_link));
56342 - fscache_stat(&fscache_n_op_cancelled);
56343 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56344 list_del_init(&op->pend_link);
56345 if (do_cancel)
56346 do_cancel(op);
56347 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56348 while (!list_empty(&object->pending_ops)) {
56349 op = list_entry(object->pending_ops.next,
56350 struct fscache_operation, pend_link);
56351 - fscache_stat(&fscache_n_op_cancelled);
56352 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56353 list_del_init(&op->pend_link);
56354
56355 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56356 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56357 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56358 op->state = FSCACHE_OP_ST_DEAD;
56359
56360 - fscache_stat(&fscache_n_op_release);
56361 + fscache_stat_unchecked(&fscache_n_op_release);
56362
56363 if (op->release) {
56364 op->release(op);
56365 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56366 * lock, and defer it otherwise */
56367 if (!spin_trylock(&object->lock)) {
56368 _debug("defer put");
56369 - fscache_stat(&fscache_n_op_deferred_release);
56370 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56371
56372 cache = object->cache;
56373 spin_lock(&cache->op_gc_list_lock);
56374 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56375
56376 _debug("GC DEFERRED REL OBJ%x OP%x",
56377 object->debug_id, op->debug_id);
56378 - fscache_stat(&fscache_n_op_gc);
56379 + fscache_stat_unchecked(&fscache_n_op_gc);
56380
56381 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56382 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56383 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56384 index d479ab3..727a7f2 100644
56385 --- a/fs/fscache/page.c
56386 +++ b/fs/fscache/page.c
56387 @@ -61,7 +61,7 @@ try_again:
56388 val = radix_tree_lookup(&cookie->stores, page->index);
56389 if (!val) {
56390 rcu_read_unlock();
56391 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56392 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56393 __fscache_uncache_page(cookie, page);
56394 return true;
56395 }
56396 @@ -91,11 +91,11 @@ try_again:
56397 spin_unlock(&cookie->stores_lock);
56398
56399 if (xpage) {
56400 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56401 - fscache_stat(&fscache_n_store_radix_deletes);
56402 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56403 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56404 ASSERTCMP(xpage, ==, page);
56405 } else {
56406 - fscache_stat(&fscache_n_store_vmscan_gone);
56407 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56408 }
56409
56410 wake_up_bit(&cookie->flags, 0);
56411 @@ -110,11 +110,11 @@ page_busy:
56412 * sleeping on memory allocation, so we may need to impose a timeout
56413 * too. */
56414 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56415 - fscache_stat(&fscache_n_store_vmscan_busy);
56416 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56417 return false;
56418 }
56419
56420 - fscache_stat(&fscache_n_store_vmscan_wait);
56421 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56422 __fscache_wait_on_page_write(cookie, page);
56423 gfp &= ~__GFP_WAIT;
56424 goto try_again;
56425 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56426 FSCACHE_COOKIE_STORING_TAG);
56427 if (!radix_tree_tag_get(&cookie->stores, page->index,
56428 FSCACHE_COOKIE_PENDING_TAG)) {
56429 - fscache_stat(&fscache_n_store_radix_deletes);
56430 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56431 xpage = radix_tree_delete(&cookie->stores, page->index);
56432 }
56433 spin_unlock(&cookie->stores_lock);
56434 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56435
56436 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56437
56438 - fscache_stat(&fscache_n_attr_changed_calls);
56439 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56440
56441 if (fscache_object_is_active(object) &&
56442 fscache_use_cookie(object)) {
56443 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56444
56445 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56446
56447 - fscache_stat(&fscache_n_attr_changed);
56448 + fscache_stat_unchecked(&fscache_n_attr_changed);
56449
56450 op = kzalloc(sizeof(*op), GFP_KERNEL);
56451 if (!op) {
56452 - fscache_stat(&fscache_n_attr_changed_nomem);
56453 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56454 _leave(" = -ENOMEM");
56455 return -ENOMEM;
56456 }
56457 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56458 if (fscache_submit_exclusive_op(object, op) < 0)
56459 goto nobufs;
56460 spin_unlock(&cookie->lock);
56461 - fscache_stat(&fscache_n_attr_changed_ok);
56462 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56463 fscache_put_operation(op);
56464 _leave(" = 0");
56465 return 0;
56466 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56467 nobufs:
56468 spin_unlock(&cookie->lock);
56469 kfree(op);
56470 - fscache_stat(&fscache_n_attr_changed_nobufs);
56471 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56472 _leave(" = %d", -ENOBUFS);
56473 return -ENOBUFS;
56474 }
56475 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56476 /* allocate a retrieval operation and attempt to submit it */
56477 op = kzalloc(sizeof(*op), GFP_NOIO);
56478 if (!op) {
56479 - fscache_stat(&fscache_n_retrievals_nomem);
56480 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56481 return NULL;
56482 }
56483
56484 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56485 return 0;
56486 }
56487
56488 - fscache_stat(&fscache_n_retrievals_wait);
56489 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56490
56491 jif = jiffies;
56492 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56493 fscache_wait_bit_interruptible,
56494 TASK_INTERRUPTIBLE) != 0) {
56495 - fscache_stat(&fscache_n_retrievals_intr);
56496 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56497 _leave(" = -ERESTARTSYS");
56498 return -ERESTARTSYS;
56499 }
56500 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56501 */
56502 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56503 struct fscache_retrieval *op,
56504 - atomic_t *stat_op_waits,
56505 - atomic_t *stat_object_dead)
56506 + atomic_unchecked_t *stat_op_waits,
56507 + atomic_unchecked_t *stat_object_dead)
56508 {
56509 int ret;
56510
56511 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56512 goto check_if_dead;
56513
56514 _debug(">>> WT");
56515 - fscache_stat(stat_op_waits);
56516 + fscache_stat_unchecked(stat_op_waits);
56517 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56518 fscache_wait_bit_interruptible,
56519 TASK_INTERRUPTIBLE) != 0) {
56520 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56521
56522 check_if_dead:
56523 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56524 - fscache_stat(stat_object_dead);
56525 + fscache_stat_unchecked(stat_object_dead);
56526 _leave(" = -ENOBUFS [cancelled]");
56527 return -ENOBUFS;
56528 }
56529 if (unlikely(fscache_object_is_dead(object))) {
56530 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56531 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56532 - fscache_stat(stat_object_dead);
56533 + fscache_stat_unchecked(stat_object_dead);
56534 return -ENOBUFS;
56535 }
56536 return 0;
56537 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56538
56539 _enter("%p,%p,,,", cookie, page);
56540
56541 - fscache_stat(&fscache_n_retrievals);
56542 + fscache_stat_unchecked(&fscache_n_retrievals);
56543
56544 if (hlist_empty(&cookie->backing_objects))
56545 goto nobufs;
56546 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56547 goto nobufs_unlock_dec;
56548 spin_unlock(&cookie->lock);
56549
56550 - fscache_stat(&fscache_n_retrieval_ops);
56551 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56552
56553 /* pin the netfs read context in case we need to do the actual netfs
56554 * read because we've encountered a cache read failure */
56555 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56556
56557 error:
56558 if (ret == -ENOMEM)
56559 - fscache_stat(&fscache_n_retrievals_nomem);
56560 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56561 else if (ret == -ERESTARTSYS)
56562 - fscache_stat(&fscache_n_retrievals_intr);
56563 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56564 else if (ret == -ENODATA)
56565 - fscache_stat(&fscache_n_retrievals_nodata);
56566 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56567 else if (ret < 0)
56568 - fscache_stat(&fscache_n_retrievals_nobufs);
56569 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56570 else
56571 - fscache_stat(&fscache_n_retrievals_ok);
56572 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56573
56574 fscache_put_retrieval(op);
56575 _leave(" = %d", ret);
56576 @@ -475,7 +475,7 @@ nobufs_unlock:
56577 atomic_dec(&cookie->n_active);
56578 kfree(op);
56579 nobufs:
56580 - fscache_stat(&fscache_n_retrievals_nobufs);
56581 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56582 _leave(" = -ENOBUFS");
56583 return -ENOBUFS;
56584 }
56585 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56586
56587 _enter("%p,,%d,,,", cookie, *nr_pages);
56588
56589 - fscache_stat(&fscache_n_retrievals);
56590 + fscache_stat_unchecked(&fscache_n_retrievals);
56591
56592 if (hlist_empty(&cookie->backing_objects))
56593 goto nobufs;
56594 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56595 goto nobufs_unlock_dec;
56596 spin_unlock(&cookie->lock);
56597
56598 - fscache_stat(&fscache_n_retrieval_ops);
56599 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56600
56601 /* pin the netfs read context in case we need to do the actual netfs
56602 * read because we've encountered a cache read failure */
56603 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56604
56605 error:
56606 if (ret == -ENOMEM)
56607 - fscache_stat(&fscache_n_retrievals_nomem);
56608 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56609 else if (ret == -ERESTARTSYS)
56610 - fscache_stat(&fscache_n_retrievals_intr);
56611 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56612 else if (ret == -ENODATA)
56613 - fscache_stat(&fscache_n_retrievals_nodata);
56614 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56615 else if (ret < 0)
56616 - fscache_stat(&fscache_n_retrievals_nobufs);
56617 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56618 else
56619 - fscache_stat(&fscache_n_retrievals_ok);
56620 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56621
56622 fscache_put_retrieval(op);
56623 _leave(" = %d", ret);
56624 @@ -600,7 +600,7 @@ nobufs_unlock:
56625 atomic_dec(&cookie->n_active);
56626 kfree(op);
56627 nobufs:
56628 - fscache_stat(&fscache_n_retrievals_nobufs);
56629 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56630 _leave(" = -ENOBUFS");
56631 return -ENOBUFS;
56632 }
56633 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56634
56635 _enter("%p,%p,,,", cookie, page);
56636
56637 - fscache_stat(&fscache_n_allocs);
56638 + fscache_stat_unchecked(&fscache_n_allocs);
56639
56640 if (hlist_empty(&cookie->backing_objects))
56641 goto nobufs;
56642 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56643 goto nobufs_unlock;
56644 spin_unlock(&cookie->lock);
56645
56646 - fscache_stat(&fscache_n_alloc_ops);
56647 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56648
56649 ret = fscache_wait_for_retrieval_activation(
56650 object, op,
56651 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56652
56653 error:
56654 if (ret == -ERESTARTSYS)
56655 - fscache_stat(&fscache_n_allocs_intr);
56656 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56657 else if (ret < 0)
56658 - fscache_stat(&fscache_n_allocs_nobufs);
56659 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56660 else
56661 - fscache_stat(&fscache_n_allocs_ok);
56662 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56663
56664 fscache_put_retrieval(op);
56665 _leave(" = %d", ret);
56666 @@ -687,7 +687,7 @@ nobufs_unlock:
56667 atomic_dec(&cookie->n_active);
56668 kfree(op);
56669 nobufs:
56670 - fscache_stat(&fscache_n_allocs_nobufs);
56671 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56672 _leave(" = -ENOBUFS");
56673 return -ENOBUFS;
56674 }
56675 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56676
56677 spin_lock(&cookie->stores_lock);
56678
56679 - fscache_stat(&fscache_n_store_calls);
56680 + fscache_stat_unchecked(&fscache_n_store_calls);
56681
56682 /* find a page to store */
56683 page = NULL;
56684 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56685 page = results[0];
56686 _debug("gang %d [%lx]", n, page->index);
56687 if (page->index > op->store_limit) {
56688 - fscache_stat(&fscache_n_store_pages_over_limit);
56689 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56690 goto superseded;
56691 }
56692
56693 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56694 spin_unlock(&cookie->stores_lock);
56695 spin_unlock(&object->lock);
56696
56697 - fscache_stat(&fscache_n_store_pages);
56698 + fscache_stat_unchecked(&fscache_n_store_pages);
56699 fscache_stat(&fscache_n_cop_write_page);
56700 ret = object->cache->ops->write_page(op, page);
56701 fscache_stat_d(&fscache_n_cop_write_page);
56702 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56703 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56704 ASSERT(PageFsCache(page));
56705
56706 - fscache_stat(&fscache_n_stores);
56707 + fscache_stat_unchecked(&fscache_n_stores);
56708
56709 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56710 _leave(" = -ENOBUFS [invalidating]");
56711 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56712 spin_unlock(&cookie->stores_lock);
56713 spin_unlock(&object->lock);
56714
56715 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56716 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56717 op->store_limit = object->store_limit;
56718
56719 atomic_inc(&cookie->n_active);
56720 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56721
56722 spin_unlock(&cookie->lock);
56723 radix_tree_preload_end();
56724 - fscache_stat(&fscache_n_store_ops);
56725 - fscache_stat(&fscache_n_stores_ok);
56726 + fscache_stat_unchecked(&fscache_n_store_ops);
56727 + fscache_stat_unchecked(&fscache_n_stores_ok);
56728
56729 /* the work queue now carries its own ref on the object */
56730 fscache_put_operation(&op->op);
56731 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56732 return 0;
56733
56734 already_queued:
56735 - fscache_stat(&fscache_n_stores_again);
56736 + fscache_stat_unchecked(&fscache_n_stores_again);
56737 already_pending:
56738 spin_unlock(&cookie->stores_lock);
56739 spin_unlock(&object->lock);
56740 spin_unlock(&cookie->lock);
56741 radix_tree_preload_end();
56742 kfree(op);
56743 - fscache_stat(&fscache_n_stores_ok);
56744 + fscache_stat_unchecked(&fscache_n_stores_ok);
56745 _leave(" = 0");
56746 return 0;
56747
56748 @@ -976,14 +976,14 @@ nobufs:
56749 spin_unlock(&cookie->lock);
56750 radix_tree_preload_end();
56751 kfree(op);
56752 - fscache_stat(&fscache_n_stores_nobufs);
56753 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56754 _leave(" = -ENOBUFS");
56755 return -ENOBUFS;
56756
56757 nomem_free:
56758 kfree(op);
56759 nomem:
56760 - fscache_stat(&fscache_n_stores_oom);
56761 + fscache_stat_unchecked(&fscache_n_stores_oom);
56762 _leave(" = -ENOMEM");
56763 return -ENOMEM;
56764 }
56765 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56766 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56767 ASSERTCMP(page, !=, NULL);
56768
56769 - fscache_stat(&fscache_n_uncaches);
56770 + fscache_stat_unchecked(&fscache_n_uncaches);
56771
56772 /* cache withdrawal may beat us to it */
56773 if (!PageFsCache(page))
56774 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56775 struct fscache_cookie *cookie = op->op.object->cookie;
56776
56777 #ifdef CONFIG_FSCACHE_STATS
56778 - atomic_inc(&fscache_n_marks);
56779 + atomic_inc_unchecked(&fscache_n_marks);
56780 #endif
56781
56782 _debug("- mark %p{%lx}", page, page->index);
56783 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56784 index 40d13c7..ddf52b9 100644
56785 --- a/fs/fscache/stats.c
56786 +++ b/fs/fscache/stats.c
56787 @@ -18,99 +18,99 @@
56788 /*
56789 * operation counters
56790 */
56791 -atomic_t fscache_n_op_pend;
56792 -atomic_t fscache_n_op_run;
56793 -atomic_t fscache_n_op_enqueue;
56794 -atomic_t fscache_n_op_requeue;
56795 -atomic_t fscache_n_op_deferred_release;
56796 -atomic_t fscache_n_op_release;
56797 -atomic_t fscache_n_op_gc;
56798 -atomic_t fscache_n_op_cancelled;
56799 -atomic_t fscache_n_op_rejected;
56800 +atomic_unchecked_t fscache_n_op_pend;
56801 +atomic_unchecked_t fscache_n_op_run;
56802 +atomic_unchecked_t fscache_n_op_enqueue;
56803 +atomic_unchecked_t fscache_n_op_requeue;
56804 +atomic_unchecked_t fscache_n_op_deferred_release;
56805 +atomic_unchecked_t fscache_n_op_release;
56806 +atomic_unchecked_t fscache_n_op_gc;
56807 +atomic_unchecked_t fscache_n_op_cancelled;
56808 +atomic_unchecked_t fscache_n_op_rejected;
56809
56810 -atomic_t fscache_n_attr_changed;
56811 -atomic_t fscache_n_attr_changed_ok;
56812 -atomic_t fscache_n_attr_changed_nobufs;
56813 -atomic_t fscache_n_attr_changed_nomem;
56814 -atomic_t fscache_n_attr_changed_calls;
56815 +atomic_unchecked_t fscache_n_attr_changed;
56816 +atomic_unchecked_t fscache_n_attr_changed_ok;
56817 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56818 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56819 +atomic_unchecked_t fscache_n_attr_changed_calls;
56820
56821 -atomic_t fscache_n_allocs;
56822 -atomic_t fscache_n_allocs_ok;
56823 -atomic_t fscache_n_allocs_wait;
56824 -atomic_t fscache_n_allocs_nobufs;
56825 -atomic_t fscache_n_allocs_intr;
56826 -atomic_t fscache_n_allocs_object_dead;
56827 -atomic_t fscache_n_alloc_ops;
56828 -atomic_t fscache_n_alloc_op_waits;
56829 +atomic_unchecked_t fscache_n_allocs;
56830 +atomic_unchecked_t fscache_n_allocs_ok;
56831 +atomic_unchecked_t fscache_n_allocs_wait;
56832 +atomic_unchecked_t fscache_n_allocs_nobufs;
56833 +atomic_unchecked_t fscache_n_allocs_intr;
56834 +atomic_unchecked_t fscache_n_allocs_object_dead;
56835 +atomic_unchecked_t fscache_n_alloc_ops;
56836 +atomic_unchecked_t fscache_n_alloc_op_waits;
56837
56838 -atomic_t fscache_n_retrievals;
56839 -atomic_t fscache_n_retrievals_ok;
56840 -atomic_t fscache_n_retrievals_wait;
56841 -atomic_t fscache_n_retrievals_nodata;
56842 -atomic_t fscache_n_retrievals_nobufs;
56843 -atomic_t fscache_n_retrievals_intr;
56844 -atomic_t fscache_n_retrievals_nomem;
56845 -atomic_t fscache_n_retrievals_object_dead;
56846 -atomic_t fscache_n_retrieval_ops;
56847 -atomic_t fscache_n_retrieval_op_waits;
56848 +atomic_unchecked_t fscache_n_retrievals;
56849 +atomic_unchecked_t fscache_n_retrievals_ok;
56850 +atomic_unchecked_t fscache_n_retrievals_wait;
56851 +atomic_unchecked_t fscache_n_retrievals_nodata;
56852 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56853 +atomic_unchecked_t fscache_n_retrievals_intr;
56854 +atomic_unchecked_t fscache_n_retrievals_nomem;
56855 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56856 +atomic_unchecked_t fscache_n_retrieval_ops;
56857 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56858
56859 -atomic_t fscache_n_stores;
56860 -atomic_t fscache_n_stores_ok;
56861 -atomic_t fscache_n_stores_again;
56862 -atomic_t fscache_n_stores_nobufs;
56863 -atomic_t fscache_n_stores_oom;
56864 -atomic_t fscache_n_store_ops;
56865 -atomic_t fscache_n_store_calls;
56866 -atomic_t fscache_n_store_pages;
56867 -atomic_t fscache_n_store_radix_deletes;
56868 -atomic_t fscache_n_store_pages_over_limit;
56869 +atomic_unchecked_t fscache_n_stores;
56870 +atomic_unchecked_t fscache_n_stores_ok;
56871 +atomic_unchecked_t fscache_n_stores_again;
56872 +atomic_unchecked_t fscache_n_stores_nobufs;
56873 +atomic_unchecked_t fscache_n_stores_oom;
56874 +atomic_unchecked_t fscache_n_store_ops;
56875 +atomic_unchecked_t fscache_n_store_calls;
56876 +atomic_unchecked_t fscache_n_store_pages;
56877 +atomic_unchecked_t fscache_n_store_radix_deletes;
56878 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56879
56880 -atomic_t fscache_n_store_vmscan_not_storing;
56881 -atomic_t fscache_n_store_vmscan_gone;
56882 -atomic_t fscache_n_store_vmscan_busy;
56883 -atomic_t fscache_n_store_vmscan_cancelled;
56884 -atomic_t fscache_n_store_vmscan_wait;
56885 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56886 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56887 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56888 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56889 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56890
56891 -atomic_t fscache_n_marks;
56892 -atomic_t fscache_n_uncaches;
56893 +atomic_unchecked_t fscache_n_marks;
56894 +atomic_unchecked_t fscache_n_uncaches;
56895
56896 -atomic_t fscache_n_acquires;
56897 -atomic_t fscache_n_acquires_null;
56898 -atomic_t fscache_n_acquires_no_cache;
56899 -atomic_t fscache_n_acquires_ok;
56900 -atomic_t fscache_n_acquires_nobufs;
56901 -atomic_t fscache_n_acquires_oom;
56902 +atomic_unchecked_t fscache_n_acquires;
56903 +atomic_unchecked_t fscache_n_acquires_null;
56904 +atomic_unchecked_t fscache_n_acquires_no_cache;
56905 +atomic_unchecked_t fscache_n_acquires_ok;
56906 +atomic_unchecked_t fscache_n_acquires_nobufs;
56907 +atomic_unchecked_t fscache_n_acquires_oom;
56908
56909 -atomic_t fscache_n_invalidates;
56910 -atomic_t fscache_n_invalidates_run;
56911 +atomic_unchecked_t fscache_n_invalidates;
56912 +atomic_unchecked_t fscache_n_invalidates_run;
56913
56914 -atomic_t fscache_n_updates;
56915 -atomic_t fscache_n_updates_null;
56916 -atomic_t fscache_n_updates_run;
56917 +atomic_unchecked_t fscache_n_updates;
56918 +atomic_unchecked_t fscache_n_updates_null;
56919 +atomic_unchecked_t fscache_n_updates_run;
56920
56921 -atomic_t fscache_n_relinquishes;
56922 -atomic_t fscache_n_relinquishes_null;
56923 -atomic_t fscache_n_relinquishes_waitcrt;
56924 -atomic_t fscache_n_relinquishes_retire;
56925 +atomic_unchecked_t fscache_n_relinquishes;
56926 +atomic_unchecked_t fscache_n_relinquishes_null;
56927 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56928 +atomic_unchecked_t fscache_n_relinquishes_retire;
56929
56930 -atomic_t fscache_n_cookie_index;
56931 -atomic_t fscache_n_cookie_data;
56932 -atomic_t fscache_n_cookie_special;
56933 +atomic_unchecked_t fscache_n_cookie_index;
56934 +atomic_unchecked_t fscache_n_cookie_data;
56935 +atomic_unchecked_t fscache_n_cookie_special;
56936
56937 -atomic_t fscache_n_object_alloc;
56938 -atomic_t fscache_n_object_no_alloc;
56939 -atomic_t fscache_n_object_lookups;
56940 -atomic_t fscache_n_object_lookups_negative;
56941 -atomic_t fscache_n_object_lookups_positive;
56942 -atomic_t fscache_n_object_lookups_timed_out;
56943 -atomic_t fscache_n_object_created;
56944 -atomic_t fscache_n_object_avail;
56945 -atomic_t fscache_n_object_dead;
56946 +atomic_unchecked_t fscache_n_object_alloc;
56947 +atomic_unchecked_t fscache_n_object_no_alloc;
56948 +atomic_unchecked_t fscache_n_object_lookups;
56949 +atomic_unchecked_t fscache_n_object_lookups_negative;
56950 +atomic_unchecked_t fscache_n_object_lookups_positive;
56951 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56952 +atomic_unchecked_t fscache_n_object_created;
56953 +atomic_unchecked_t fscache_n_object_avail;
56954 +atomic_unchecked_t fscache_n_object_dead;
56955
56956 -atomic_t fscache_n_checkaux_none;
56957 -atomic_t fscache_n_checkaux_okay;
56958 -atomic_t fscache_n_checkaux_update;
56959 -atomic_t fscache_n_checkaux_obsolete;
56960 +atomic_unchecked_t fscache_n_checkaux_none;
56961 +atomic_unchecked_t fscache_n_checkaux_okay;
56962 +atomic_unchecked_t fscache_n_checkaux_update;
56963 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56964
56965 atomic_t fscache_n_cop_alloc_object;
56966 atomic_t fscache_n_cop_lookup_object;
56967 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56968 seq_puts(m, "FS-Cache statistics\n");
56969
56970 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56971 - atomic_read(&fscache_n_cookie_index),
56972 - atomic_read(&fscache_n_cookie_data),
56973 - atomic_read(&fscache_n_cookie_special));
56974 + atomic_read_unchecked(&fscache_n_cookie_index),
56975 + atomic_read_unchecked(&fscache_n_cookie_data),
56976 + atomic_read_unchecked(&fscache_n_cookie_special));
56977
56978 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56979 - atomic_read(&fscache_n_object_alloc),
56980 - atomic_read(&fscache_n_object_no_alloc),
56981 - atomic_read(&fscache_n_object_avail),
56982 - atomic_read(&fscache_n_object_dead));
56983 + atomic_read_unchecked(&fscache_n_object_alloc),
56984 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56985 + atomic_read_unchecked(&fscache_n_object_avail),
56986 + atomic_read_unchecked(&fscache_n_object_dead));
56987 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56988 - atomic_read(&fscache_n_checkaux_none),
56989 - atomic_read(&fscache_n_checkaux_okay),
56990 - atomic_read(&fscache_n_checkaux_update),
56991 - atomic_read(&fscache_n_checkaux_obsolete));
56992 + atomic_read_unchecked(&fscache_n_checkaux_none),
56993 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56994 + atomic_read_unchecked(&fscache_n_checkaux_update),
56995 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56996
56997 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56998 - atomic_read(&fscache_n_marks),
56999 - atomic_read(&fscache_n_uncaches));
57000 + atomic_read_unchecked(&fscache_n_marks),
57001 + atomic_read_unchecked(&fscache_n_uncaches));
57002
57003 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57004 " oom=%u\n",
57005 - atomic_read(&fscache_n_acquires),
57006 - atomic_read(&fscache_n_acquires_null),
57007 - atomic_read(&fscache_n_acquires_no_cache),
57008 - atomic_read(&fscache_n_acquires_ok),
57009 - atomic_read(&fscache_n_acquires_nobufs),
57010 - atomic_read(&fscache_n_acquires_oom));
57011 + atomic_read_unchecked(&fscache_n_acquires),
57012 + atomic_read_unchecked(&fscache_n_acquires_null),
57013 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57014 + atomic_read_unchecked(&fscache_n_acquires_ok),
57015 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57016 + atomic_read_unchecked(&fscache_n_acquires_oom));
57017
57018 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57019 - atomic_read(&fscache_n_object_lookups),
57020 - atomic_read(&fscache_n_object_lookups_negative),
57021 - atomic_read(&fscache_n_object_lookups_positive),
57022 - atomic_read(&fscache_n_object_created),
57023 - atomic_read(&fscache_n_object_lookups_timed_out));
57024 + atomic_read_unchecked(&fscache_n_object_lookups),
57025 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57026 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57027 + atomic_read_unchecked(&fscache_n_object_created),
57028 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57029
57030 seq_printf(m, "Invals : n=%u run=%u\n",
57031 - atomic_read(&fscache_n_invalidates),
57032 - atomic_read(&fscache_n_invalidates_run));
57033 + atomic_read_unchecked(&fscache_n_invalidates),
57034 + atomic_read_unchecked(&fscache_n_invalidates_run));
57035
57036 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57037 - atomic_read(&fscache_n_updates),
57038 - atomic_read(&fscache_n_updates_null),
57039 - atomic_read(&fscache_n_updates_run));
57040 + atomic_read_unchecked(&fscache_n_updates),
57041 + atomic_read_unchecked(&fscache_n_updates_null),
57042 + atomic_read_unchecked(&fscache_n_updates_run));
57043
57044 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57045 - atomic_read(&fscache_n_relinquishes),
57046 - atomic_read(&fscache_n_relinquishes_null),
57047 - atomic_read(&fscache_n_relinquishes_waitcrt),
57048 - atomic_read(&fscache_n_relinquishes_retire));
57049 + atomic_read_unchecked(&fscache_n_relinquishes),
57050 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57051 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57052 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57053
57054 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57055 - atomic_read(&fscache_n_attr_changed),
57056 - atomic_read(&fscache_n_attr_changed_ok),
57057 - atomic_read(&fscache_n_attr_changed_nobufs),
57058 - atomic_read(&fscache_n_attr_changed_nomem),
57059 - atomic_read(&fscache_n_attr_changed_calls));
57060 + atomic_read_unchecked(&fscache_n_attr_changed),
57061 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57062 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57063 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57064 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57065
57066 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57067 - atomic_read(&fscache_n_allocs),
57068 - atomic_read(&fscache_n_allocs_ok),
57069 - atomic_read(&fscache_n_allocs_wait),
57070 - atomic_read(&fscache_n_allocs_nobufs),
57071 - atomic_read(&fscache_n_allocs_intr));
57072 + atomic_read_unchecked(&fscache_n_allocs),
57073 + atomic_read_unchecked(&fscache_n_allocs_ok),
57074 + atomic_read_unchecked(&fscache_n_allocs_wait),
57075 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57076 + atomic_read_unchecked(&fscache_n_allocs_intr));
57077 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57078 - atomic_read(&fscache_n_alloc_ops),
57079 - atomic_read(&fscache_n_alloc_op_waits),
57080 - atomic_read(&fscache_n_allocs_object_dead));
57081 + atomic_read_unchecked(&fscache_n_alloc_ops),
57082 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57083 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57084
57085 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57086 " int=%u oom=%u\n",
57087 - atomic_read(&fscache_n_retrievals),
57088 - atomic_read(&fscache_n_retrievals_ok),
57089 - atomic_read(&fscache_n_retrievals_wait),
57090 - atomic_read(&fscache_n_retrievals_nodata),
57091 - atomic_read(&fscache_n_retrievals_nobufs),
57092 - atomic_read(&fscache_n_retrievals_intr),
57093 - atomic_read(&fscache_n_retrievals_nomem));
57094 + atomic_read_unchecked(&fscache_n_retrievals),
57095 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57096 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57097 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57098 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57099 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57100 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57101 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57102 - atomic_read(&fscache_n_retrieval_ops),
57103 - atomic_read(&fscache_n_retrieval_op_waits),
57104 - atomic_read(&fscache_n_retrievals_object_dead));
57105 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57106 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57107 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57108
57109 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57110 - atomic_read(&fscache_n_stores),
57111 - atomic_read(&fscache_n_stores_ok),
57112 - atomic_read(&fscache_n_stores_again),
57113 - atomic_read(&fscache_n_stores_nobufs),
57114 - atomic_read(&fscache_n_stores_oom));
57115 + atomic_read_unchecked(&fscache_n_stores),
57116 + atomic_read_unchecked(&fscache_n_stores_ok),
57117 + atomic_read_unchecked(&fscache_n_stores_again),
57118 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57119 + atomic_read_unchecked(&fscache_n_stores_oom));
57120 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57121 - atomic_read(&fscache_n_store_ops),
57122 - atomic_read(&fscache_n_store_calls),
57123 - atomic_read(&fscache_n_store_pages),
57124 - atomic_read(&fscache_n_store_radix_deletes),
57125 - atomic_read(&fscache_n_store_pages_over_limit));
57126 + atomic_read_unchecked(&fscache_n_store_ops),
57127 + atomic_read_unchecked(&fscache_n_store_calls),
57128 + atomic_read_unchecked(&fscache_n_store_pages),
57129 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57130 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57131
57132 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57133 - atomic_read(&fscache_n_store_vmscan_not_storing),
57134 - atomic_read(&fscache_n_store_vmscan_gone),
57135 - atomic_read(&fscache_n_store_vmscan_busy),
57136 - atomic_read(&fscache_n_store_vmscan_cancelled),
57137 - atomic_read(&fscache_n_store_vmscan_wait));
57138 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57139 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57140 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57141 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57142 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57143
57144 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57145 - atomic_read(&fscache_n_op_pend),
57146 - atomic_read(&fscache_n_op_run),
57147 - atomic_read(&fscache_n_op_enqueue),
57148 - atomic_read(&fscache_n_op_cancelled),
57149 - atomic_read(&fscache_n_op_rejected));
57150 + atomic_read_unchecked(&fscache_n_op_pend),
57151 + atomic_read_unchecked(&fscache_n_op_run),
57152 + atomic_read_unchecked(&fscache_n_op_enqueue),
57153 + atomic_read_unchecked(&fscache_n_op_cancelled),
57154 + atomic_read_unchecked(&fscache_n_op_rejected));
57155 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57156 - atomic_read(&fscache_n_op_deferred_release),
57157 - atomic_read(&fscache_n_op_release),
57158 - atomic_read(&fscache_n_op_gc));
57159 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57160 + atomic_read_unchecked(&fscache_n_op_release),
57161 + atomic_read_unchecked(&fscache_n_op_gc));
57162
57163 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57164 atomic_read(&fscache_n_cop_alloc_object),
57165 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57166 index aef34b1..59bfd7b 100644
57167 --- a/fs/fuse/cuse.c
57168 +++ b/fs/fuse/cuse.c
57169 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57170 INIT_LIST_HEAD(&cuse_conntbl[i]);
57171
57172 /* inherit and extend fuse_dev_operations */
57173 - cuse_channel_fops = fuse_dev_operations;
57174 - cuse_channel_fops.owner = THIS_MODULE;
57175 - cuse_channel_fops.open = cuse_channel_open;
57176 - cuse_channel_fops.release = cuse_channel_release;
57177 + pax_open_kernel();
57178 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57179 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57180 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57181 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57182 + pax_close_kernel();
57183
57184 cuse_class = class_create(THIS_MODULE, "cuse");
57185 if (IS_ERR(cuse_class))
57186 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57187 index 1d55f94..088da65 100644
57188 --- a/fs/fuse/dev.c
57189 +++ b/fs/fuse/dev.c
57190 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57191 ret = 0;
57192 pipe_lock(pipe);
57193
57194 - if (!pipe->readers) {
57195 + if (!atomic_read(&pipe->readers)) {
57196 send_sig(SIGPIPE, current, 0);
57197 if (!ret)
57198 ret = -EPIPE;
57199 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57200 page_nr++;
57201 ret += buf->len;
57202
57203 - if (pipe->files)
57204 + if (atomic_read(&pipe->files))
57205 do_wakeup = 1;
57206 }
57207
57208 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57209 index 8fec28f..cd40dba 100644
57210 --- a/fs/fuse/dir.c
57211 +++ b/fs/fuse/dir.c
57212 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57213 return link;
57214 }
57215
57216 -static void free_link(char *link)
57217 +static void free_link(const char *link)
57218 {
57219 if (!IS_ERR(link))
57220 free_page((unsigned long) link);
57221 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57222 index 64915ee..6bed500 100644
57223 --- a/fs/gfs2/inode.c
57224 +++ b/fs/gfs2/inode.c
57225 @@ -1506,7 +1506,7 @@ out:
57226
57227 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57228 {
57229 - char *s = nd_get_link(nd);
57230 + const char *s = nd_get_link(nd);
57231 if (!IS_ERR(s))
57232 kfree(s);
57233 }
57234 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57235 index d19b30a..ef89c36 100644
57236 --- a/fs/hugetlbfs/inode.c
57237 +++ b/fs/hugetlbfs/inode.c
57238 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57239 struct mm_struct *mm = current->mm;
57240 struct vm_area_struct *vma;
57241 struct hstate *h = hstate_file(file);
57242 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57243 struct vm_unmapped_area_info info;
57244
57245 if (len & ~huge_page_mask(h))
57246 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57247 return addr;
57248 }
57249
57250 +#ifdef CONFIG_PAX_RANDMMAP
57251 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57252 +#endif
57253 +
57254 if (addr) {
57255 addr = ALIGN(addr, huge_page_size(h));
57256 vma = find_vma(mm, addr);
57257 - if (TASK_SIZE - len >= addr &&
57258 - (!vma || addr + len <= vma->vm_start))
57259 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57260 return addr;
57261 }
57262
57263 info.flags = 0;
57264 info.length = len;
57265 info.low_limit = TASK_UNMAPPED_BASE;
57266 +
57267 +#ifdef CONFIG_PAX_RANDMMAP
57268 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57269 + info.low_limit += mm->delta_mmap;
57270 +#endif
57271 +
57272 info.high_limit = TASK_SIZE;
57273 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57274 info.align_offset = 0;
57275 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57276 };
57277 MODULE_ALIAS_FS("hugetlbfs");
57278
57279 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57280 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57281
57282 static int can_do_hugetlb_shm(void)
57283 {
57284 diff --git a/fs/inode.c b/fs/inode.c
57285 index d6dfb09..602e77e 100644
57286 --- a/fs/inode.c
57287 +++ b/fs/inode.c
57288 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57289
57290 #ifdef CONFIG_SMP
57291 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57292 - static atomic_t shared_last_ino;
57293 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57294 + static atomic_unchecked_t shared_last_ino;
57295 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57296
57297 res = next - LAST_INO_BATCH;
57298 }
57299 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57300 index 4a6cf28..d3a29d3 100644
57301 --- a/fs/jffs2/erase.c
57302 +++ b/fs/jffs2/erase.c
57303 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57304 struct jffs2_unknown_node marker = {
57305 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57306 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57307 - .totlen = cpu_to_je32(c->cleanmarker_size)
57308 + .totlen = cpu_to_je32(c->cleanmarker_size),
57309 + .hdr_crc = cpu_to_je32(0)
57310 };
57311
57312 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57313 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57314 index a6597d6..41b30ec 100644
57315 --- a/fs/jffs2/wbuf.c
57316 +++ b/fs/jffs2/wbuf.c
57317 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57318 {
57319 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57320 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57321 - .totlen = constant_cpu_to_je32(8)
57322 + .totlen = constant_cpu_to_je32(8),
57323 + .hdr_crc = constant_cpu_to_je32(0)
57324 };
57325
57326 /*
57327 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57328 index 6669aa2..36b033d 100644
57329 --- a/fs/jfs/super.c
57330 +++ b/fs/jfs/super.c
57331 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57332
57333 jfs_inode_cachep =
57334 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57335 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57336 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57337 init_once);
57338 if (jfs_inode_cachep == NULL)
57339 return -ENOMEM;
57340 diff --git a/fs/libfs.c b/fs/libfs.c
57341 index 3a3a9b5..3a9b074 100644
57342 --- a/fs/libfs.c
57343 +++ b/fs/libfs.c
57344 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57345
57346 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57347 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57348 + char d_name[sizeof(next->d_iname)];
57349 + const unsigned char *name;
57350 +
57351 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57352 if (!simple_positive(next)) {
57353 spin_unlock(&next->d_lock);
57354 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57355
57356 spin_unlock(&next->d_lock);
57357 spin_unlock(&dentry->d_lock);
57358 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57359 + name = next->d_name.name;
57360 + if (name == next->d_iname) {
57361 + memcpy(d_name, name, next->d_name.len);
57362 + name = d_name;
57363 + }
57364 + if (!dir_emit(ctx, name, next->d_name.len,
57365 next->d_inode->i_ino, dt_type(next->d_inode)))
57366 return 0;
57367 spin_lock(&dentry->d_lock);
57368 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57369 index acd3947..1f896e2 100644
57370 --- a/fs/lockd/clntproc.c
57371 +++ b/fs/lockd/clntproc.c
57372 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57373 /*
57374 * Cookie counter for NLM requests
57375 */
57376 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57377 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57378
57379 void nlmclnt_next_cookie(struct nlm_cookie *c)
57380 {
57381 - u32 cookie = atomic_inc_return(&nlm_cookie);
57382 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57383
57384 memcpy(c->data, &cookie, 4);
57385 c->len=4;
57386 diff --git a/fs/locks.c b/fs/locks.c
57387 index b27a300..4156d0b 100644
57388 --- a/fs/locks.c
57389 +++ b/fs/locks.c
57390 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57391 return;
57392
57393 if (filp->f_op && filp->f_op->flock) {
57394 - struct file_lock fl = {
57395 + struct file_lock flock = {
57396 .fl_pid = current->tgid,
57397 .fl_file = filp,
57398 .fl_flags = FL_FLOCK,
57399 .fl_type = F_UNLCK,
57400 .fl_end = OFFSET_MAX,
57401 };
57402 - filp->f_op->flock(filp, F_SETLKW, &fl);
57403 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57404 - fl.fl_ops->fl_release_private(&fl);
57405 + filp->f_op->flock(filp, F_SETLKW, &flock);
57406 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57407 + flock.fl_ops->fl_release_private(&flock);
57408 }
57409
57410 spin_lock(&inode->i_lock);
57411 diff --git a/fs/namei.c b/fs/namei.c
57412 index 7720fbd..7934bb2 100644
57413 --- a/fs/namei.c
57414 +++ b/fs/namei.c
57415 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57416 if (ret != -EACCES)
57417 return ret;
57418
57419 +#ifdef CONFIG_GRKERNSEC
57420 + /* we'll block if we have to log due to a denied capability use */
57421 + if (mask & MAY_NOT_BLOCK)
57422 + return -ECHILD;
57423 +#endif
57424 +
57425 if (S_ISDIR(inode->i_mode)) {
57426 /* DACs are overridable for directories */
57427 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57428 - return 0;
57429 if (!(mask & MAY_WRITE))
57430 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57431 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57432 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57433 return 0;
57434 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57435 + return 0;
57436 return -EACCES;
57437 }
57438 /*
57439 + * Searching includes executable on directories, else just read.
57440 + */
57441 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57442 + if (mask == MAY_READ)
57443 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57444 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57445 + return 0;
57446 +
57447 + /*
57448 * Read/write DACs are always overridable.
57449 * Executable DACs are overridable when there is
57450 * at least one exec bit set.
57451 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57452 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57453 return 0;
57454
57455 - /*
57456 - * Searching includes executable on directories, else just read.
57457 - */
57458 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57459 - if (mask == MAY_READ)
57460 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57461 - return 0;
57462 -
57463 return -EACCES;
57464 }
57465
57466 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57467 {
57468 struct dentry *dentry = link->dentry;
57469 int error;
57470 - char *s;
57471 + const char *s;
57472
57473 BUG_ON(nd->flags & LOOKUP_RCU);
57474
57475 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57476 if (error)
57477 goto out_put_nd_path;
57478
57479 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57480 + dentry->d_inode, dentry, nd->path.mnt)) {
57481 + error = -EACCES;
57482 + goto out_put_nd_path;
57483 + }
57484 +
57485 nd->last_type = LAST_BIND;
57486 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57487 error = PTR_ERR(*p);
57488 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57489 if (res)
57490 break;
57491 res = walk_component(nd, path, LOOKUP_FOLLOW);
57492 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57493 + res = -EACCES;
57494 put_link(nd, &link, cookie);
57495 } while (res > 0);
57496
57497 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57498 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57499 {
57500 unsigned long a, b, adata, bdata, mask, hash, len;
57501 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57502 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57503
57504 hash = a = 0;
57505 len = -sizeof(unsigned long);
57506 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57507 if (err)
57508 break;
57509 err = lookup_last(nd, &path);
57510 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57511 + err = -EACCES;
57512 put_link(nd, &link, cookie);
57513 }
57514 }
57515 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57516 if (!err)
57517 err = complete_walk(nd);
57518
57519 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57520 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57521 + path_put(&nd->path);
57522 + err = -ENOENT;
57523 + }
57524 + }
57525 +
57526 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57527 if (!can_lookup(nd->inode)) {
57528 path_put(&nd->path);
57529 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57530 retval = path_lookupat(dfd, name->name,
57531 flags | LOOKUP_REVAL, nd);
57532
57533 - if (likely(!retval))
57534 + if (likely(!retval)) {
57535 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57536 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57537 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57538 + path_put(&nd->path);
57539 + return -ENOENT;
57540 + }
57541 + }
57542 + }
57543 return retval;
57544 }
57545
57546 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57547 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57548 return -EPERM;
57549
57550 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57551 + return -EPERM;
57552 + if (gr_handle_rawio(inode))
57553 + return -EPERM;
57554 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57555 + return -EACCES;
57556 +
57557 return 0;
57558 }
57559
57560 @@ -2601,7 +2640,7 @@ looked_up:
57561 * cleared otherwise prior to returning.
57562 */
57563 static int lookup_open(struct nameidata *nd, struct path *path,
57564 - struct file *file,
57565 + struct path *link, struct file *file,
57566 const struct open_flags *op,
57567 bool got_write, int *opened)
57568 {
57569 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57570 /* Negative dentry, just create the file */
57571 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57572 umode_t mode = op->mode;
57573 +
57574 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57575 + error = -EACCES;
57576 + goto out_dput;
57577 + }
57578 +
57579 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57580 + error = -EACCES;
57581 + goto out_dput;
57582 + }
57583 +
57584 if (!IS_POSIXACL(dir->d_inode))
57585 mode &= ~current_umask();
57586 /*
57587 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57588 nd->flags & LOOKUP_EXCL);
57589 if (error)
57590 goto out_dput;
57591 + else
57592 + gr_handle_create(dentry, nd->path.mnt);
57593 }
57594 out_no_open:
57595 path->dentry = dentry;
57596 @@ -2671,7 +2723,7 @@ out_dput:
57597 /*
57598 * Handle the last step of open()
57599 */
57600 -static int do_last(struct nameidata *nd, struct path *path,
57601 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57602 struct file *file, const struct open_flags *op,
57603 int *opened, struct filename *name)
57604 {
57605 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57606 if (error)
57607 return error;
57608
57609 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57610 + error = -ENOENT;
57611 + goto out;
57612 + }
57613 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57614 + error = -EACCES;
57615 + goto out;
57616 + }
57617 +
57618 audit_inode(name, dir, LOOKUP_PARENT);
57619 error = -EISDIR;
57620 /* trailing slashes? */
57621 @@ -2740,7 +2801,7 @@ retry_lookup:
57622 */
57623 }
57624 mutex_lock(&dir->d_inode->i_mutex);
57625 - error = lookup_open(nd, path, file, op, got_write, opened);
57626 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57627 mutex_unlock(&dir->d_inode->i_mutex);
57628
57629 if (error <= 0) {
57630 @@ -2764,11 +2825,28 @@ retry_lookup:
57631 goto finish_open_created;
57632 }
57633
57634 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57635 + error = -ENOENT;
57636 + goto exit_dput;
57637 + }
57638 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57639 + error = -EACCES;
57640 + goto exit_dput;
57641 + }
57642 +
57643 /*
57644 * create/update audit record if it already exists.
57645 */
57646 - if (path->dentry->d_inode)
57647 + if (path->dentry->d_inode) {
57648 + /* only check if O_CREAT is specified, all other checks need to go
57649 + into may_open */
57650 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57651 + error = -EACCES;
57652 + goto exit_dput;
57653 + }
57654 +
57655 audit_inode(name, path->dentry, 0);
57656 + }
57657
57658 /*
57659 * If atomic_open() acquired write access it is dropped now due to
57660 @@ -2809,6 +2887,11 @@ finish_lookup:
57661 }
57662 }
57663 BUG_ON(inode != path->dentry->d_inode);
57664 + /* if we're resolving a symlink to another symlink */
57665 + if (link && gr_handle_symlink_owner(link, inode)) {
57666 + error = -EACCES;
57667 + goto out;
57668 + }
57669 return 1;
57670 }
57671
57672 @@ -2818,7 +2901,6 @@ finish_lookup:
57673 save_parent.dentry = nd->path.dentry;
57674 save_parent.mnt = mntget(path->mnt);
57675 nd->path.dentry = path->dentry;
57676 -
57677 }
57678 nd->inode = inode;
57679 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57680 @@ -2828,7 +2910,18 @@ finish_open:
57681 path_put(&save_parent);
57682 return error;
57683 }
57684 +
57685 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57686 + error = -ENOENT;
57687 + goto out;
57688 + }
57689 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57690 + error = -EACCES;
57691 + goto out;
57692 + }
57693 +
57694 audit_inode(name, nd->path.dentry, 0);
57695 +
57696 error = -EISDIR;
57697 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57698 goto out;
57699 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57700 if (unlikely(error))
57701 goto out;
57702
57703 - error = do_last(nd, &path, file, op, &opened, pathname);
57704 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57705 while (unlikely(error > 0)) { /* trailing symlink */
57706 struct path link = path;
57707 void *cookie;
57708 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57709 error = follow_link(&link, nd, &cookie);
57710 if (unlikely(error))
57711 break;
57712 - error = do_last(nd, &path, file, op, &opened, pathname);
57713 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57714 put_link(nd, &link, cookie);
57715 }
57716 out:
57717 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57718 goto unlock;
57719
57720 error = -EEXIST;
57721 - if (dentry->d_inode)
57722 + if (dentry->d_inode) {
57723 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57724 + error = -ENOENT;
57725 + }
57726 goto fail;
57727 + }
57728 /*
57729 * Special case - lookup gave negative, but... we had foo/bar/
57730 * From the vfs_mknod() POV we just have a negative dentry -
57731 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57732 }
57733 EXPORT_SYMBOL(user_path_create);
57734
57735 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57736 +{
57737 + struct filename *tmp = getname(pathname);
57738 + struct dentry *res;
57739 + if (IS_ERR(tmp))
57740 + return ERR_CAST(tmp);
57741 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57742 + if (IS_ERR(res))
57743 + putname(tmp);
57744 + else
57745 + *to = tmp;
57746 + return res;
57747 +}
57748 +
57749 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57750 {
57751 int error = may_create(dir, dentry);
57752 @@ -3224,6 +3335,17 @@ retry:
57753
57754 if (!IS_POSIXACL(path.dentry->d_inode))
57755 mode &= ~current_umask();
57756 +
57757 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57758 + error = -EPERM;
57759 + goto out;
57760 + }
57761 +
57762 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57763 + error = -EACCES;
57764 + goto out;
57765 + }
57766 +
57767 error = security_path_mknod(&path, dentry, mode, dev);
57768 if (error)
57769 goto out;
57770 @@ -3240,6 +3362,8 @@ retry:
57771 break;
57772 }
57773 out:
57774 + if (!error)
57775 + gr_handle_create(dentry, path.mnt);
57776 done_path_create(&path, dentry);
57777 if (retry_estale(error, lookup_flags)) {
57778 lookup_flags |= LOOKUP_REVAL;
57779 @@ -3292,9 +3416,16 @@ retry:
57780
57781 if (!IS_POSIXACL(path.dentry->d_inode))
57782 mode &= ~current_umask();
57783 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57784 + error = -EACCES;
57785 + goto out;
57786 + }
57787 error = security_path_mkdir(&path, dentry, mode);
57788 if (!error)
57789 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57790 + if (!error)
57791 + gr_handle_create(dentry, path.mnt);
57792 +out:
57793 done_path_create(&path, dentry);
57794 if (retry_estale(error, lookup_flags)) {
57795 lookup_flags |= LOOKUP_REVAL;
57796 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57797 struct filename *name;
57798 struct dentry *dentry;
57799 struct nameidata nd;
57800 + ino_t saved_ino = 0;
57801 + dev_t saved_dev = 0;
57802 unsigned int lookup_flags = 0;
57803 retry:
57804 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57805 @@ -3407,10 +3540,21 @@ retry:
57806 error = -ENOENT;
57807 goto exit3;
57808 }
57809 +
57810 + saved_ino = dentry->d_inode->i_ino;
57811 + saved_dev = gr_get_dev_from_dentry(dentry);
57812 +
57813 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57814 + error = -EACCES;
57815 + goto exit3;
57816 + }
57817 +
57818 error = security_path_rmdir(&nd.path, dentry);
57819 if (error)
57820 goto exit3;
57821 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57822 + if (!error && (saved_dev || saved_ino))
57823 + gr_handle_delete(saved_ino, saved_dev);
57824 exit3:
57825 dput(dentry);
57826 exit2:
57827 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57828 struct dentry *dentry;
57829 struct nameidata nd;
57830 struct inode *inode = NULL;
57831 + ino_t saved_ino = 0;
57832 + dev_t saved_dev = 0;
57833 unsigned int lookup_flags = 0;
57834 retry:
57835 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57836 @@ -3502,10 +3648,22 @@ retry:
57837 if (!inode)
57838 goto slashes;
57839 ihold(inode);
57840 +
57841 + if (inode->i_nlink <= 1) {
57842 + saved_ino = inode->i_ino;
57843 + saved_dev = gr_get_dev_from_dentry(dentry);
57844 + }
57845 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57846 + error = -EACCES;
57847 + goto exit2;
57848 + }
57849 +
57850 error = security_path_unlink(&nd.path, dentry);
57851 if (error)
57852 goto exit2;
57853 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57854 + if (!error && (saved_ino || saved_dev))
57855 + gr_handle_delete(saved_ino, saved_dev);
57856 exit2:
57857 dput(dentry);
57858 }
57859 @@ -3583,9 +3741,17 @@ retry:
57860 if (IS_ERR(dentry))
57861 goto out_putname;
57862
57863 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57864 + error = -EACCES;
57865 + goto out;
57866 + }
57867 +
57868 error = security_path_symlink(&path, dentry, from->name);
57869 if (!error)
57870 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57871 + if (!error)
57872 + gr_handle_create(dentry, path.mnt);
57873 +out:
57874 done_path_create(&path, dentry);
57875 if (retry_estale(error, lookup_flags)) {
57876 lookup_flags |= LOOKUP_REVAL;
57877 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57878 {
57879 struct dentry *new_dentry;
57880 struct path old_path, new_path;
57881 + struct filename *to = NULL;
57882 int how = 0;
57883 int error;
57884
57885 @@ -3688,7 +3855,7 @@ retry:
57886 if (error)
57887 return error;
57888
57889 - new_dentry = user_path_create(newdfd, newname, &new_path,
57890 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57891 (how & LOOKUP_REVAL));
57892 error = PTR_ERR(new_dentry);
57893 if (IS_ERR(new_dentry))
57894 @@ -3700,11 +3867,28 @@ retry:
57895 error = may_linkat(&old_path);
57896 if (unlikely(error))
57897 goto out_dput;
57898 +
57899 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57900 + old_path.dentry->d_inode,
57901 + old_path.dentry->d_inode->i_mode, to)) {
57902 + error = -EACCES;
57903 + goto out_dput;
57904 + }
57905 +
57906 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57907 + old_path.dentry, old_path.mnt, to)) {
57908 + error = -EACCES;
57909 + goto out_dput;
57910 + }
57911 +
57912 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57913 if (error)
57914 goto out_dput;
57915 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57916 + if (!error)
57917 + gr_handle_create(new_dentry, new_path.mnt);
57918 out_dput:
57919 + putname(to);
57920 done_path_create(&new_path, new_dentry);
57921 if (retry_estale(error, how)) {
57922 how |= LOOKUP_REVAL;
57923 @@ -3950,12 +4134,21 @@ retry:
57924 if (new_dentry == trap)
57925 goto exit5;
57926
57927 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57928 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57929 + to);
57930 + if (error)
57931 + goto exit5;
57932 +
57933 error = security_path_rename(&oldnd.path, old_dentry,
57934 &newnd.path, new_dentry);
57935 if (error)
57936 goto exit5;
57937 error = vfs_rename(old_dir->d_inode, old_dentry,
57938 new_dir->d_inode, new_dentry);
57939 + if (!error)
57940 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57941 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57942 exit5:
57943 dput(new_dentry);
57944 exit4:
57945 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57946
57947 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57948 {
57949 + char tmpbuf[64];
57950 + const char *newlink;
57951 int len;
57952
57953 len = PTR_ERR(link);
57954 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57955 len = strlen(link);
57956 if (len > (unsigned) buflen)
57957 len = buflen;
57958 - if (copy_to_user(buffer, link, len))
57959 +
57960 + if (len < sizeof(tmpbuf)) {
57961 + memcpy(tmpbuf, link, len);
57962 + newlink = tmpbuf;
57963 + } else
57964 + newlink = link;
57965 +
57966 + if (copy_to_user(buffer, newlink, len))
57967 len = -EFAULT;
57968 out:
57969 return len;
57970 diff --git a/fs/namespace.c b/fs/namespace.c
57971 index a45ba4f..b4c7d07 100644
57972 --- a/fs/namespace.c
57973 +++ b/fs/namespace.c
57974 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57975 if (!(sb->s_flags & MS_RDONLY))
57976 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57977 up_write(&sb->s_umount);
57978 +
57979 + gr_log_remount(mnt->mnt_devname, retval);
57980 +
57981 return retval;
57982 }
57983
57984 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57985 }
57986 br_write_unlock(&vfsmount_lock);
57987 namespace_unlock();
57988 +
57989 + gr_log_unmount(mnt->mnt_devname, retval);
57990 +
57991 return retval;
57992 }
57993
57994 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57995 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57996 */
57997
57998 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57999 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58000 {
58001 struct path path;
58002 struct mount *mnt;
58003 @@ -1342,7 +1348,7 @@ out:
58004 /*
58005 * The 2.0 compatible umount. No flags.
58006 */
58007 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58008 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58009 {
58010 return sys_umount(name, 0);
58011 }
58012 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58013 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58014 MS_STRICTATIME);
58015
58016 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58017 + retval = -EPERM;
58018 + goto dput_out;
58019 + }
58020 +
58021 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58022 + retval = -EPERM;
58023 + goto dput_out;
58024 + }
58025 +
58026 if (flags & MS_REMOUNT)
58027 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58028 data_page);
58029 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58030 dev_name, data_page);
58031 dput_out:
58032 path_put(&path);
58033 +
58034 + gr_log_mount(dev_name, dir_name, retval);
58035 +
58036 return retval;
58037 }
58038
58039 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58040 * number incrementing at 10Ghz will take 12,427 years to wrap which
58041 * is effectively never, so we can ignore the possibility.
58042 */
58043 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58044 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58045
58046 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58047 {
58048 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58049 kfree(new_ns);
58050 return ERR_PTR(ret);
58051 }
58052 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58053 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58054 atomic_set(&new_ns->count, 1);
58055 new_ns->root = NULL;
58056 INIT_LIST_HEAD(&new_ns->list);
58057 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58058 * Allocate a new namespace structure and populate it with contents
58059 * copied from the namespace of the passed in task structure.
58060 */
58061 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58062 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58063 struct user_namespace *user_ns, struct fs_struct *fs)
58064 {
58065 struct mnt_namespace *new_ns;
58066 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58067 }
58068 EXPORT_SYMBOL(mount_subtree);
58069
58070 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58071 - char __user *, type, unsigned long, flags, void __user *, data)
58072 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58073 + const char __user *, type, unsigned long, flags, void __user *, data)
58074 {
58075 int ret;
58076 char *kernel_type;
58077 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58078 if (error)
58079 goto out2;
58080
58081 + if (gr_handle_chroot_pivot()) {
58082 + error = -EPERM;
58083 + goto out2;
58084 + }
58085 +
58086 get_fs_root(current->fs, &root);
58087 old_mp = lock_mount(&old);
58088 error = PTR_ERR(old_mp);
58089 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58090 !nsown_capable(CAP_SYS_ADMIN))
58091 return -EPERM;
58092
58093 - if (fs->users != 1)
58094 + if (atomic_read(&fs->users) != 1)
58095 return -EINVAL;
58096
58097 get_mnt_ns(mnt_ns);
58098 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58099 index f4ccfe6..a5cf064 100644
58100 --- a/fs/nfs/callback_xdr.c
58101 +++ b/fs/nfs/callback_xdr.c
58102 @@ -51,7 +51,7 @@ struct callback_op {
58103 callback_decode_arg_t decode_args;
58104 callback_encode_res_t encode_res;
58105 long res_maxsize;
58106 -};
58107 +} __do_const;
58108
58109 static struct callback_op callback_ops[];
58110
58111 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58112 index 941246f..17d8724 100644
58113 --- a/fs/nfs/inode.c
58114 +++ b/fs/nfs/inode.c
58115 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58116 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58117 }
58118
58119 -static atomic_long_t nfs_attr_generation_counter;
58120 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58121
58122 static unsigned long nfs_read_attr_generation_counter(void)
58123 {
58124 - return atomic_long_read(&nfs_attr_generation_counter);
58125 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58126 }
58127
58128 unsigned long nfs_inc_attr_generation_counter(void)
58129 {
58130 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58131 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58132 }
58133
58134 void nfs_fattr_init(struct nfs_fattr *fattr)
58135 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58136 index 419572f..5414a23 100644
58137 --- a/fs/nfsd/nfs4proc.c
58138 +++ b/fs/nfsd/nfs4proc.c
58139 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58140 nfsd4op_rsize op_rsize_bop;
58141 stateid_getter op_get_currentstateid;
58142 stateid_setter op_set_currentstateid;
58143 -};
58144 +} __do_const;
58145
58146 static struct nfsd4_operation nfsd4_ops[];
58147
58148 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58149 index c2a4701..fd80e29 100644
58150 --- a/fs/nfsd/nfs4xdr.c
58151 +++ b/fs/nfsd/nfs4xdr.c
58152 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58153
58154 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58155
58156 -static nfsd4_dec nfsd4_dec_ops[] = {
58157 +static const nfsd4_dec nfsd4_dec_ops[] = {
58158 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58159 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58160 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58161 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58162 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58163 };
58164
58165 -static nfsd4_dec nfsd41_dec_ops[] = {
58166 +static const nfsd4_dec nfsd41_dec_ops[] = {
58167 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58168 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58169 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58170 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58171 };
58172
58173 struct nfsd4_minorversion_ops {
58174 - nfsd4_dec *decoders;
58175 + const nfsd4_dec *decoders;
58176 int nops;
58177 };
58178
58179 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58180 index e76244e..9fe8f2f1 100644
58181 --- a/fs/nfsd/nfscache.c
58182 +++ b/fs/nfsd/nfscache.c
58183 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58184 {
58185 struct svc_cacherep *rp = rqstp->rq_cacherep;
58186 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58187 - int len;
58188 + long len;
58189 size_t bufsize = 0;
58190
58191 if (!rp)
58192 return;
58193
58194 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58195 - len >>= 2;
58196 + if (statp) {
58197 + len = (char*)statp - (char*)resv->iov_base;
58198 + len = resv->iov_len - len;
58199 + len >>= 2;
58200 + }
58201
58202 /* Don't cache excessive amounts of data and XDR failures */
58203 if (!statp || len > (256 >> 2)) {
58204 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58205 index c827acb..b253b77 100644
58206 --- a/fs/nfsd/vfs.c
58207 +++ b/fs/nfsd/vfs.c
58208 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58209 } else {
58210 oldfs = get_fs();
58211 set_fs(KERNEL_DS);
58212 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58213 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58214 set_fs(oldfs);
58215 }
58216
58217 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58218
58219 /* Write the data. */
58220 oldfs = get_fs(); set_fs(KERNEL_DS);
58221 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58222 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58223 set_fs(oldfs);
58224 if (host_err < 0)
58225 goto out_nfserr;
58226 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58227 */
58228
58229 oldfs = get_fs(); set_fs(KERNEL_DS);
58230 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58231 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58232 set_fs(oldfs);
58233
58234 if (host_err < 0)
58235 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58236 index fea6bd5..8ee9d81 100644
58237 --- a/fs/nls/nls_base.c
58238 +++ b/fs/nls/nls_base.c
58239 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58240
58241 int register_nls(struct nls_table * nls)
58242 {
58243 - struct nls_table ** tmp = &tables;
58244 + struct nls_table *tmp = tables;
58245
58246 if (nls->next)
58247 return -EBUSY;
58248
58249 spin_lock(&nls_lock);
58250 - while (*tmp) {
58251 - if (nls == *tmp) {
58252 + while (tmp) {
58253 + if (nls == tmp) {
58254 spin_unlock(&nls_lock);
58255 return -EBUSY;
58256 }
58257 - tmp = &(*tmp)->next;
58258 + tmp = tmp->next;
58259 }
58260 - nls->next = tables;
58261 + pax_open_kernel();
58262 + *(struct nls_table **)&nls->next = tables;
58263 + pax_close_kernel();
58264 tables = nls;
58265 spin_unlock(&nls_lock);
58266 return 0;
58267 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58268
58269 int unregister_nls(struct nls_table * nls)
58270 {
58271 - struct nls_table ** tmp = &tables;
58272 + struct nls_table * const * tmp = &tables;
58273
58274 spin_lock(&nls_lock);
58275 while (*tmp) {
58276 if (nls == *tmp) {
58277 - *tmp = nls->next;
58278 + pax_open_kernel();
58279 + *(struct nls_table **)tmp = nls->next;
58280 + pax_close_kernel();
58281 spin_unlock(&nls_lock);
58282 return 0;
58283 }
58284 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58285 index 7424929..35f6be5 100644
58286 --- a/fs/nls/nls_euc-jp.c
58287 +++ b/fs/nls/nls_euc-jp.c
58288 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58289 p_nls = load_nls("cp932");
58290
58291 if (p_nls) {
58292 - table.charset2upper = p_nls->charset2upper;
58293 - table.charset2lower = p_nls->charset2lower;
58294 + pax_open_kernel();
58295 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58296 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58297 + pax_close_kernel();
58298 return register_nls(&table);
58299 }
58300
58301 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58302 index e7bc1d7..06bd4bb 100644
58303 --- a/fs/nls/nls_koi8-ru.c
58304 +++ b/fs/nls/nls_koi8-ru.c
58305 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58306 p_nls = load_nls("koi8-u");
58307
58308 if (p_nls) {
58309 - table.charset2upper = p_nls->charset2upper;
58310 - table.charset2lower = p_nls->charset2lower;
58311 + pax_open_kernel();
58312 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58313 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58314 + pax_close_kernel();
58315 return register_nls(&table);
58316 }
58317
58318 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58319 index e44cb64..4807084 100644
58320 --- a/fs/notify/fanotify/fanotify_user.c
58321 +++ b/fs/notify/fanotify/fanotify_user.c
58322 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58323
58324 fd = fanotify_event_metadata.fd;
58325 ret = -EFAULT;
58326 - if (copy_to_user(buf, &fanotify_event_metadata,
58327 - fanotify_event_metadata.event_len))
58328 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58329 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58330 goto out_close_fd;
58331
58332 ret = prepare_for_access_response(group, event, fd);
58333 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58334 index 7b51b05..5ea5ef6 100644
58335 --- a/fs/notify/notification.c
58336 +++ b/fs/notify/notification.c
58337 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58338 * get set to 0 so it will never get 'freed'
58339 */
58340 static struct fsnotify_event *q_overflow_event;
58341 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58342 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58343
58344 /**
58345 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58346 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58347 */
58348 u32 fsnotify_get_cookie(void)
58349 {
58350 - return atomic_inc_return(&fsnotify_sync_cookie);
58351 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58352 }
58353 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58354
58355 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58356 index 9e38daf..5727cae 100644
58357 --- a/fs/ntfs/dir.c
58358 +++ b/fs/ntfs/dir.c
58359 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58360 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58361 ~(s64)(ndir->itype.index.block_size - 1)));
58362 /* Bounds checks. */
58363 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58364 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58365 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58366 "inode 0x%lx or driver bug.", vdir->i_ino);
58367 goto err_out;
58368 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58369 index c5670b8..d590213 100644
58370 --- a/fs/ntfs/file.c
58371 +++ b/fs/ntfs/file.c
58372 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58373 char *addr;
58374 size_t total = 0;
58375 unsigned len;
58376 - int left;
58377 + unsigned left;
58378
58379 do {
58380 len = PAGE_CACHE_SIZE - ofs;
58381 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58382 index 82650d5..db37dcf 100644
58383 --- a/fs/ntfs/super.c
58384 +++ b/fs/ntfs/super.c
58385 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58386 if (!silent)
58387 ntfs_error(sb, "Primary boot sector is invalid.");
58388 } else if (!silent)
58389 - ntfs_error(sb, read_err_str, "primary");
58390 + ntfs_error(sb, read_err_str, "%s", "primary");
58391 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58392 if (bh_primary)
58393 brelse(bh_primary);
58394 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58395 goto hotfix_primary_boot_sector;
58396 brelse(bh_backup);
58397 } else if (!silent)
58398 - ntfs_error(sb, read_err_str, "backup");
58399 + ntfs_error(sb, read_err_str, "%s", "backup");
58400 /* Try to read NT3.51- backup boot sector. */
58401 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58402 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58403 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58404 "sector.");
58405 brelse(bh_backup);
58406 } else if (!silent)
58407 - ntfs_error(sb, read_err_str, "backup");
58408 + ntfs_error(sb, read_err_str, "%s", "backup");
58409 /* We failed. Cleanup and return. */
58410 if (bh_primary)
58411 brelse(bh_primary);
58412 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58413 index aebeacd..0dcdd26 100644
58414 --- a/fs/ocfs2/localalloc.c
58415 +++ b/fs/ocfs2/localalloc.c
58416 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58417 goto bail;
58418 }
58419
58420 - atomic_inc(&osb->alloc_stats.moves);
58421 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58422
58423 bail:
58424 if (handle)
58425 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58426 index 3a90347..c40bef8 100644
58427 --- a/fs/ocfs2/ocfs2.h
58428 +++ b/fs/ocfs2/ocfs2.h
58429 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58430
58431 struct ocfs2_alloc_stats
58432 {
58433 - atomic_t moves;
58434 - atomic_t local_data;
58435 - atomic_t bitmap_data;
58436 - atomic_t bg_allocs;
58437 - atomic_t bg_extends;
58438 + atomic_unchecked_t moves;
58439 + atomic_unchecked_t local_data;
58440 + atomic_unchecked_t bitmap_data;
58441 + atomic_unchecked_t bg_allocs;
58442 + atomic_unchecked_t bg_extends;
58443 };
58444
58445 enum ocfs2_local_alloc_state
58446 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58447 index 5397c07..54afc55 100644
58448 --- a/fs/ocfs2/suballoc.c
58449 +++ b/fs/ocfs2/suballoc.c
58450 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58451 mlog_errno(status);
58452 goto bail;
58453 }
58454 - atomic_inc(&osb->alloc_stats.bg_extends);
58455 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58456
58457 /* You should never ask for this much metadata */
58458 BUG_ON(bits_wanted >
58459 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58460 mlog_errno(status);
58461 goto bail;
58462 }
58463 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58464 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58465
58466 *suballoc_loc = res.sr_bg_blkno;
58467 *suballoc_bit_start = res.sr_bit_offset;
58468 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58469 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58470 res->sr_bits);
58471
58472 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58473 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58474
58475 BUG_ON(res->sr_bits != 1);
58476
58477 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58478 mlog_errno(status);
58479 goto bail;
58480 }
58481 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58482 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58483
58484 BUG_ON(res.sr_bits != 1);
58485
58486 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58487 cluster_start,
58488 num_clusters);
58489 if (!status)
58490 - atomic_inc(&osb->alloc_stats.local_data);
58491 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58492 } else {
58493 if (min_clusters > (osb->bitmap_cpg - 1)) {
58494 /* The only paths asking for contiguousness
58495 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58496 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58497 res.sr_bg_blkno,
58498 res.sr_bit_offset);
58499 - atomic_inc(&osb->alloc_stats.bitmap_data);
58500 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58501 *num_clusters = res.sr_bits;
58502 }
58503 }
58504 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58505 index 121da2d..a0232bc 100644
58506 --- a/fs/ocfs2/super.c
58507 +++ b/fs/ocfs2/super.c
58508 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58509 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58510 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58511 "Stats",
58512 - atomic_read(&osb->alloc_stats.bitmap_data),
58513 - atomic_read(&osb->alloc_stats.local_data),
58514 - atomic_read(&osb->alloc_stats.bg_allocs),
58515 - atomic_read(&osb->alloc_stats.moves),
58516 - atomic_read(&osb->alloc_stats.bg_extends));
58517 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58518 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58519 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58520 + atomic_read_unchecked(&osb->alloc_stats.moves),
58521 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58522
58523 out += snprintf(buf + out, len - out,
58524 "%10s => State: %u Descriptor: %llu Size: %u bits "
58525 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58526 spin_lock_init(&osb->osb_xattr_lock);
58527 ocfs2_init_steal_slots(osb);
58528
58529 - atomic_set(&osb->alloc_stats.moves, 0);
58530 - atomic_set(&osb->alloc_stats.local_data, 0);
58531 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58532 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58533 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58534 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58535 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58536 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58537 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58538 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58539
58540 /* Copy the blockcheck stats from the superblock probe */
58541 osb->osb_ecc_stats = *stats;
58542 diff --git a/fs/open.c b/fs/open.c
58543 index 7931f76..7b03f3b 100644
58544 --- a/fs/open.c
58545 +++ b/fs/open.c
58546 @@ -32,6 +32,8 @@
58547 #include <linux/dnotify.h>
58548 #include <linux/compat.h>
58549
58550 +#define CREATE_TRACE_POINTS
58551 +#include <trace/events/fs.h>
58552 #include "internal.h"
58553
58554 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58555 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58556 error = locks_verify_truncate(inode, NULL, length);
58557 if (!error)
58558 error = security_path_truncate(path);
58559 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58560 + error = -EACCES;
58561 if (!error)
58562 error = do_truncate(path->dentry, length, 0, NULL);
58563
58564 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58565 error = locks_verify_truncate(inode, f.file, length);
58566 if (!error)
58567 error = security_path_truncate(&f.file->f_path);
58568 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58569 + error = -EACCES;
58570 if (!error)
58571 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58572 sb_end_write(inode->i_sb);
58573 @@ -360,6 +366,9 @@ retry:
58574 if (__mnt_is_readonly(path.mnt))
58575 res = -EROFS;
58576
58577 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58578 + res = -EACCES;
58579 +
58580 out_path_release:
58581 path_put(&path);
58582 if (retry_estale(res, lookup_flags)) {
58583 @@ -391,6 +400,8 @@ retry:
58584 if (error)
58585 goto dput_and_out;
58586
58587 + gr_log_chdir(path.dentry, path.mnt);
58588 +
58589 set_fs_pwd(current->fs, &path);
58590
58591 dput_and_out:
58592 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58593 goto out_putf;
58594
58595 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58596 +
58597 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58598 + error = -EPERM;
58599 +
58600 + if (!error)
58601 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58602 +
58603 if (!error)
58604 set_fs_pwd(current->fs, &f.file->f_path);
58605 out_putf:
58606 @@ -449,7 +467,13 @@ retry:
58607 if (error)
58608 goto dput_and_out;
58609
58610 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58611 + goto dput_and_out;
58612 +
58613 set_fs_root(current->fs, &path);
58614 +
58615 + gr_handle_chroot_chdir(&path);
58616 +
58617 error = 0;
58618 dput_and_out:
58619 path_put(&path);
58620 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58621 if (error)
58622 return error;
58623 mutex_lock(&inode->i_mutex);
58624 +
58625 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58626 + error = -EACCES;
58627 + goto out_unlock;
58628 + }
58629 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58630 + error = -EACCES;
58631 + goto out_unlock;
58632 + }
58633 +
58634 error = security_path_chmod(path, mode);
58635 if (error)
58636 goto out_unlock;
58637 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58638 uid = make_kuid(current_user_ns(), user);
58639 gid = make_kgid(current_user_ns(), group);
58640
58641 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58642 + return -EACCES;
58643 +
58644 newattrs.ia_valid = ATTR_CTIME;
58645 if (user != (uid_t) -1) {
58646 if (!uid_valid(uid))
58647 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58648 } else {
58649 fsnotify_open(f);
58650 fd_install(fd, f);
58651 + trace_do_sys_open(tmp->name, flags, mode);
58652 }
58653 }
58654 putname(tmp);
58655 diff --git a/fs/pipe.c b/fs/pipe.c
58656 index d2c45e1..009fe1c 100644
58657 --- a/fs/pipe.c
58658 +++ b/fs/pipe.c
58659 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58660
58661 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58662 {
58663 - if (pipe->files)
58664 + if (atomic_read(&pipe->files))
58665 mutex_lock_nested(&pipe->mutex, subclass);
58666 }
58667
58668 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58669
58670 void pipe_unlock(struct pipe_inode_info *pipe)
58671 {
58672 - if (pipe->files)
58673 + if (atomic_read(&pipe->files))
58674 mutex_unlock(&pipe->mutex);
58675 }
58676 EXPORT_SYMBOL(pipe_unlock);
58677 @@ -449,9 +449,9 @@ redo:
58678 }
58679 if (bufs) /* More to do? */
58680 continue;
58681 - if (!pipe->writers)
58682 + if (!atomic_read(&pipe->writers))
58683 break;
58684 - if (!pipe->waiting_writers) {
58685 + if (!atomic_read(&pipe->waiting_writers)) {
58686 /* syscall merging: Usually we must not sleep
58687 * if O_NONBLOCK is set, or if we got some data.
58688 * But if a writer sleeps in kernel space, then
58689 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58690 ret = 0;
58691 __pipe_lock(pipe);
58692
58693 - if (!pipe->readers) {
58694 + if (!atomic_read(&pipe->readers)) {
58695 send_sig(SIGPIPE, current, 0);
58696 ret = -EPIPE;
58697 goto out;
58698 @@ -562,7 +562,7 @@ redo1:
58699 for (;;) {
58700 int bufs;
58701
58702 - if (!pipe->readers) {
58703 + if (!atomic_read(&pipe->readers)) {
58704 send_sig(SIGPIPE, current, 0);
58705 if (!ret)
58706 ret = -EPIPE;
58707 @@ -653,9 +653,9 @@ redo2:
58708 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58709 do_wakeup = 0;
58710 }
58711 - pipe->waiting_writers++;
58712 + atomic_inc(&pipe->waiting_writers);
58713 pipe_wait(pipe);
58714 - pipe->waiting_writers--;
58715 + atomic_dec(&pipe->waiting_writers);
58716 }
58717 out:
58718 __pipe_unlock(pipe);
58719 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58720 mask = 0;
58721 if (filp->f_mode & FMODE_READ) {
58722 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58723 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58724 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58725 mask |= POLLHUP;
58726 }
58727
58728 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58729 * Most Unices do not set POLLERR for FIFOs but on Linux they
58730 * behave exactly like pipes for poll().
58731 */
58732 - if (!pipe->readers)
58733 + if (!atomic_read(&pipe->readers))
58734 mask |= POLLERR;
58735 }
58736
58737 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58738
58739 __pipe_lock(pipe);
58740 if (file->f_mode & FMODE_READ)
58741 - pipe->readers--;
58742 + atomic_dec(&pipe->readers);
58743 if (file->f_mode & FMODE_WRITE)
58744 - pipe->writers--;
58745 + atomic_dec(&pipe->writers);
58746
58747 - if (pipe->readers || pipe->writers) {
58748 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58749 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58750 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58751 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58752 }
58753 spin_lock(&inode->i_lock);
58754 - if (!--pipe->files) {
58755 + if (atomic_dec_and_test(&pipe->files)) {
58756 inode->i_pipe = NULL;
58757 kill = 1;
58758 }
58759 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58760 kfree(pipe);
58761 }
58762
58763 -static struct vfsmount *pipe_mnt __read_mostly;
58764 +struct vfsmount *pipe_mnt __read_mostly;
58765
58766 /*
58767 * pipefs_dname() is called from d_path().
58768 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58769 goto fail_iput;
58770
58771 inode->i_pipe = pipe;
58772 - pipe->files = 2;
58773 - pipe->readers = pipe->writers = 1;
58774 + atomic_set(&pipe->files, 2);
58775 + atomic_set(&pipe->readers, 1);
58776 + atomic_set(&pipe->writers, 1);
58777 inode->i_fop = &pipefifo_fops;
58778
58779 /*
58780 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58781 spin_lock(&inode->i_lock);
58782 if (inode->i_pipe) {
58783 pipe = inode->i_pipe;
58784 - pipe->files++;
58785 + atomic_inc(&pipe->files);
58786 spin_unlock(&inode->i_lock);
58787 } else {
58788 spin_unlock(&inode->i_lock);
58789 pipe = alloc_pipe_info();
58790 if (!pipe)
58791 return -ENOMEM;
58792 - pipe->files = 1;
58793 + atomic_set(&pipe->files, 1);
58794 spin_lock(&inode->i_lock);
58795 if (unlikely(inode->i_pipe)) {
58796 - inode->i_pipe->files++;
58797 + atomic_inc(&inode->i_pipe->files);
58798 spin_unlock(&inode->i_lock);
58799 free_pipe_info(pipe);
58800 pipe = inode->i_pipe;
58801 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58802 * opened, even when there is no process writing the FIFO.
58803 */
58804 pipe->r_counter++;
58805 - if (pipe->readers++ == 0)
58806 + if (atomic_inc_return(&pipe->readers) == 1)
58807 wake_up_partner(pipe);
58808
58809 - if (!is_pipe && !pipe->writers) {
58810 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58811 if ((filp->f_flags & O_NONBLOCK)) {
58812 /* suppress POLLHUP until we have
58813 * seen a writer */
58814 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58815 * errno=ENXIO when there is no process reading the FIFO.
58816 */
58817 ret = -ENXIO;
58818 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58819 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58820 goto err;
58821
58822 pipe->w_counter++;
58823 - if (!pipe->writers++)
58824 + if (atomic_inc_return(&pipe->writers) == 1)
58825 wake_up_partner(pipe);
58826
58827 - if (!is_pipe && !pipe->readers) {
58828 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58829 if (wait_for_partner(pipe, &pipe->r_counter))
58830 goto err_wr;
58831 }
58832 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58833 * the process can at least talk to itself.
58834 */
58835
58836 - pipe->readers++;
58837 - pipe->writers++;
58838 + atomic_inc(&pipe->readers);
58839 + atomic_inc(&pipe->writers);
58840 pipe->r_counter++;
58841 pipe->w_counter++;
58842 - if (pipe->readers == 1 || pipe->writers == 1)
58843 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58844 wake_up_partner(pipe);
58845 break;
58846
58847 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58848 return 0;
58849
58850 err_rd:
58851 - if (!--pipe->readers)
58852 + if (atomic_dec_and_test(&pipe->readers))
58853 wake_up_interruptible(&pipe->wait);
58854 ret = -ERESTARTSYS;
58855 goto err;
58856
58857 err_wr:
58858 - if (!--pipe->writers)
58859 + if (atomic_dec_and_test(&pipe->writers))
58860 wake_up_interruptible(&pipe->wait);
58861 ret = -ERESTARTSYS;
58862 goto err;
58863
58864 err:
58865 spin_lock(&inode->i_lock);
58866 - if (!--pipe->files) {
58867 + if (atomic_dec_and_test(&pipe->files)) {
58868 inode->i_pipe = NULL;
58869 kill = 1;
58870 }
58871 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58872 index 15af622..0e9f4467 100644
58873 --- a/fs/proc/Kconfig
58874 +++ b/fs/proc/Kconfig
58875 @@ -30,12 +30,12 @@ config PROC_FS
58876
58877 config PROC_KCORE
58878 bool "/proc/kcore support" if !ARM
58879 - depends on PROC_FS && MMU
58880 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58881
58882 config PROC_VMCORE
58883 bool "/proc/vmcore support"
58884 - depends on PROC_FS && CRASH_DUMP
58885 - default y
58886 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58887 + default n
58888 help
58889 Exports the dump image of crashed kernel in ELF format.
58890
58891 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58892 limited in memory.
58893
58894 config PROC_PAGE_MONITOR
58895 - default y
58896 - depends on PROC_FS && MMU
58897 + default n
58898 + depends on PROC_FS && MMU && !GRKERNSEC
58899 bool "Enable /proc page monitoring" if EXPERT
58900 help
58901 Various /proc files exist to monitor process memory utilization:
58902 diff --git a/fs/proc/array.c b/fs/proc/array.c
58903 index cbd0f1b..adec3f0 100644
58904 --- a/fs/proc/array.c
58905 +++ b/fs/proc/array.c
58906 @@ -60,6 +60,7 @@
58907 #include <linux/tty.h>
58908 #include <linux/string.h>
58909 #include <linux/mman.h>
58910 +#include <linux/grsecurity.h>
58911 #include <linux/proc_fs.h>
58912 #include <linux/ioport.h>
58913 #include <linux/uaccess.h>
58914 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58915 seq_putc(m, '\n');
58916 }
58917
58918 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58919 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58920 +{
58921 + if (p->mm)
58922 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58923 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58924 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58925 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58926 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58927 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58928 + else
58929 + seq_printf(m, "PaX:\t-----\n");
58930 +}
58931 +#endif
58932 +
58933 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58934 struct pid *pid, struct task_struct *task)
58935 {
58936 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58937 task_cpus_allowed(m, task);
58938 cpuset_task_status_allowed(m, task);
58939 task_context_switch_counts(m, task);
58940 +
58941 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58942 + task_pax(m, task);
58943 +#endif
58944 +
58945 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58946 + task_grsec_rbac(m, task);
58947 +#endif
58948 +
58949 return 0;
58950 }
58951
58952 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58953 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58954 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58955 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58956 +#endif
58957 +
58958 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58959 struct pid *pid, struct task_struct *task, int whole)
58960 {
58961 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58962 char tcomm[sizeof(task->comm)];
58963 unsigned long flags;
58964
58965 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58966 + if (current->exec_id != m->exec_id) {
58967 + gr_log_badprocpid("stat");
58968 + return 0;
58969 + }
58970 +#endif
58971 +
58972 state = *get_task_state(task);
58973 vsize = eip = esp = 0;
58974 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58975 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58976 gtime = task_gtime(task);
58977 }
58978
58979 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58980 + if (PAX_RAND_FLAGS(mm)) {
58981 + eip = 0;
58982 + esp = 0;
58983 + wchan = 0;
58984 + }
58985 +#endif
58986 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58987 + wchan = 0;
58988 + eip =0;
58989 + esp =0;
58990 +#endif
58991 +
58992 /* scale priority and nice values from timeslices to -20..20 */
58993 /* to make it look like a "normal" Unix priority/nice value */
58994 priority = task_prio(task);
58995 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58996 seq_put_decimal_ull(m, ' ', vsize);
58997 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
58998 seq_put_decimal_ull(m, ' ', rsslim);
58999 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59000 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59001 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59002 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59003 +#else
59004 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59005 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59006 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59007 +#endif
59008 seq_put_decimal_ull(m, ' ', esp);
59009 seq_put_decimal_ull(m, ' ', eip);
59010 /* The signal information here is obsolete.
59011 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59012 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59013 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59014
59015 - if (mm && permitted) {
59016 + if (mm && permitted
59017 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59018 + && !PAX_RAND_FLAGS(mm)
59019 +#endif
59020 + ) {
59021 seq_put_decimal_ull(m, ' ', mm->start_data);
59022 seq_put_decimal_ull(m, ' ', mm->end_data);
59023 seq_put_decimal_ull(m, ' ', mm->start_brk);
59024 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59025 struct pid *pid, struct task_struct *task)
59026 {
59027 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59028 - struct mm_struct *mm = get_task_mm(task);
59029 + struct mm_struct *mm;
59030
59031 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59032 + if (current->exec_id != m->exec_id) {
59033 + gr_log_badprocpid("statm");
59034 + return 0;
59035 + }
59036 +#endif
59037 + mm = get_task_mm(task);
59038 if (mm) {
59039 size = task_statm(mm, &shared, &text, &data, &resident);
59040 mmput(mm);
59041 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59042 return 0;
59043 }
59044
59045 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59046 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59047 +{
59048 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59049 +}
59050 +#endif
59051 +
59052 #ifdef CONFIG_CHECKPOINT_RESTORE
59053 static struct pid *
59054 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59055 diff --git a/fs/proc/base.c b/fs/proc/base.c
59056 index 1485e38..8ad4236 100644
59057 --- a/fs/proc/base.c
59058 +++ b/fs/proc/base.c
59059 @@ -113,6 +113,14 @@ struct pid_entry {
59060 union proc_op op;
59061 };
59062
59063 +struct getdents_callback {
59064 + struct linux_dirent __user * current_dir;
59065 + struct linux_dirent __user * previous;
59066 + struct file * file;
59067 + int count;
59068 + int error;
59069 +};
59070 +
59071 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59072 .name = (NAME), \
59073 .len = sizeof(NAME) - 1, \
59074 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59075 if (!mm->arg_end)
59076 goto out_mm; /* Shh! No looking before we're done */
59077
59078 + if (gr_acl_handle_procpidmem(task))
59079 + goto out_mm;
59080 +
59081 len = mm->arg_end - mm->arg_start;
59082
59083 if (len > PAGE_SIZE)
59084 @@ -237,12 +248,28 @@ out:
59085 return res;
59086 }
59087
59088 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59089 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59090 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59091 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59092 +#endif
59093 +
59094 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59095 {
59096 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59097 int res = PTR_ERR(mm);
59098 if (mm && !IS_ERR(mm)) {
59099 unsigned int nwords = 0;
59100 +
59101 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59102 + /* allow if we're currently ptracing this task */
59103 + if (PAX_RAND_FLAGS(mm) &&
59104 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59105 + mmput(mm);
59106 + return 0;
59107 + }
59108 +#endif
59109 +
59110 do {
59111 nwords += 2;
59112 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59113 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59114 }
59115
59116
59117 -#ifdef CONFIG_KALLSYMS
59118 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59119 /*
59120 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59121 * Returns the resolved symbol. If that fails, simply return the address.
59122 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59123 mutex_unlock(&task->signal->cred_guard_mutex);
59124 }
59125
59126 -#ifdef CONFIG_STACKTRACE
59127 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59128
59129 #define MAX_STACK_TRACE_DEPTH 64
59130
59131 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59132 return count;
59133 }
59134
59135 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59136 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59137 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59138 {
59139 long nr;
59140 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59141 /************************************************************************/
59142
59143 /* permission checks */
59144 -static int proc_fd_access_allowed(struct inode *inode)
59145 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59146 {
59147 struct task_struct *task;
59148 int allowed = 0;
59149 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59150 */
59151 task = get_proc_task(inode);
59152 if (task) {
59153 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59154 + if (log)
59155 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59156 + else
59157 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59158 put_task_struct(task);
59159 }
59160 return allowed;
59161 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59162 struct task_struct *task,
59163 int hide_pid_min)
59164 {
59165 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59166 + return false;
59167 +
59168 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59169 + rcu_read_lock();
59170 + {
59171 + const struct cred *tmpcred = current_cred();
59172 + const struct cred *cred = __task_cred(task);
59173 +
59174 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59175 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59176 + || in_group_p(grsec_proc_gid)
59177 +#endif
59178 + ) {
59179 + rcu_read_unlock();
59180 + return true;
59181 + }
59182 + }
59183 + rcu_read_unlock();
59184 +
59185 + if (!pid->hide_pid)
59186 + return false;
59187 +#endif
59188 +
59189 if (pid->hide_pid < hide_pid_min)
59190 return true;
59191 if (in_group_p(pid->pid_gid))
59192 return true;
59193 +
59194 return ptrace_may_access(task, PTRACE_MODE_READ);
59195 }
59196
59197 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59198 put_task_struct(task);
59199
59200 if (!has_perms) {
59201 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59202 + {
59203 +#else
59204 if (pid->hide_pid == 2) {
59205 +#endif
59206 /*
59207 * Let's make getdents(), stat(), and open()
59208 * consistent with each other. If a process
59209 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59210 if (!task)
59211 return -ESRCH;
59212
59213 + if (gr_acl_handle_procpidmem(task)) {
59214 + put_task_struct(task);
59215 + return -EPERM;
59216 + }
59217 +
59218 mm = mm_access(task, mode);
59219 put_task_struct(task);
59220
59221 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59222
59223 file->private_data = mm;
59224
59225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59226 + file->f_version = current->exec_id;
59227 +#endif
59228 +
59229 return 0;
59230 }
59231
59232 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59233 ssize_t copied;
59234 char *page;
59235
59236 +#ifdef CONFIG_GRKERNSEC
59237 + if (write)
59238 + return -EPERM;
59239 +#endif
59240 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59241 + if (file->f_version != current->exec_id) {
59242 + gr_log_badprocpid("mem");
59243 + return 0;
59244 + }
59245 +#endif
59246 +
59247 if (!mm)
59248 return 0;
59249
59250 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59251 goto free;
59252
59253 while (count > 0) {
59254 - int this_len = min_t(int, count, PAGE_SIZE);
59255 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59256
59257 if (write && copy_from_user(page, buf, this_len)) {
59258 copied = -EFAULT;
59259 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59260 if (!mm)
59261 return 0;
59262
59263 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59264 + if (file->f_version != current->exec_id) {
59265 + gr_log_badprocpid("environ");
59266 + return 0;
59267 + }
59268 +#endif
59269 +
59270 page = (char *)__get_free_page(GFP_TEMPORARY);
59271 if (!page)
59272 return -ENOMEM;
59273 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59274 goto free;
59275 while (count > 0) {
59276 size_t this_len, max_len;
59277 - int retval;
59278 + ssize_t retval;
59279
59280 if (src >= (mm->env_end - mm->env_start))
59281 break;
59282 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59283 int error = -EACCES;
59284
59285 /* Are we allowed to snoop on the tasks file descriptors? */
59286 - if (!proc_fd_access_allowed(inode))
59287 + if (!proc_fd_access_allowed(inode, 0))
59288 goto out;
59289
59290 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59291 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59292 struct path path;
59293
59294 /* Are we allowed to snoop on the tasks file descriptors? */
59295 - if (!proc_fd_access_allowed(inode))
59296 - goto out;
59297 + /* logging this is needed for learning on chromium to work properly,
59298 + but we don't want to flood the logs from 'ps' which does a readlink
59299 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59300 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59301 + */
59302 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59303 + if (!proc_fd_access_allowed(inode,0))
59304 + goto out;
59305 + } else {
59306 + if (!proc_fd_access_allowed(inode,1))
59307 + goto out;
59308 + }
59309
59310 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59311 if (error)
59312 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59313 rcu_read_lock();
59314 cred = __task_cred(task);
59315 inode->i_uid = cred->euid;
59316 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59317 + inode->i_gid = grsec_proc_gid;
59318 +#else
59319 inode->i_gid = cred->egid;
59320 +#endif
59321 rcu_read_unlock();
59322 }
59323 security_task_to_inode(task, inode);
59324 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59325 return -ENOENT;
59326 }
59327 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59328 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59329 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59330 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59331 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59332 +#endif
59333 task_dumpable(task)) {
59334 cred = __task_cred(task);
59335 stat->uid = cred->euid;
59336 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59337 + stat->gid = grsec_proc_gid;
59338 +#else
59339 stat->gid = cred->egid;
59340 +#endif
59341 }
59342 }
59343 rcu_read_unlock();
59344 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59345
59346 if (task) {
59347 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59348 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59349 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59350 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59351 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59352 +#endif
59353 task_dumpable(task)) {
59354 rcu_read_lock();
59355 cred = __task_cred(task);
59356 inode->i_uid = cred->euid;
59357 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59358 + inode->i_gid = grsec_proc_gid;
59359 +#else
59360 inode->i_gid = cred->egid;
59361 +#endif
59362 rcu_read_unlock();
59363 } else {
59364 inode->i_uid = GLOBAL_ROOT_UID;
59365 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59366 if (!task)
59367 goto out_no_task;
59368
59369 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59370 + goto out;
59371 +
59372 /*
59373 * Yes, it does not scale. And it should not. Don't add
59374 * new entries into /proc/<tgid>/ without very good reasons.
59375 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59376 if (!task)
59377 return -ENOENT;
59378
59379 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59380 + goto out;
59381 +
59382 if (!dir_emit_dots(file, ctx))
59383 goto out;
59384
59385 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59386 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59387 #endif
59388 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59389 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59390 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59391 INF("syscall", S_IRUGO, proc_pid_syscall),
59392 #endif
59393 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59394 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59395 #ifdef CONFIG_SECURITY
59396 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59397 #endif
59398 -#ifdef CONFIG_KALLSYMS
59399 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59400 INF("wchan", S_IRUGO, proc_pid_wchan),
59401 #endif
59402 -#ifdef CONFIG_STACKTRACE
59403 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59404 ONE("stack", S_IRUGO, proc_pid_stack),
59405 #endif
59406 #ifdef CONFIG_SCHEDSTATS
59407 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59408 #ifdef CONFIG_HARDWALL
59409 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59410 #endif
59411 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59412 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59413 +#endif
59414 #ifdef CONFIG_USER_NS
59415 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59416 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59417 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59418 if (!inode)
59419 goto out;
59420
59421 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59422 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59423 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59424 + inode->i_gid = grsec_proc_gid;
59425 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59426 +#else
59427 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59428 +#endif
59429 inode->i_op = &proc_tgid_base_inode_operations;
59430 inode->i_fop = &proc_tgid_base_operations;
59431 inode->i_flags|=S_IMMUTABLE;
59432 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59433 if (!task)
59434 goto out;
59435
59436 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59437 + goto out_put_task;
59438 +
59439 result = proc_pid_instantiate(dir, dentry, task, NULL);
59440 +out_put_task:
59441 put_task_struct(task);
59442 out:
59443 return ERR_PTR(result);
59444 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59445 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59446 #endif
59447 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59448 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59449 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59450 INF("syscall", S_IRUGO, proc_pid_syscall),
59451 #endif
59452 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59453 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59454 #ifdef CONFIG_SECURITY
59455 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59456 #endif
59457 -#ifdef CONFIG_KALLSYMS
59458 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59459 INF("wchan", S_IRUGO, proc_pid_wchan),
59460 #endif
59461 -#ifdef CONFIG_STACKTRACE
59462 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59463 ONE("stack", S_IRUGO, proc_pid_stack),
59464 #endif
59465 #ifdef CONFIG_SCHEDSTATS
59466 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59467 index 82676e3..5f8518a 100644
59468 --- a/fs/proc/cmdline.c
59469 +++ b/fs/proc/cmdline.c
59470 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59471
59472 static int __init proc_cmdline_init(void)
59473 {
59474 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59475 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59476 +#else
59477 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59478 +#endif
59479 return 0;
59480 }
59481 module_init(proc_cmdline_init);
59482 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59483 index b143471..bb105e5 100644
59484 --- a/fs/proc/devices.c
59485 +++ b/fs/proc/devices.c
59486 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59487
59488 static int __init proc_devices_init(void)
59489 {
59490 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59491 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59492 +#else
59493 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59494 +#endif
59495 return 0;
59496 }
59497 module_init(proc_devices_init);
59498 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59499 index 0ff80f9..a1d7500 100644
59500 --- a/fs/proc/fd.c
59501 +++ b/fs/proc/fd.c
59502 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59503 if (!task)
59504 return -ENOENT;
59505
59506 - files = get_files_struct(task);
59507 + if (!gr_acl_handle_procpidmem(task))
59508 + files = get_files_struct(task);
59509 put_task_struct(task);
59510
59511 if (files) {
59512 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59513 */
59514 int proc_fd_permission(struct inode *inode, int mask)
59515 {
59516 + struct task_struct *task;
59517 int rv = generic_permission(inode, mask);
59518 - if (rv == 0)
59519 - return 0;
59520 +
59521 if (task_pid(current) == proc_pid(inode))
59522 rv = 0;
59523 +
59524 + task = get_proc_task(inode);
59525 + if (task == NULL)
59526 + return rv;
59527 +
59528 + if (gr_acl_handle_procpidmem(task))
59529 + rv = -EACCES;
59530 +
59531 + put_task_struct(task);
59532 +
59533 return rv;
59534 }
59535
59536 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59537 index 073aea6..0630370 100644
59538 --- a/fs/proc/inode.c
59539 +++ b/fs/proc/inode.c
59540 @@ -23,11 +23,17 @@
59541 #include <linux/slab.h>
59542 #include <linux/mount.h>
59543 #include <linux/magic.h>
59544 +#include <linux/grsecurity.h>
59545
59546 #include <asm/uaccess.h>
59547
59548 #include "internal.h"
59549
59550 +#ifdef CONFIG_PROC_SYSCTL
59551 +extern const struct inode_operations proc_sys_inode_operations;
59552 +extern const struct inode_operations proc_sys_dir_operations;
59553 +#endif
59554 +
59555 static void proc_evict_inode(struct inode *inode)
59556 {
59557 struct proc_dir_entry *de;
59558 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59559 ns = PROC_I(inode)->ns.ns;
59560 if (ns_ops && ns)
59561 ns_ops->put(ns);
59562 +
59563 +#ifdef CONFIG_PROC_SYSCTL
59564 + if (inode->i_op == &proc_sys_inode_operations ||
59565 + inode->i_op == &proc_sys_dir_operations)
59566 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59567 +#endif
59568 +
59569 }
59570
59571 static struct kmem_cache * proc_inode_cachep;
59572 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59573 if (de->mode) {
59574 inode->i_mode = de->mode;
59575 inode->i_uid = de->uid;
59576 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59577 + inode->i_gid = grsec_proc_gid;
59578 +#else
59579 inode->i_gid = de->gid;
59580 +#endif
59581 }
59582 if (de->size)
59583 inode->i_size = de->size;
59584 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59585 index 651d09a..60c73ae 100644
59586 --- a/fs/proc/internal.h
59587 +++ b/fs/proc/internal.h
59588 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59589 struct pid *, struct task_struct *);
59590 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59591 struct pid *, struct task_struct *);
59592 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59593 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59594 +#endif
59595
59596 /*
59597 * base.c
59598 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59599 index 06ea155..9a798c7 100644
59600 --- a/fs/proc/kcore.c
59601 +++ b/fs/proc/kcore.c
59602 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59603 * the addresses in the elf_phdr on our list.
59604 */
59605 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59606 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59607 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59608 + if (tsz > buflen)
59609 tsz = buflen;
59610 -
59611 +
59612 while (buflen) {
59613 struct kcore_list *m;
59614
59615 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59616 kfree(elf_buf);
59617 } else {
59618 if (kern_addr_valid(start)) {
59619 - unsigned long n;
59620 + char *elf_buf;
59621 + mm_segment_t oldfs;
59622
59623 - n = copy_to_user(buffer, (char *)start, tsz);
59624 - /*
59625 - * We cannot distinguish between fault on source
59626 - * and fault on destination. When this happens
59627 - * we clear too and hope it will trigger the
59628 - * EFAULT again.
59629 - */
59630 - if (n) {
59631 - if (clear_user(buffer + tsz - n,
59632 - n))
59633 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59634 + if (!elf_buf)
59635 + return -ENOMEM;
59636 + oldfs = get_fs();
59637 + set_fs(KERNEL_DS);
59638 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59639 + set_fs(oldfs);
59640 + if (copy_to_user(buffer, elf_buf, tsz)) {
59641 + kfree(elf_buf);
59642 return -EFAULT;
59643 + }
59644 }
59645 + set_fs(oldfs);
59646 + kfree(elf_buf);
59647 } else {
59648 if (clear_user(buffer, tsz))
59649 return -EFAULT;
59650 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59651
59652 static int open_kcore(struct inode *inode, struct file *filp)
59653 {
59654 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59655 + return -EPERM;
59656 +#endif
59657 if (!capable(CAP_SYS_RAWIO))
59658 return -EPERM;
59659 if (kcore_need_update)
59660 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59661 index 5aa847a..f77c8d4 100644
59662 --- a/fs/proc/meminfo.c
59663 +++ b/fs/proc/meminfo.c
59664 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59665 vmi.used >> 10,
59666 vmi.largest_chunk >> 10
59667 #ifdef CONFIG_MEMORY_FAILURE
59668 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59669 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59670 #endif
59671 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59672 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59673 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59674 index ccfd99b..1b7e255 100644
59675 --- a/fs/proc/nommu.c
59676 +++ b/fs/proc/nommu.c
59677 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59678 if (len < 1)
59679 len = 1;
59680 seq_printf(m, "%*c", len, ' ');
59681 - seq_path(m, &file->f_path, "");
59682 + seq_path(m, &file->f_path, "\n\\");
59683 }
59684
59685 seq_putc(m, '\n');
59686 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59687 index 4677bb7..408e936 100644
59688 --- a/fs/proc/proc_net.c
59689 +++ b/fs/proc/proc_net.c
59690 @@ -23,6 +23,7 @@
59691 #include <linux/nsproxy.h>
59692 #include <net/net_namespace.h>
59693 #include <linux/seq_file.h>
59694 +#include <linux/grsecurity.h>
59695
59696 #include "internal.h"
59697
59698 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59699 struct task_struct *task;
59700 struct nsproxy *ns;
59701 struct net *net = NULL;
59702 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59703 + const struct cred *cred = current_cred();
59704 +#endif
59705 +
59706 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59707 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59708 + return net;
59709 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59710 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59711 + return net;
59712 +#endif
59713
59714 rcu_read_lock();
59715 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59716 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59717 index 7129046..f2779c6 100644
59718 --- a/fs/proc/proc_sysctl.c
59719 +++ b/fs/proc/proc_sysctl.c
59720 @@ -13,11 +13,15 @@
59721 #include <linux/module.h>
59722 #include "internal.h"
59723
59724 +extern int gr_handle_chroot_sysctl(const int op);
59725 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59726 + const int op);
59727 +
59728 static const struct dentry_operations proc_sys_dentry_operations;
59729 static const struct file_operations proc_sys_file_operations;
59730 -static const struct inode_operations proc_sys_inode_operations;
59731 +const struct inode_operations proc_sys_inode_operations;
59732 static const struct file_operations proc_sys_dir_file_operations;
59733 -static const struct inode_operations proc_sys_dir_operations;
59734 +const struct inode_operations proc_sys_dir_operations;
59735
59736 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59737 {
59738 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59739
59740 err = NULL;
59741 d_set_d_op(dentry, &proc_sys_dentry_operations);
59742 +
59743 + gr_handle_proc_create(dentry, inode);
59744 +
59745 d_add(dentry, inode);
59746
59747 out:
59748 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59749 struct inode *inode = file_inode(filp);
59750 struct ctl_table_header *head = grab_header(inode);
59751 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59752 + int op = write ? MAY_WRITE : MAY_READ;
59753 ssize_t error;
59754 size_t res;
59755
59756 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59757 * and won't be until we finish.
59758 */
59759 error = -EPERM;
59760 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59761 + if (sysctl_perm(head, table, op))
59762 goto out;
59763
59764 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59765 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59766 if (!table->proc_handler)
59767 goto out;
59768
59769 +#ifdef CONFIG_GRKERNSEC
59770 + error = -EPERM;
59771 + if (gr_handle_chroot_sysctl(op))
59772 + goto out;
59773 + dget(filp->f_path.dentry);
59774 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59775 + dput(filp->f_path.dentry);
59776 + goto out;
59777 + }
59778 + dput(filp->f_path.dentry);
59779 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59780 + goto out;
59781 + if (write && !capable(CAP_SYS_ADMIN))
59782 + goto out;
59783 +#endif
59784 +
59785 /* careful: calling conventions are nasty here */
59786 res = count;
59787 error = table->proc_handler(table, write, buf, &res, ppos);
59788 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59789 return false;
59790 } else {
59791 d_set_d_op(child, &proc_sys_dentry_operations);
59792 +
59793 + gr_handle_proc_create(child, inode);
59794 +
59795 d_add(child, inode);
59796 }
59797 } else {
59798 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59799 if ((*pos)++ < ctx->pos)
59800 return true;
59801
59802 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59803 + return 0;
59804 +
59805 if (unlikely(S_ISLNK(table->mode)))
59806 res = proc_sys_link_fill_cache(file, ctx, head, table);
59807 else
59808 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59809 if (IS_ERR(head))
59810 return PTR_ERR(head);
59811
59812 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59813 + return -ENOENT;
59814 +
59815 generic_fillattr(inode, stat);
59816 if (table)
59817 stat->mode = (stat->mode & S_IFMT) | table->mode;
59818 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59819 .llseek = generic_file_llseek,
59820 };
59821
59822 -static const struct inode_operations proc_sys_inode_operations = {
59823 +const struct inode_operations proc_sys_inode_operations = {
59824 .permission = proc_sys_permission,
59825 .setattr = proc_sys_setattr,
59826 .getattr = proc_sys_getattr,
59827 };
59828
59829 -static const struct inode_operations proc_sys_dir_operations = {
59830 +const struct inode_operations proc_sys_dir_operations = {
59831 .lookup = proc_sys_lookup,
59832 .permission = proc_sys_permission,
59833 .setattr = proc_sys_setattr,
59834 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59835 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59836 const char *name, int namelen)
59837 {
59838 - struct ctl_table *table;
59839 + ctl_table_no_const *table;
59840 struct ctl_dir *new;
59841 struct ctl_node *node;
59842 char *new_name;
59843 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59844 return NULL;
59845
59846 node = (struct ctl_node *)(new + 1);
59847 - table = (struct ctl_table *)(node + 1);
59848 + table = (ctl_table_no_const *)(node + 1);
59849 new_name = (char *)(table + 2);
59850 memcpy(new_name, name, namelen);
59851 new_name[namelen] = '\0';
59852 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59853 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59854 struct ctl_table_root *link_root)
59855 {
59856 - struct ctl_table *link_table, *entry, *link;
59857 + ctl_table_no_const *link_table, *link;
59858 + struct ctl_table *entry;
59859 struct ctl_table_header *links;
59860 struct ctl_node *node;
59861 char *link_name;
59862 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59863 return NULL;
59864
59865 node = (struct ctl_node *)(links + 1);
59866 - link_table = (struct ctl_table *)(node + nr_entries);
59867 + link_table = (ctl_table_no_const *)(node + nr_entries);
59868 link_name = (char *)&link_table[nr_entries + 1];
59869
59870 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59871 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59872 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59873 struct ctl_table *table)
59874 {
59875 - struct ctl_table *ctl_table_arg = NULL;
59876 - struct ctl_table *entry, *files;
59877 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59878 + struct ctl_table *entry;
59879 int nr_files = 0;
59880 int nr_dirs = 0;
59881 int err = -ENOMEM;
59882 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59883 nr_files++;
59884 }
59885
59886 - files = table;
59887 /* If there are mixed files and directories we need a new table */
59888 if (nr_dirs && nr_files) {
59889 - struct ctl_table *new;
59890 + ctl_table_no_const *new;
59891 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59892 GFP_KERNEL);
59893 if (!files)
59894 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59895 /* Register everything except a directory full of subdirectories */
59896 if (nr_files || !nr_dirs) {
59897 struct ctl_table_header *header;
59898 - header = __register_sysctl_table(set, path, files);
59899 + header = __register_sysctl_table(set, path, files ? files : table);
59900 if (!header) {
59901 kfree(ctl_table_arg);
59902 goto out;
59903 diff --git a/fs/proc/root.c b/fs/proc/root.c
59904 index 0e0e83c..005ba6a 100644
59905 --- a/fs/proc/root.c
59906 +++ b/fs/proc/root.c
59907 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59908 #ifdef CONFIG_PROC_DEVICETREE
59909 proc_device_tree_init();
59910 #endif
59911 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59912 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59913 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59914 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59915 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59916 +#endif
59917 +#else
59918 proc_mkdir("bus", NULL);
59919 +#endif
59920 proc_sys_init();
59921 }
59922
59923 diff --git a/fs/proc/self.c b/fs/proc/self.c
59924 index 6b6a993..807cccc 100644
59925 --- a/fs/proc/self.c
59926 +++ b/fs/proc/self.c
59927 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59928 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59929 void *cookie)
59930 {
59931 - char *s = nd_get_link(nd);
59932 + const char *s = nd_get_link(nd);
59933 if (!IS_ERR(s))
59934 kfree(s);
59935 }
59936 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59937 index 107d026..c715aeb 100644
59938 --- a/fs/proc/task_mmu.c
59939 +++ b/fs/proc/task_mmu.c
59940 @@ -12,12 +12,19 @@
59941 #include <linux/swap.h>
59942 #include <linux/swapops.h>
59943 #include <linux/mmu_notifier.h>
59944 +#include <linux/grsecurity.h>
59945
59946 #include <asm/elf.h>
59947 #include <asm/uaccess.h>
59948 #include <asm/tlbflush.h>
59949 #include "internal.h"
59950
59951 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59952 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59953 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59954 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59955 +#endif
59956 +
59957 void task_mem(struct seq_file *m, struct mm_struct *mm)
59958 {
59959 unsigned long data, text, lib, swap;
59960 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59961 "VmExe:\t%8lu kB\n"
59962 "VmLib:\t%8lu kB\n"
59963 "VmPTE:\t%8lu kB\n"
59964 - "VmSwap:\t%8lu kB\n",
59965 - hiwater_vm << (PAGE_SHIFT-10),
59966 + "VmSwap:\t%8lu kB\n"
59967 +
59968 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59969 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59970 +#endif
59971 +
59972 + ,hiwater_vm << (PAGE_SHIFT-10),
59973 total_vm << (PAGE_SHIFT-10),
59974 mm->locked_vm << (PAGE_SHIFT-10),
59975 mm->pinned_vm << (PAGE_SHIFT-10),
59976 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59977 data << (PAGE_SHIFT-10),
59978 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59979 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59980 - swap << (PAGE_SHIFT-10));
59981 + swap << (PAGE_SHIFT-10)
59982 +
59983 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59984 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59985 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
59986 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
59987 +#else
59988 + , mm->context.user_cs_base
59989 + , mm->context.user_cs_limit
59990 +#endif
59991 +#endif
59992 +
59993 + );
59994 }
59995
59996 unsigned long task_vsize(struct mm_struct *mm)
59997 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59998 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
59999 }
60000
60001 - /* We don't show the stack guard page in /proc/maps */
60002 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60003 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60004 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60005 +#else
60006 start = vma->vm_start;
60007 - if (stack_guard_page_start(vma, start))
60008 - start += PAGE_SIZE;
60009 end = vma->vm_end;
60010 - if (stack_guard_page_end(vma, end))
60011 - end -= PAGE_SIZE;
60012 +#endif
60013
60014 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60015 start,
60016 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60017 flags & VM_WRITE ? 'w' : '-',
60018 flags & VM_EXEC ? 'x' : '-',
60019 flags & VM_MAYSHARE ? 's' : 'p',
60020 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60021 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60022 +#else
60023 pgoff,
60024 +#endif
60025 MAJOR(dev), MINOR(dev), ino, &len);
60026
60027 /*
60028 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60029 */
60030 if (file) {
60031 pad_len_spaces(m, len);
60032 - seq_path(m, &file->f_path, "\n");
60033 + seq_path(m, &file->f_path, "\n\\");
60034 goto done;
60035 }
60036
60037 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60038 * Thread stack in /proc/PID/task/TID/maps or
60039 * the main process stack.
60040 */
60041 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60042 - vma->vm_end >= mm->start_stack)) {
60043 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60044 + (vma->vm_start <= mm->start_stack &&
60045 + vma->vm_end >= mm->start_stack)) {
60046 name = "[stack]";
60047 } else {
60048 /* Thread stack in /proc/PID/maps */
60049 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60050 struct proc_maps_private *priv = m->private;
60051 struct task_struct *task = priv->task;
60052
60053 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60054 + if (current->exec_id != m->exec_id) {
60055 + gr_log_badprocpid("maps");
60056 + return 0;
60057 + }
60058 +#endif
60059 +
60060 show_map_vma(m, vma, is_pid);
60061
60062 if (m->count < m->size) /* vma is copied successfully */
60063 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60064 .private = &mss,
60065 };
60066
60067 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60068 + if (current->exec_id != m->exec_id) {
60069 + gr_log_badprocpid("smaps");
60070 + return 0;
60071 + }
60072 +#endif
60073 memset(&mss, 0, sizeof mss);
60074 - mss.vma = vma;
60075 - /* mmap_sem is held in m_start */
60076 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60077 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60078 -
60079 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60080 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60081 +#endif
60082 + mss.vma = vma;
60083 + /* mmap_sem is held in m_start */
60084 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60085 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60086 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60087 + }
60088 +#endif
60089 show_map_vma(m, vma, is_pid);
60090
60091 seq_printf(m,
60092 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60093 "KernelPageSize: %8lu kB\n"
60094 "MMUPageSize: %8lu kB\n"
60095 "Locked: %8lu kB\n",
60096 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60097 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60098 +#else
60099 (vma->vm_end - vma->vm_start) >> 10,
60100 +#endif
60101 mss.resident >> 10,
60102 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60103 mss.shared_clean >> 10,
60104 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60105 int n;
60106 char buffer[50];
60107
60108 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60109 + if (current->exec_id != m->exec_id) {
60110 + gr_log_badprocpid("numa_maps");
60111 + return 0;
60112 + }
60113 +#endif
60114 +
60115 if (!mm)
60116 return 0;
60117
60118 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60119 mpol_to_str(buffer, sizeof(buffer), pol);
60120 mpol_cond_put(pol);
60121
60122 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60123 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60124 +#else
60125 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60126 +#endif
60127
60128 if (file) {
60129 seq_printf(m, " file=");
60130 - seq_path(m, &file->f_path, "\n\t= ");
60131 + seq_path(m, &file->f_path, "\n\t\\= ");
60132 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60133 seq_printf(m, " heap");
60134 } else {
60135 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60136 index 56123a6..5a2f6ec 100644
60137 --- a/fs/proc/task_nommu.c
60138 +++ b/fs/proc/task_nommu.c
60139 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60140 else
60141 bytes += kobjsize(mm);
60142
60143 - if (current->fs && current->fs->users > 1)
60144 + if (current->fs && atomic_read(&current->fs->users) > 1)
60145 sbytes += kobjsize(current->fs);
60146 else
60147 bytes += kobjsize(current->fs);
60148 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60149
60150 if (file) {
60151 pad_len_spaces(m, len);
60152 - seq_path(m, &file->f_path, "");
60153 + seq_path(m, &file->f_path, "\n\\");
60154 } else if (mm) {
60155 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60156
60157 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60158 index a1a16eb..6be46ed 100644
60159 --- a/fs/proc/vmcore.c
60160 +++ b/fs/proc/vmcore.c
60161 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60162 nr_bytes = count;
60163
60164 /* If pfn is not ram, return zeros for sparse dump files */
60165 - if (pfn_is_ram(pfn) == 0)
60166 - memset(buf, 0, nr_bytes);
60167 - else {
60168 + if (pfn_is_ram(pfn) == 0) {
60169 + if (userbuf) {
60170 + if (clear_user((char __force_user *)buf, nr_bytes))
60171 + return -EFAULT;
60172 + } else
60173 + memset(buf, 0, nr_bytes);
60174 + } else {
60175 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60176 offset, userbuf);
60177 if (tmp < 0)
60178 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60179 if (*fpos < m->offset + m->size) {
60180 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60181 start = m->paddr + *fpos - m->offset;
60182 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60183 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60184 if (tmp < 0)
60185 return tmp;
60186 buflen -= tsz;
60187 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60188 index b00fcc9..e0c6381 100644
60189 --- a/fs/qnx6/qnx6.h
60190 +++ b/fs/qnx6/qnx6.h
60191 @@ -74,7 +74,7 @@ enum {
60192 BYTESEX_BE,
60193 };
60194
60195 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60196 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60197 {
60198 if (sbi->s_bytesex == BYTESEX_LE)
60199 return le64_to_cpu((__force __le64)n);
60200 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60201 return (__force __fs64)cpu_to_be64(n);
60202 }
60203
60204 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60205 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60206 {
60207 if (sbi->s_bytesex == BYTESEX_LE)
60208 return le32_to_cpu((__force __le32)n);
60209 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60210 index 16e8abb..2dcf914 100644
60211 --- a/fs/quota/netlink.c
60212 +++ b/fs/quota/netlink.c
60213 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60214 void quota_send_warning(struct kqid qid, dev_t dev,
60215 const char warntype)
60216 {
60217 - static atomic_t seq;
60218 + static atomic_unchecked_t seq;
60219 struct sk_buff *skb;
60220 void *msg_head;
60221 int ret;
60222 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60223 "VFS: Not enough memory to send quota warning.\n");
60224 return;
60225 }
60226 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60227 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60228 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60229 if (!msg_head) {
60230 printk(KERN_ERR
60231 diff --git a/fs/read_write.c b/fs/read_write.c
60232 index 122a384..0b7ecf2 100644
60233 --- a/fs/read_write.c
60234 +++ b/fs/read_write.c
60235 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60236
60237 old_fs = get_fs();
60238 set_fs(get_ds());
60239 - p = (__force const char __user *)buf;
60240 + p = (const char __force_user *)buf;
60241 if (count > MAX_RW_COUNT)
60242 count = MAX_RW_COUNT;
60243 if (file->f_op->write)
60244 diff --git a/fs/readdir.c b/fs/readdir.c
60245 index 93d71e5..6a14be8 100644
60246 --- a/fs/readdir.c
60247 +++ b/fs/readdir.c
60248 @@ -17,6 +17,7 @@
60249 #include <linux/security.h>
60250 #include <linux/syscalls.h>
60251 #include <linux/unistd.h>
60252 +#include <linux/namei.h>
60253
60254 #include <asm/uaccess.h>
60255
60256 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60257 struct readdir_callback {
60258 struct dir_context ctx;
60259 struct old_linux_dirent __user * dirent;
60260 + struct file * file;
60261 int result;
60262 };
60263
60264 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60265 buf->result = -EOVERFLOW;
60266 return -EOVERFLOW;
60267 }
60268 +
60269 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60270 + return 0;
60271 +
60272 buf->result++;
60273 dirent = buf->dirent;
60274 if (!access_ok(VERIFY_WRITE, dirent,
60275 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60276 if (!f.file)
60277 return -EBADF;
60278
60279 + buf.file = f.file;
60280 error = iterate_dir(f.file, &buf.ctx);
60281 if (buf.result)
60282 error = buf.result;
60283 @@ -142,6 +149,7 @@ struct getdents_callback {
60284 struct dir_context ctx;
60285 struct linux_dirent __user * current_dir;
60286 struct linux_dirent __user * previous;
60287 + struct file * file;
60288 int count;
60289 int error;
60290 };
60291 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60292 buf->error = -EOVERFLOW;
60293 return -EOVERFLOW;
60294 }
60295 +
60296 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60297 + return 0;
60298 +
60299 dirent = buf->previous;
60300 if (dirent) {
60301 if (__put_user(offset, &dirent->d_off))
60302 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60303 if (!f.file)
60304 return -EBADF;
60305
60306 + buf.file = f.file;
60307 error = iterate_dir(f.file, &buf.ctx);
60308 if (error >= 0)
60309 error = buf.error;
60310 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60311 struct dir_context ctx;
60312 struct linux_dirent64 __user * current_dir;
60313 struct linux_dirent64 __user * previous;
60314 + struct file *file;
60315 int count;
60316 int error;
60317 };
60318 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60319 buf->error = -EINVAL; /* only used if we fail.. */
60320 if (reclen > buf->count)
60321 return -EINVAL;
60322 +
60323 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60324 + return 0;
60325 +
60326 dirent = buf->previous;
60327 if (dirent) {
60328 if (__put_user(offset, &dirent->d_off))
60329 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60330 if (!f.file)
60331 return -EBADF;
60332
60333 + buf.file = f.file;
60334 error = iterate_dir(f.file, &buf.ctx);
60335 if (error >= 0)
60336 error = buf.error;
60337 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60338 index 2b7882b..1c5ef48 100644
60339 --- a/fs/reiserfs/do_balan.c
60340 +++ b/fs/reiserfs/do_balan.c
60341 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60342 return;
60343 }
60344
60345 - atomic_inc(&(fs_generation(tb->tb_sb)));
60346 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60347 do_balance_starts(tb);
60348
60349 /* balance leaf returns 0 except if combining L R and S into
60350 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60351 index a958444..42b2323 100644
60352 --- a/fs/reiserfs/procfs.c
60353 +++ b/fs/reiserfs/procfs.c
60354 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60355 "SMALL_TAILS " : "NO_TAILS ",
60356 replay_only(sb) ? "REPLAY_ONLY " : "",
60357 convert_reiserfs(sb) ? "CONV " : "",
60358 - atomic_read(&r->s_generation_counter),
60359 + atomic_read_unchecked(&r->s_generation_counter),
60360 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60361 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60362 SF(s_good_search_by_key_reada), SF(s_bmaps),
60363 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60364 index 3df5ce6..8c0f4b0 100644
60365 --- a/fs/reiserfs/reiserfs.h
60366 +++ b/fs/reiserfs/reiserfs.h
60367 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60368 /* Comment? -Hans */
60369 wait_queue_head_t s_wait;
60370 /* To be obsoleted soon by per buffer seals.. -Hans */
60371 - atomic_t s_generation_counter; // increased by one every time the
60372 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60373 // tree gets re-balanced
60374 unsigned long s_properties; /* File system properties. Currently holds
60375 on-disk FS format */
60376 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60377 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60378
60379 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60380 -#define get_generation(s) atomic_read (&fs_generation(s))
60381 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60382 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60383 #define __fs_changed(gen,s) (gen != get_generation (s))
60384 #define fs_changed(gen,s) \
60385 diff --git a/fs/select.c b/fs/select.c
60386 index 35d4adc7..d6c60db 100644
60387 --- a/fs/select.c
60388 +++ b/fs/select.c
60389 @@ -20,6 +20,7 @@
60390 #include <linux/export.h>
60391 #include <linux/slab.h>
60392 #include <linux/poll.h>
60393 +#include <linux/security.h>
60394 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60395 #include <linux/file.h>
60396 #include <linux/fdtable.h>
60397 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60398 struct poll_list *walk = head;
60399 unsigned long todo = nfds;
60400
60401 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60402 if (nfds > rlimit(RLIMIT_NOFILE))
60403 return -EINVAL;
60404
60405 diff --git a/fs/seq_file.c b/fs/seq_file.c
60406 index 3135c25..d0395dd 100644
60407 --- a/fs/seq_file.c
60408 +++ b/fs/seq_file.c
60409 @@ -10,6 +10,7 @@
60410 #include <linux/seq_file.h>
60411 #include <linux/slab.h>
60412 #include <linux/cred.h>
60413 +#include <linux/sched.h>
60414
60415 #include <asm/uaccess.h>
60416 #include <asm/page.h>
60417 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60418 #ifdef CONFIG_USER_NS
60419 p->user_ns = file->f_cred->user_ns;
60420 #endif
60421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60422 + p->exec_id = current->exec_id;
60423 +#endif
60424
60425 /*
60426 * Wrappers around seq_open(e.g. swaps_open) need to be
60427 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60428 return 0;
60429 }
60430 if (!m->buf) {
60431 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60432 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60433 if (!m->buf)
60434 return -ENOMEM;
60435 }
60436 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60437 Eoverflow:
60438 m->op->stop(m, p);
60439 kfree(m->buf);
60440 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60441 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60442 return !m->buf ? -ENOMEM : -EAGAIN;
60443 }
60444
60445 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60446
60447 /* grab buffer if we didn't have one */
60448 if (!m->buf) {
60449 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60450 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60451 if (!m->buf)
60452 goto Enomem;
60453 }
60454 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60455 goto Fill;
60456 m->op->stop(m, p);
60457 kfree(m->buf);
60458 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60459 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60460 if (!m->buf)
60461 goto Enomem;
60462 m->count = 0;
60463 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60464 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60465 void *data)
60466 {
60467 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60468 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60469 int res = -ENOMEM;
60470
60471 if (op) {
60472 diff --git a/fs/splice.c b/fs/splice.c
60473 index 3b7ee65..87fc2e4 100644
60474 --- a/fs/splice.c
60475 +++ b/fs/splice.c
60476 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60477 pipe_lock(pipe);
60478
60479 for (;;) {
60480 - if (!pipe->readers) {
60481 + if (!atomic_read(&pipe->readers)) {
60482 send_sig(SIGPIPE, current, 0);
60483 if (!ret)
60484 ret = -EPIPE;
60485 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60486 page_nr++;
60487 ret += buf->len;
60488
60489 - if (pipe->files)
60490 + if (atomic_read(&pipe->files))
60491 do_wakeup = 1;
60492
60493 if (!--spd->nr_pages)
60494 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60495 do_wakeup = 0;
60496 }
60497
60498 - pipe->waiting_writers++;
60499 + atomic_inc(&pipe->waiting_writers);
60500 pipe_wait(pipe);
60501 - pipe->waiting_writers--;
60502 + atomic_dec(&pipe->waiting_writers);
60503 }
60504
60505 pipe_unlock(pipe);
60506 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60507 old_fs = get_fs();
60508 set_fs(get_ds());
60509 /* The cast to a user pointer is valid due to the set_fs() */
60510 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60511 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60512 set_fs(old_fs);
60513
60514 return res;
60515 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60516 old_fs = get_fs();
60517 set_fs(get_ds());
60518 /* The cast to a user pointer is valid due to the set_fs() */
60519 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60520 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60521 set_fs(old_fs);
60522
60523 return res;
60524 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60525 goto err;
60526
60527 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60528 - vec[i].iov_base = (void __user *) page_address(page);
60529 + vec[i].iov_base = (void __force_user *) page_address(page);
60530 vec[i].iov_len = this_len;
60531 spd.pages[i] = page;
60532 spd.nr_pages++;
60533 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60534 ops->release(pipe, buf);
60535 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60536 pipe->nrbufs--;
60537 - if (pipe->files)
60538 + if (atomic_read(&pipe->files))
60539 sd->need_wakeup = true;
60540 }
60541
60542 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60543 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60544 {
60545 while (!pipe->nrbufs) {
60546 - if (!pipe->writers)
60547 + if (!atomic_read(&pipe->writers))
60548 return 0;
60549
60550 - if (!pipe->waiting_writers && sd->num_spliced)
60551 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60552 return 0;
60553
60554 if (sd->flags & SPLICE_F_NONBLOCK)
60555 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60556 * out of the pipe right after the splice_to_pipe(). So set
60557 * PIPE_READERS appropriately.
60558 */
60559 - pipe->readers = 1;
60560 + atomic_set(&pipe->readers, 1);
60561
60562 current->splice_pipe = pipe;
60563 }
60564 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60565
60566 partial[buffers].offset = off;
60567 partial[buffers].len = plen;
60568 + partial[buffers].private = 0;
60569
60570 off = 0;
60571 len -= plen;
60572 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60573 ret = -ERESTARTSYS;
60574 break;
60575 }
60576 - if (!pipe->writers)
60577 + if (!atomic_read(&pipe->writers))
60578 break;
60579 - if (!pipe->waiting_writers) {
60580 + if (!atomic_read(&pipe->waiting_writers)) {
60581 if (flags & SPLICE_F_NONBLOCK) {
60582 ret = -EAGAIN;
60583 break;
60584 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60585 pipe_lock(pipe);
60586
60587 while (pipe->nrbufs >= pipe->buffers) {
60588 - if (!pipe->readers) {
60589 + if (!atomic_read(&pipe->readers)) {
60590 send_sig(SIGPIPE, current, 0);
60591 ret = -EPIPE;
60592 break;
60593 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60594 ret = -ERESTARTSYS;
60595 break;
60596 }
60597 - pipe->waiting_writers++;
60598 + atomic_inc(&pipe->waiting_writers);
60599 pipe_wait(pipe);
60600 - pipe->waiting_writers--;
60601 + atomic_dec(&pipe->waiting_writers);
60602 }
60603
60604 pipe_unlock(pipe);
60605 @@ -1862,14 +1863,14 @@ retry:
60606 pipe_double_lock(ipipe, opipe);
60607
60608 do {
60609 - if (!opipe->readers) {
60610 + if (!atomic_read(&opipe->readers)) {
60611 send_sig(SIGPIPE, current, 0);
60612 if (!ret)
60613 ret = -EPIPE;
60614 break;
60615 }
60616
60617 - if (!ipipe->nrbufs && !ipipe->writers)
60618 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60619 break;
60620
60621 /*
60622 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60623 pipe_double_lock(ipipe, opipe);
60624
60625 do {
60626 - if (!opipe->readers) {
60627 + if (!atomic_read(&opipe->readers)) {
60628 send_sig(SIGPIPE, current, 0);
60629 if (!ret)
60630 ret = -EPIPE;
60631 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60632 * return EAGAIN if we have the potential of some data in the
60633 * future, otherwise just return 0
60634 */
60635 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60636 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60637 ret = -EAGAIN;
60638
60639 pipe_unlock(ipipe);
60640 diff --git a/fs/stat.c b/fs/stat.c
60641 index 04ce1ac..a13dd1e 100644
60642 --- a/fs/stat.c
60643 +++ b/fs/stat.c
60644 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60645 stat->gid = inode->i_gid;
60646 stat->rdev = inode->i_rdev;
60647 stat->size = i_size_read(inode);
60648 - stat->atime = inode->i_atime;
60649 - stat->mtime = inode->i_mtime;
60650 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60651 + stat->atime = inode->i_ctime;
60652 + stat->mtime = inode->i_ctime;
60653 + } else {
60654 + stat->atime = inode->i_atime;
60655 + stat->mtime = inode->i_mtime;
60656 + }
60657 stat->ctime = inode->i_ctime;
60658 stat->blksize = (1 << inode->i_blkbits);
60659 stat->blocks = inode->i_blocks;
60660 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60661 if (retval)
60662 return retval;
60663
60664 - if (inode->i_op->getattr)
60665 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60666 + if (inode->i_op->getattr) {
60667 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60668 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60669 + stat->atime = stat->ctime;
60670 + stat->mtime = stat->ctime;
60671 + }
60672 + return retval;
60673 + }
60674
60675 generic_fillattr(inode, stat);
60676 return 0;
60677 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60678 index 15c68f9..36a8b3e 100644
60679 --- a/fs/sysfs/bin.c
60680 +++ b/fs/sysfs/bin.c
60681 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60682 return ret;
60683 }
60684
60685 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60686 - void *buf, int len, int write)
60687 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60688 + void *buf, size_t len, int write)
60689 {
60690 struct file *file = vma->vm_file;
60691 struct bin_buffer *bb = file->private_data;
60692 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60693 - int ret;
60694 + ssize_t ret;
60695
60696 if (!bb->vm_ops)
60697 return -EINVAL;
60698 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60699 index e068e74..92edeb8 100644
60700 --- a/fs/sysfs/dir.c
60701 +++ b/fs/sysfs/dir.c
60702 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60703 *
60704 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60705 */
60706 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60707 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60708 {
60709 unsigned long hash = init_name_hash();
60710 unsigned int len = strlen(name);
60711 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60712 struct sysfs_dirent *sd;
60713 int rc;
60714
60715 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60716 + const char *parent_name = parent_sd->s_name;
60717 +
60718 + mode = S_IFDIR | S_IRWXU;
60719 +
60720 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60721 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60722 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60723 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60724 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60725 +#endif
60726 +
60727 /* allocate */
60728 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60729 if (!sd)
60730 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60731 index d2bb7ed..fe8c331 100644
60732 --- a/fs/sysfs/file.c
60733 +++ b/fs/sysfs/file.c
60734 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60735
60736 struct sysfs_open_dirent {
60737 atomic_t refcnt;
60738 - atomic_t event;
60739 + atomic_unchecked_t event;
60740 wait_queue_head_t poll;
60741 struct list_head buffers; /* goes through sysfs_buffer.list */
60742 };
60743 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60744 if (!sysfs_get_active(attr_sd))
60745 return -ENODEV;
60746
60747 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60748 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60749 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60750
60751 sysfs_put_active(attr_sd);
60752 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60753 return -ENOMEM;
60754
60755 atomic_set(&new_od->refcnt, 0);
60756 - atomic_set(&new_od->event, 1);
60757 + atomic_set_unchecked(&new_od->event, 1);
60758 init_waitqueue_head(&new_od->poll);
60759 INIT_LIST_HEAD(&new_od->buffers);
60760 goto retry;
60761 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60762
60763 sysfs_put_active(attr_sd);
60764
60765 - if (buffer->event != atomic_read(&od->event))
60766 + if (buffer->event != atomic_read_unchecked(&od->event))
60767 goto trigger;
60768
60769 return DEFAULT_POLLMASK;
60770 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60771 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60772 od = sd->s_attr.open;
60773 if (od) {
60774 - atomic_inc(&od->event);
60775 + atomic_inc_unchecked(&od->event);
60776 wake_up_interruptible(&od->poll);
60777 }
60778 }
60779 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60780 index 8c940df..25b733e 100644
60781 --- a/fs/sysfs/symlink.c
60782 +++ b/fs/sysfs/symlink.c
60783 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60784
60785 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60786 {
60787 - char *page = nd_get_link(nd);
60788 + const char *page = nd_get_link(nd);
60789 if (!IS_ERR(page))
60790 free_page((unsigned long)page);
60791 }
60792 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60793 index 69d4889..a810bd4 100644
60794 --- a/fs/sysv/sysv.h
60795 +++ b/fs/sysv/sysv.h
60796 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60797 #endif
60798 }
60799
60800 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60801 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60802 {
60803 if (sbi->s_bytesex == BYTESEX_PDP)
60804 return PDP_swab((__force __u32)n);
60805 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60806 index e18b988..f1d4ad0f 100644
60807 --- a/fs/ubifs/io.c
60808 +++ b/fs/ubifs/io.c
60809 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60810 return err;
60811 }
60812
60813 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60814 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60815 {
60816 int err;
60817
60818 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60819 index c175b4d..8f36a16 100644
60820 --- a/fs/udf/misc.c
60821 +++ b/fs/udf/misc.c
60822 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60823
60824 u8 udf_tag_checksum(const struct tag *t)
60825 {
60826 - u8 *data = (u8 *)t;
60827 + const u8 *data = (const u8 *)t;
60828 u8 checksum = 0;
60829 int i;
60830 for (i = 0; i < sizeof(struct tag); ++i)
60831 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60832 index 8d974c4..b82f6ec 100644
60833 --- a/fs/ufs/swab.h
60834 +++ b/fs/ufs/swab.h
60835 @@ -22,7 +22,7 @@ enum {
60836 BYTESEX_BE
60837 };
60838
60839 -static inline u64
60840 +static inline u64 __intentional_overflow(-1)
60841 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60842 {
60843 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60844 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60845 return (__force __fs64)cpu_to_be64(n);
60846 }
60847
60848 -static inline u32
60849 +static inline u32 __intentional_overflow(-1)
60850 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60851 {
60852 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60853 diff --git a/fs/utimes.c b/fs/utimes.c
60854 index f4fb7ec..3fe03c0 100644
60855 --- a/fs/utimes.c
60856 +++ b/fs/utimes.c
60857 @@ -1,6 +1,7 @@
60858 #include <linux/compiler.h>
60859 #include <linux/file.h>
60860 #include <linux/fs.h>
60861 +#include <linux/security.h>
60862 #include <linux/linkage.h>
60863 #include <linux/mount.h>
60864 #include <linux/namei.h>
60865 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60866 goto mnt_drop_write_and_out;
60867 }
60868 }
60869 +
60870 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60871 + error = -EACCES;
60872 + goto mnt_drop_write_and_out;
60873 + }
60874 +
60875 mutex_lock(&inode->i_mutex);
60876 error = notify_change(path->dentry, &newattrs);
60877 mutex_unlock(&inode->i_mutex);
60878 diff --git a/fs/xattr.c b/fs/xattr.c
60879 index 3377dff..4d074d9 100644
60880 --- a/fs/xattr.c
60881 +++ b/fs/xattr.c
60882 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60883 return rc;
60884 }
60885
60886 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60887 +ssize_t
60888 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60889 +{
60890 + struct inode *inode = dentry->d_inode;
60891 + ssize_t error;
60892 +
60893 + error = inode_permission(inode, MAY_EXEC);
60894 + if (error)
60895 + return error;
60896 +
60897 + if (inode->i_op->getxattr)
60898 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60899 + else
60900 + error = -EOPNOTSUPP;
60901 +
60902 + return error;
60903 +}
60904 +EXPORT_SYMBOL(pax_getxattr);
60905 +#endif
60906 +
60907 ssize_t
60908 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60909 {
60910 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60911 * Extended attribute SET operations
60912 */
60913 static long
60914 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60915 +setxattr(struct path *path, const char __user *name, const void __user *value,
60916 size_t size, int flags)
60917 {
60918 int error;
60919 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60920 posix_acl_fix_xattr_from_user(kvalue, size);
60921 }
60922
60923 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60924 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60925 + error = -EACCES;
60926 + goto out;
60927 + }
60928 +
60929 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60930 out:
60931 if (vvalue)
60932 vfree(vvalue);
60933 @@ -377,7 +403,7 @@ retry:
60934 return error;
60935 error = mnt_want_write(path.mnt);
60936 if (!error) {
60937 - error = setxattr(path.dentry, name, value, size, flags);
60938 + error = setxattr(&path, name, value, size, flags);
60939 mnt_drop_write(path.mnt);
60940 }
60941 path_put(&path);
60942 @@ -401,7 +427,7 @@ retry:
60943 return error;
60944 error = mnt_want_write(path.mnt);
60945 if (!error) {
60946 - error = setxattr(path.dentry, name, value, size, flags);
60947 + error = setxattr(&path, name, value, size, flags);
60948 mnt_drop_write(path.mnt);
60949 }
60950 path_put(&path);
60951 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60952 const void __user *,value, size_t, size, int, flags)
60953 {
60954 struct fd f = fdget(fd);
60955 - struct dentry *dentry;
60956 int error = -EBADF;
60957
60958 if (!f.file)
60959 return error;
60960 - dentry = f.file->f_path.dentry;
60961 - audit_inode(NULL, dentry, 0);
60962 + audit_inode(NULL, f.file->f_path.dentry, 0);
60963 error = mnt_want_write_file(f.file);
60964 if (!error) {
60965 - error = setxattr(dentry, name, value, size, flags);
60966 + error = setxattr(&f.file->f_path, name, value, size, flags);
60967 mnt_drop_write_file(f.file);
60968 }
60969 fdput(f);
60970 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60971 index 9fbea87..6b19972 100644
60972 --- a/fs/xattr_acl.c
60973 +++ b/fs/xattr_acl.c
60974 @@ -76,8 +76,8 @@ struct posix_acl *
60975 posix_acl_from_xattr(struct user_namespace *user_ns,
60976 const void *value, size_t size)
60977 {
60978 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60979 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60980 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60981 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60982 int count;
60983 struct posix_acl *acl;
60984 struct posix_acl_entry *acl_e;
60985 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
60986 index 05c698c..6b918af 100644
60987 --- a/fs/xfs/xfs_bmap.c
60988 +++ b/fs/xfs/xfs_bmap.c
60989 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
60990
60991 #else
60992 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
60993 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
60994 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
60995 #endif /* DEBUG */
60996
60997 /*
60998 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
60999 index 97676a3..399a75d 100644
61000 --- a/fs/xfs/xfs_dir2_sf.c
61001 +++ b/fs/xfs/xfs_dir2_sf.c
61002 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61003
61004 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61005 ctx->pos = off & 0x7fffffff;
61006 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61007 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61008 + char name[sfep->namelen];
61009 + memcpy(name, sfep->name, sfep->namelen);
61010 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61011 + return 0;
61012 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61013 ino, DT_UNKNOWN))
61014 return 0;
61015 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61016 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61017 index 6e2bca5..6ce80d3 100644
61018 --- a/fs/xfs/xfs_ioctl.c
61019 +++ b/fs/xfs/xfs_ioctl.c
61020 @@ -127,7 +127,7 @@ xfs_find_handle(
61021 }
61022
61023 error = -EFAULT;
61024 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61025 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61026 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61027 goto out_put;
61028
61029 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61030 index 96dda62..d6c6a52 100644
61031 --- a/fs/xfs/xfs_iops.c
61032 +++ b/fs/xfs/xfs_iops.c
61033 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61034 struct nameidata *nd,
61035 void *p)
61036 {
61037 - char *s = nd_get_link(nd);
61038 + const char *s = nd_get_link(nd);
61039
61040 if (!IS_ERR(s))
61041 kfree(s);
61042 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61043 new file mode 100644
61044 index 0000000..0fd7c82
61045 --- /dev/null
61046 +++ b/grsecurity/Kconfig
61047 @@ -0,0 +1,1080 @@
61048 +#
61049 +# grecurity configuration
61050 +#
61051 +menu "Memory Protections"
61052 +depends on GRKERNSEC
61053 +
61054 +config GRKERNSEC_KMEM
61055 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61056 + default y if GRKERNSEC_CONFIG_AUTO
61057 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61058 + help
61059 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61060 + be written to or read from to modify or leak the contents of the running
61061 + kernel. /dev/port will also not be allowed to be opened and support
61062 + for /dev/cpu/*/msr will be removed. If you have module
61063 + support disabled, enabling this will close up five ways that are
61064 + currently used to insert malicious code into the running kernel.
61065 +
61066 + Even with all these features enabled, we still highly recommend that
61067 + you use the RBAC system, as it is still possible for an attacker to
61068 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61069 +
61070 + If you are not using XFree86, you may be able to stop this additional
61071 + case by enabling the 'Disable privileged I/O' option. Though nothing
61072 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61073 + but only to video memory, which is the only writing we allow in this
61074 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61075 + not be allowed to mprotect it with PROT_WRITE later.
61076 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61077 + from working.
61078 +
61079 + It is highly recommended that you say Y here if you meet all the
61080 + conditions above.
61081 +
61082 +config GRKERNSEC_VM86
61083 + bool "Restrict VM86 mode"
61084 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61085 + depends on X86_32
61086 +
61087 + help
61088 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61089 + make use of a special execution mode on 32bit x86 processors called
61090 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61091 + video cards and will still work with this option enabled. The purpose
61092 + of the option is to prevent exploitation of emulation errors in
61093 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61094 + Nearly all users should be able to enable this option.
61095 +
61096 +config GRKERNSEC_IO
61097 + bool "Disable privileged I/O"
61098 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61099 + depends on X86
61100 + select RTC_CLASS
61101 + select RTC_INTF_DEV
61102 + select RTC_DRV_CMOS
61103 +
61104 + help
61105 + If you say Y here, all ioperm and iopl calls will return an error.
61106 + Ioperm and iopl can be used to modify the running kernel.
61107 + Unfortunately, some programs need this access to operate properly,
61108 + the most notable of which are XFree86 and hwclock. hwclock can be
61109 + remedied by having RTC support in the kernel, so real-time
61110 + clock support is enabled if this option is enabled, to ensure
61111 + that hwclock operates correctly. XFree86 still will not
61112 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61113 + IF YOU USE XFree86. If you use XFree86 and you still want to
61114 + protect your kernel against modification, use the RBAC system.
61115 +
61116 +config GRKERNSEC_JIT_HARDEN
61117 + bool "Harden BPF JIT against spray attacks"
61118 + default y if GRKERNSEC_CONFIG_AUTO
61119 + depends on BPF_JIT
61120 + help
61121 + If you say Y here, the native code generated by the kernel's Berkeley
61122 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61123 + attacks that attempt to fit attacker-beneficial instructions in
61124 + 32bit immediate fields of JIT-generated native instructions. The
61125 + attacker will generally aim to cause an unintended instruction sequence
61126 + of JIT-generated native code to execute by jumping into the middle of
61127 + a generated instruction. This feature effectively randomizes the 32bit
61128 + immediate constants present in the generated code to thwart such attacks.
61129 +
61130 + If you're using KERNEXEC, it's recommended that you enable this option
61131 + to supplement the hardening of the kernel.
61132 +
61133 +config GRKERNSEC_PERF_HARDEN
61134 + bool "Disable unprivileged PERF_EVENTS usage by default"
61135 + default y if GRKERNSEC_CONFIG_AUTO
61136 + depends on PERF_EVENTS
61137 + help
61138 + If you say Y here, the range of acceptable values for the
61139 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61140 + default to a new value: 3. When the sysctl is set to this value, no
61141 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61142 +
61143 + Though PERF_EVENTS can be used legitimately for performance monitoring
61144 + and low-level application profiling, it is forced on regardless of
61145 + configuration, has been at fault for several vulnerabilities, and
61146 + creates new opportunities for side channels and other information leaks.
61147 +
61148 + This feature puts PERF_EVENTS into a secure default state and permits
61149 + the administrator to change out of it temporarily if unprivileged
61150 + application profiling is needed.
61151 +
61152 +config GRKERNSEC_RAND_THREADSTACK
61153 + bool "Insert random gaps between thread stacks"
61154 + default y if GRKERNSEC_CONFIG_AUTO
61155 + depends on PAX_RANDMMAP && !PPC
61156 + help
61157 + If you say Y here, a random-sized gap will be enforced between allocated
61158 + thread stacks. Glibc's NPTL and other threading libraries that
61159 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61160 + The implementation currently provides 8 bits of entropy for the gap.
61161 +
61162 + Many distributions do not compile threaded remote services with the
61163 + -fstack-check argument to GCC, causing the variable-sized stack-based
61164 + allocator, alloca(), to not probe the stack on allocation. This
61165 + permits an unbounded alloca() to skip over any guard page and potentially
61166 + modify another thread's stack reliably. An enforced random gap
61167 + reduces the reliability of such an attack and increases the chance
61168 + that such a read/write to another thread's stack instead lands in
61169 + an unmapped area, causing a crash and triggering grsecurity's
61170 + anti-bruteforcing logic.
61171 +
61172 +config GRKERNSEC_PROC_MEMMAP
61173 + bool "Harden ASLR against information leaks and entropy reduction"
61174 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61175 + depends on PAX_NOEXEC || PAX_ASLR
61176 + help
61177 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61178 + give no information about the addresses of its mappings if
61179 + PaX features that rely on random addresses are enabled on the task.
61180 + In addition to sanitizing this information and disabling other
61181 + dangerous sources of information, this option causes reads of sensitive
61182 + /proc/<pid> entries where the file descriptor was opened in a different
61183 + task than the one performing the read. Such attempts are logged.
61184 + This option also limits argv/env strings for suid/sgid binaries
61185 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61186 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61187 + binaries to prevent alternative mmap layouts from being abused.
61188 +
61189 + If you use PaX it is essential that you say Y here as it closes up
61190 + several holes that make full ASLR useless locally.
61191 +
61192 +config GRKERNSEC_BRUTE
61193 + bool "Deter exploit bruteforcing"
61194 + default y if GRKERNSEC_CONFIG_AUTO
61195 + help
61196 + If you say Y here, attempts to bruteforce exploits against forking
61197 + daemons such as apache or sshd, as well as against suid/sgid binaries
61198 + will be deterred. When a child of a forking daemon is killed by PaX
61199 + or crashes due to an illegal instruction or other suspicious signal,
61200 + the parent process will be delayed 30 seconds upon every subsequent
61201 + fork until the administrator is able to assess the situation and
61202 + restart the daemon.
61203 + In the suid/sgid case, the attempt is logged, the user has all their
61204 + existing instances of the suid/sgid binary terminated and will
61205 + be unable to execute any suid/sgid binaries for 15 minutes.
61206 +
61207 + It is recommended that you also enable signal logging in the auditing
61208 + section so that logs are generated when a process triggers a suspicious
61209 + signal.
61210 + If the sysctl option is enabled, a sysctl option with name
61211 + "deter_bruteforce" is created.
61212 +
61213 +
61214 +config GRKERNSEC_MODHARDEN
61215 + bool "Harden module auto-loading"
61216 + default y if GRKERNSEC_CONFIG_AUTO
61217 + depends on MODULES
61218 + help
61219 + If you say Y here, module auto-loading in response to use of some
61220 + feature implemented by an unloaded module will be restricted to
61221 + root users. Enabling this option helps defend against attacks
61222 + by unprivileged users who abuse the auto-loading behavior to
61223 + cause a vulnerable module to load that is then exploited.
61224 +
61225 + If this option prevents a legitimate use of auto-loading for a
61226 + non-root user, the administrator can execute modprobe manually
61227 + with the exact name of the module mentioned in the alert log.
61228 + Alternatively, the administrator can add the module to the list
61229 + of modules loaded at boot by modifying init scripts.
61230 +
61231 + Modification of init scripts will most likely be needed on
61232 + Ubuntu servers with encrypted home directory support enabled,
61233 + as the first non-root user logging in will cause the ecb(aes),
61234 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61235 +
61236 +config GRKERNSEC_HIDESYM
61237 + bool "Hide kernel symbols"
61238 + default y if GRKERNSEC_CONFIG_AUTO
61239 + select PAX_USERCOPY_SLABS
61240 + help
61241 + If you say Y here, getting information on loaded modules, and
61242 + displaying all kernel symbols through a syscall will be restricted
61243 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61244 + /proc/kallsyms will be restricted to the root user. The RBAC
61245 + system can hide that entry even from root.
61246 +
61247 + This option also prevents leaking of kernel addresses through
61248 + several /proc entries.
61249 +
61250 + Note that this option is only effective provided the following
61251 + conditions are met:
61252 + 1) The kernel using grsecurity is not precompiled by some distribution
61253 + 2) You have also enabled GRKERNSEC_DMESG
61254 + 3) You are using the RBAC system and hiding other files such as your
61255 + kernel image and System.map. Alternatively, enabling this option
61256 + causes the permissions on /boot, /lib/modules, and the kernel
61257 + source directory to change at compile time to prevent
61258 + reading by non-root users.
61259 + If the above conditions are met, this option will aid in providing a
61260 + useful protection against local kernel exploitation of overflows
61261 + and arbitrary read/write vulnerabilities.
61262 +
61263 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61264 + in addition to this feature.
61265 +
61266 +config GRKERNSEC_KERN_LOCKOUT
61267 + bool "Active kernel exploit response"
61268 + default y if GRKERNSEC_CONFIG_AUTO
61269 + depends on X86 || ARM || PPC || SPARC
61270 + help
61271 + If you say Y here, when a PaX alert is triggered due to suspicious
61272 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61273 + or an OOPS occurs due to bad memory accesses, instead of just
61274 + terminating the offending process (and potentially allowing
61275 + a subsequent exploit from the same user), we will take one of two
61276 + actions:
61277 + If the user was root, we will panic the system
61278 + If the user was non-root, we will log the attempt, terminate
61279 + all processes owned by the user, then prevent them from creating
61280 + any new processes until the system is restarted
61281 + This deters repeated kernel exploitation/bruteforcing attempts
61282 + and is useful for later forensics.
61283 +
61284 +endmenu
61285 +menu "Role Based Access Control Options"
61286 +depends on GRKERNSEC
61287 +
61288 +config GRKERNSEC_RBAC_DEBUG
61289 + bool
61290 +
61291 +config GRKERNSEC_NO_RBAC
61292 + bool "Disable RBAC system"
61293 + help
61294 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61295 + preventing the RBAC system from being enabled. You should only say Y
61296 + here if you have no intention of using the RBAC system, so as to prevent
61297 + an attacker with root access from misusing the RBAC system to hide files
61298 + and processes when loadable module support and /dev/[k]mem have been
61299 + locked down.
61300 +
61301 +config GRKERNSEC_ACL_HIDEKERN
61302 + bool "Hide kernel processes"
61303 + help
61304 + If you say Y here, all kernel threads will be hidden to all
61305 + processes but those whose subject has the "view hidden processes"
61306 + flag.
61307 +
61308 +config GRKERNSEC_ACL_MAXTRIES
61309 + int "Maximum tries before password lockout"
61310 + default 3
61311 + help
61312 + This option enforces the maximum number of times a user can attempt
61313 + to authorize themselves with the grsecurity RBAC system before being
61314 + denied the ability to attempt authorization again for a specified time.
61315 + The lower the number, the harder it will be to brute-force a password.
61316 +
61317 +config GRKERNSEC_ACL_TIMEOUT
61318 + int "Time to wait after max password tries, in seconds"
61319 + default 30
61320 + help
61321 + This option specifies the time the user must wait after attempting to
61322 + authorize to the RBAC system with the maximum number of invalid
61323 + passwords. The higher the number, the harder it will be to brute-force
61324 + a password.
61325 +
61326 +endmenu
61327 +menu "Filesystem Protections"
61328 +depends on GRKERNSEC
61329 +
61330 +config GRKERNSEC_PROC
61331 + bool "Proc restrictions"
61332 + default y if GRKERNSEC_CONFIG_AUTO
61333 + help
61334 + If you say Y here, the permissions of the /proc filesystem
61335 + will be altered to enhance system security and privacy. You MUST
61336 + choose either a user only restriction or a user and group restriction.
61337 + Depending upon the option you choose, you can either restrict users to
61338 + see only the processes they themselves run, or choose a group that can
61339 + view all processes and files normally restricted to root if you choose
61340 + the "restrict to user only" option. NOTE: If you're running identd or
61341 + ntpd as a non-root user, you will have to run it as the group you
61342 + specify here.
61343 +
61344 +config GRKERNSEC_PROC_USER
61345 + bool "Restrict /proc to user only"
61346 + depends on GRKERNSEC_PROC
61347 + help
61348 + If you say Y here, non-root users will only be able to view their own
61349 + processes, and restricts them from viewing network-related information,
61350 + and viewing kernel symbol and module information.
61351 +
61352 +config GRKERNSEC_PROC_USERGROUP
61353 + bool "Allow special group"
61354 + default y if GRKERNSEC_CONFIG_AUTO
61355 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61356 + help
61357 + If you say Y here, you will be able to select a group that will be
61358 + able to view all processes and network-related information. If you've
61359 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61360 + remain hidden. This option is useful if you want to run identd as
61361 + a non-root user. The group you select may also be chosen at boot time
61362 + via "grsec_proc_gid=" on the kernel commandline.
61363 +
61364 +config GRKERNSEC_PROC_GID
61365 + int "GID for special group"
61366 + depends on GRKERNSEC_PROC_USERGROUP
61367 + default 1001
61368 +
61369 +config GRKERNSEC_PROC_ADD
61370 + bool "Additional restrictions"
61371 + default y if GRKERNSEC_CONFIG_AUTO
61372 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61373 + help
61374 + If you say Y here, additional restrictions will be placed on
61375 + /proc that keep normal users from viewing device information and
61376 + slabinfo information that could be useful for exploits.
61377 +
61378 +config GRKERNSEC_LINK
61379 + bool "Linking restrictions"
61380 + default y if GRKERNSEC_CONFIG_AUTO
61381 + help
61382 + If you say Y here, /tmp race exploits will be prevented, since users
61383 + will no longer be able to follow symlinks owned by other users in
61384 + world-writable +t directories (e.g. /tmp), unless the owner of the
61385 + symlink is the owner of the directory. users will also not be
61386 + able to hardlink to files they do not own. If the sysctl option is
61387 + enabled, a sysctl option with name "linking_restrictions" is created.
61388 +
61389 +config GRKERNSEC_SYMLINKOWN
61390 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61391 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61392 + help
61393 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61394 + that prevents it from being used as a security feature. As Apache
61395 + verifies the symlink by performing a stat() against the target of
61396 + the symlink before it is followed, an attacker can setup a symlink
61397 + to point to a same-owned file, then replace the symlink with one
61398 + that targets another user's file just after Apache "validates" the
61399 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61400 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61401 + will be in place for the group you specify. If the sysctl option
61402 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61403 + created.
61404 +
61405 +config GRKERNSEC_SYMLINKOWN_GID
61406 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61407 + depends on GRKERNSEC_SYMLINKOWN
61408 + default 1006
61409 + help
61410 + Setting this GID determines what group kernel-enforced
61411 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61412 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61413 +
61414 +config GRKERNSEC_FIFO
61415 + bool "FIFO restrictions"
61416 + default y if GRKERNSEC_CONFIG_AUTO
61417 + help
61418 + If you say Y here, users will not be able to write to FIFOs they don't
61419 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61420 + the FIFO is the same owner of the directory it's held in. If the sysctl
61421 + option is enabled, a sysctl option with name "fifo_restrictions" is
61422 + created.
61423 +
61424 +config GRKERNSEC_SYSFS_RESTRICT
61425 + bool "Sysfs/debugfs restriction"
61426 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61427 + depends on SYSFS
61428 + help
61429 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61430 + any filesystem normally mounted under it (e.g. debugfs) will be
61431 + mostly accessible only by root. These filesystems generally provide access
61432 + to hardware and debug information that isn't appropriate for unprivileged
61433 + users of the system. Sysfs and debugfs have also become a large source
61434 + of new vulnerabilities, ranging from infoleaks to local compromise.
61435 + There has been very little oversight with an eye toward security involved
61436 + in adding new exporters of information to these filesystems, so their
61437 + use is discouraged.
61438 + For reasons of compatibility, a few directories have been whitelisted
61439 + for access by non-root users:
61440 + /sys/fs/selinux
61441 + /sys/fs/fuse
61442 + /sys/devices/system/cpu
61443 +
61444 +config GRKERNSEC_ROFS
61445 + bool "Runtime read-only mount protection"
61446 + depends on SYSCTL
61447 + help
61448 + If you say Y here, a sysctl option with name "romount_protect" will
61449 + be created. By setting this option to 1 at runtime, filesystems
61450 + will be protected in the following ways:
61451 + * No new writable mounts will be allowed
61452 + * Existing read-only mounts won't be able to be remounted read/write
61453 + * Write operations will be denied on all block devices
61454 + This option acts independently of grsec_lock: once it is set to 1,
61455 + it cannot be turned off. Therefore, please be mindful of the resulting
61456 + behavior if this option is enabled in an init script on a read-only
61457 + filesystem. This feature is mainly intended for secure embedded systems.
61458 +
61459 +config GRKERNSEC_DEVICE_SIDECHANNEL
61460 + bool "Eliminate stat/notify-based device sidechannels"
61461 + default y if GRKERNSEC_CONFIG_AUTO
61462 + help
61463 + If you say Y here, timing analyses on block or character
61464 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61465 + will be thwarted for unprivileged users. If a process without
61466 + CAP_MKNOD stats such a device, the last access and last modify times
61467 + will match the device's create time. No access or modify events
61468 + will be triggered through inotify/dnotify/fanotify for such devices.
61469 + This feature will prevent attacks that may at a minimum
61470 + allow an attacker to determine the administrator's password length.
61471 +
61472 +config GRKERNSEC_CHROOT
61473 + bool "Chroot jail restrictions"
61474 + default y if GRKERNSEC_CONFIG_AUTO
61475 + help
61476 + If you say Y here, you will be able to choose several options that will
61477 + make breaking out of a chrooted jail much more difficult. If you
61478 + encounter no software incompatibilities with the following options, it
61479 + is recommended that you enable each one.
61480 +
61481 +config GRKERNSEC_CHROOT_MOUNT
61482 + bool "Deny mounts"
61483 + default y if GRKERNSEC_CONFIG_AUTO
61484 + depends on GRKERNSEC_CHROOT
61485 + help
61486 + If you say Y here, processes inside a chroot will not be able to
61487 + mount or remount filesystems. If the sysctl option is enabled, a
61488 + sysctl option with name "chroot_deny_mount" is created.
61489 +
61490 +config GRKERNSEC_CHROOT_DOUBLE
61491 + bool "Deny double-chroots"
61492 + default y if GRKERNSEC_CONFIG_AUTO
61493 + depends on GRKERNSEC_CHROOT
61494 + help
61495 + If you say Y here, processes inside a chroot will not be able to chroot
61496 + again outside the chroot. This is a widely used method of breaking
61497 + out of a chroot jail and should not be allowed. If the sysctl
61498 + option is enabled, a sysctl option with name
61499 + "chroot_deny_chroot" is created.
61500 +
61501 +config GRKERNSEC_CHROOT_PIVOT
61502 + bool "Deny pivot_root in chroot"
61503 + default y if GRKERNSEC_CONFIG_AUTO
61504 + depends on GRKERNSEC_CHROOT
61505 + help
61506 + If you say Y here, processes inside a chroot will not be able to use
61507 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61508 + works similar to chroot in that it changes the root filesystem. This
61509 + function could be misused in a chrooted process to attempt to break out
61510 + of the chroot, and therefore should not be allowed. If the sysctl
61511 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61512 + created.
61513 +
61514 +config GRKERNSEC_CHROOT_CHDIR
61515 + bool "Enforce chdir(\"/\") on all chroots"
61516 + default y if GRKERNSEC_CONFIG_AUTO
61517 + depends on GRKERNSEC_CHROOT
61518 + help
61519 + If you say Y here, the current working directory of all newly-chrooted
61520 + applications will be set to the the root directory of the chroot.
61521 + The man page on chroot(2) states:
61522 + Note that this call does not change the current working
61523 + directory, so that `.' can be outside the tree rooted at
61524 + `/'. In particular, the super-user can escape from a
61525 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61526 +
61527 + It is recommended that you say Y here, since it's not known to break
61528 + any software. If the sysctl option is enabled, a sysctl option with
61529 + name "chroot_enforce_chdir" is created.
61530 +
61531 +config GRKERNSEC_CHROOT_CHMOD
61532 + bool "Deny (f)chmod +s"
61533 + default y if GRKERNSEC_CONFIG_AUTO
61534 + depends on GRKERNSEC_CHROOT
61535 + help
61536 + If you say Y here, processes inside a chroot will not be able to chmod
61537 + or fchmod files to make them have suid or sgid bits. This protects
61538 + against another published method of breaking a chroot. If the sysctl
61539 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61540 + created.
61541 +
61542 +config GRKERNSEC_CHROOT_FCHDIR
61543 + bool "Deny fchdir out of chroot"
61544 + default y if GRKERNSEC_CONFIG_AUTO
61545 + depends on GRKERNSEC_CHROOT
61546 + help
61547 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61548 + to a file descriptor of the chrooting process that points to a directory
61549 + outside the filesystem will be stopped. If the sysctl option
61550 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61551 +
61552 +config GRKERNSEC_CHROOT_MKNOD
61553 + bool "Deny mknod"
61554 + default y if GRKERNSEC_CONFIG_AUTO
61555 + depends on GRKERNSEC_CHROOT
61556 + help
61557 + If you say Y here, processes inside a chroot will not be allowed to
61558 + mknod. The problem with using mknod inside a chroot is that it
61559 + would allow an attacker to create a device entry that is the same
61560 + as one on the physical root of your system, which could range from
61561 + anything from the console device to a device for your harddrive (which
61562 + they could then use to wipe the drive or steal data). It is recommended
61563 + that you say Y here, unless you run into software incompatibilities.
61564 + If the sysctl option is enabled, a sysctl option with name
61565 + "chroot_deny_mknod" is created.
61566 +
61567 +config GRKERNSEC_CHROOT_SHMAT
61568 + bool "Deny shmat() out of chroot"
61569 + default y if GRKERNSEC_CONFIG_AUTO
61570 + depends on GRKERNSEC_CHROOT
61571 + help
61572 + If you say Y here, processes inside a chroot will not be able to attach
61573 + to shared memory segments that were created outside of the chroot jail.
61574 + It is recommended that you say Y here. If the sysctl option is enabled,
61575 + a sysctl option with name "chroot_deny_shmat" is created.
61576 +
61577 +config GRKERNSEC_CHROOT_UNIX
61578 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61579 + default y if GRKERNSEC_CONFIG_AUTO
61580 + depends on GRKERNSEC_CHROOT
61581 + help
61582 + If you say Y here, processes inside a chroot will not be able to
61583 + connect to abstract (meaning not belonging to a filesystem) Unix
61584 + domain sockets that were bound outside of a chroot. It is recommended
61585 + that you say Y here. If the sysctl option is enabled, a sysctl option
61586 + with name "chroot_deny_unix" is created.
61587 +
61588 +config GRKERNSEC_CHROOT_FINDTASK
61589 + bool "Protect outside processes"
61590 + default y if GRKERNSEC_CONFIG_AUTO
61591 + depends on GRKERNSEC_CHROOT
61592 + help
61593 + If you say Y here, processes inside a chroot will not be able to
61594 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61595 + getsid, or view any process outside of the chroot. If the sysctl
61596 + option is enabled, a sysctl option with name "chroot_findtask" is
61597 + created.
61598 +
61599 +config GRKERNSEC_CHROOT_NICE
61600 + bool "Restrict priority changes"
61601 + default y if GRKERNSEC_CONFIG_AUTO
61602 + depends on GRKERNSEC_CHROOT
61603 + help
61604 + If you say Y here, processes inside a chroot will not be able to raise
61605 + the priority of processes in the chroot, or alter the priority of
61606 + processes outside the chroot. This provides more security than simply
61607 + removing CAP_SYS_NICE from the process' capability set. If the
61608 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61609 + is created.
61610 +
61611 +config GRKERNSEC_CHROOT_SYSCTL
61612 + bool "Deny sysctl writes"
61613 + default y if GRKERNSEC_CONFIG_AUTO
61614 + depends on GRKERNSEC_CHROOT
61615 + help
61616 + If you say Y here, an attacker in a chroot will not be able to
61617 + write to sysctl entries, either by sysctl(2) or through a /proc
61618 + interface. It is strongly recommended that you say Y here. If the
61619 + sysctl option is enabled, a sysctl option with name
61620 + "chroot_deny_sysctl" is created.
61621 +
61622 +config GRKERNSEC_CHROOT_CAPS
61623 + bool "Capability restrictions"
61624 + default y if GRKERNSEC_CONFIG_AUTO
61625 + depends on GRKERNSEC_CHROOT
61626 + help
61627 + If you say Y here, the capabilities on all processes within a
61628 + chroot jail will be lowered to stop module insertion, raw i/o,
61629 + system and net admin tasks, rebooting the system, modifying immutable
61630 + files, modifying IPC owned by another, and changing the system time.
61631 + This is left an option because it can break some apps. Disable this
61632 + if your chrooted apps are having problems performing those kinds of
61633 + tasks. If the sysctl option is enabled, a sysctl option with
61634 + name "chroot_caps" is created.
61635 +
61636 +config GRKERNSEC_CHROOT_INITRD
61637 + bool "Exempt initrd tasks from restrictions"
61638 + default y if GRKERNSEC_CONFIG_AUTO
61639 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61640 + help
61641 + If you say Y here, tasks started prior to init will be exempted from
61642 + grsecurity's chroot restrictions. This option is mainly meant to
61643 + resolve Plymouth's performing privileged operations unnecessarily
61644 + in a chroot.
61645 +
61646 +endmenu
61647 +menu "Kernel Auditing"
61648 +depends on GRKERNSEC
61649 +
61650 +config GRKERNSEC_AUDIT_GROUP
61651 + bool "Single group for auditing"
61652 + help
61653 + If you say Y here, the exec and chdir logging features will only operate
61654 + on a group you specify. This option is recommended if you only want to
61655 + watch certain users instead of having a large amount of logs from the
61656 + entire system. If the sysctl option is enabled, a sysctl option with
61657 + name "audit_group" is created.
61658 +
61659 +config GRKERNSEC_AUDIT_GID
61660 + int "GID for auditing"
61661 + depends on GRKERNSEC_AUDIT_GROUP
61662 + default 1007
61663 +
61664 +config GRKERNSEC_EXECLOG
61665 + bool "Exec logging"
61666 + help
61667 + If you say Y here, all execve() calls will be logged (since the
61668 + other exec*() calls are frontends to execve(), all execution
61669 + will be logged). Useful for shell-servers that like to keep track
61670 + of their users. If the sysctl option is enabled, a sysctl option with
61671 + name "exec_logging" is created.
61672 + WARNING: This option when enabled will produce a LOT of logs, especially
61673 + on an active system.
61674 +
61675 +config GRKERNSEC_RESLOG
61676 + bool "Resource logging"
61677 + default y if GRKERNSEC_CONFIG_AUTO
61678 + help
61679 + If you say Y here, all attempts to overstep resource limits will
61680 + be logged with the resource name, the requested size, and the current
61681 + limit. It is highly recommended that you say Y here. If the sysctl
61682 + option is enabled, a sysctl option with name "resource_logging" is
61683 + created. If the RBAC system is enabled, the sysctl value is ignored.
61684 +
61685 +config GRKERNSEC_CHROOT_EXECLOG
61686 + bool "Log execs within chroot"
61687 + help
61688 + If you say Y here, all executions inside a chroot jail will be logged
61689 + to syslog. This can cause a large amount of logs if certain
61690 + applications (eg. djb's daemontools) are installed on the system, and
61691 + is therefore left as an option. If the sysctl option is enabled, a
61692 + sysctl option with name "chroot_execlog" is created.
61693 +
61694 +config GRKERNSEC_AUDIT_PTRACE
61695 + bool "Ptrace logging"
61696 + help
61697 + If you say Y here, all attempts to attach to a process via ptrace
61698 + will be logged. If the sysctl option is enabled, a sysctl option
61699 + with name "audit_ptrace" is created.
61700 +
61701 +config GRKERNSEC_AUDIT_CHDIR
61702 + bool "Chdir logging"
61703 + help
61704 + If you say Y here, all chdir() calls will be logged. If the sysctl
61705 + option is enabled, a sysctl option with name "audit_chdir" is created.
61706 +
61707 +config GRKERNSEC_AUDIT_MOUNT
61708 + bool "(Un)Mount logging"
61709 + help
61710 + If you say Y here, all mounts and unmounts will be logged. If the
61711 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61712 + created.
61713 +
61714 +config GRKERNSEC_SIGNAL
61715 + bool "Signal logging"
61716 + default y if GRKERNSEC_CONFIG_AUTO
61717 + help
61718 + If you say Y here, certain important signals will be logged, such as
61719 + SIGSEGV, which will as a result inform you of when a error in a program
61720 + occurred, which in some cases could mean a possible exploit attempt.
61721 + If the sysctl option is enabled, a sysctl option with name
61722 + "signal_logging" is created.
61723 +
61724 +config GRKERNSEC_FORKFAIL
61725 + bool "Fork failure logging"
61726 + help
61727 + If you say Y here, all failed fork() attempts will be logged.
61728 + This could suggest a fork bomb, or someone attempting to overstep
61729 + their process limit. If the sysctl option is enabled, a sysctl option
61730 + with name "forkfail_logging" is created.
61731 +
61732 +config GRKERNSEC_TIME
61733 + bool "Time change logging"
61734 + default y if GRKERNSEC_CONFIG_AUTO
61735 + help
61736 + If you say Y here, any changes of the system clock will be logged.
61737 + If the sysctl option is enabled, a sysctl option with name
61738 + "timechange_logging" is created.
61739 +
61740 +config GRKERNSEC_PROC_IPADDR
61741 + bool "/proc/<pid>/ipaddr support"
61742 + default y if GRKERNSEC_CONFIG_AUTO
61743 + help
61744 + If you say Y here, a new entry will be added to each /proc/<pid>
61745 + directory that contains the IP address of the person using the task.
61746 + The IP is carried across local TCP and AF_UNIX stream sockets.
61747 + This information can be useful for IDS/IPSes to perform remote response
61748 + to a local attack. The entry is readable by only the owner of the
61749 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61750 + the RBAC system), and thus does not create privacy concerns.
61751 +
61752 +config GRKERNSEC_RWXMAP_LOG
61753 + bool 'Denied RWX mmap/mprotect logging'
61754 + default y if GRKERNSEC_CONFIG_AUTO
61755 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61756 + help
61757 + If you say Y here, calls to mmap() and mprotect() with explicit
61758 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61759 + denied by the PAX_MPROTECT feature. This feature will also
61760 + log other problematic scenarios that can occur when PAX_MPROTECT
61761 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61762 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61763 + is created.
61764 +
61765 +endmenu
61766 +
61767 +menu "Executable Protections"
61768 +depends on GRKERNSEC
61769 +
61770 +config GRKERNSEC_DMESG
61771 + bool "Dmesg(8) restriction"
61772 + default y if GRKERNSEC_CONFIG_AUTO
61773 + help
61774 + If you say Y here, non-root users will not be able to use dmesg(8)
61775 + to view the contents of the kernel's circular log buffer.
61776 + The kernel's log buffer often contains kernel addresses and other
61777 + identifying information useful to an attacker in fingerprinting a
61778 + system for a targeted exploit.
61779 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61780 + created.
61781 +
61782 +config GRKERNSEC_HARDEN_PTRACE
61783 + bool "Deter ptrace-based process snooping"
61784 + default y if GRKERNSEC_CONFIG_AUTO
61785 + help
61786 + If you say Y here, TTY sniffers and other malicious monitoring
61787 + programs implemented through ptrace will be defeated. If you
61788 + have been using the RBAC system, this option has already been
61789 + enabled for several years for all users, with the ability to make
61790 + fine-grained exceptions.
61791 +
61792 + This option only affects the ability of non-root users to ptrace
61793 + processes that are not a descendent of the ptracing process.
61794 + This means that strace ./binary and gdb ./binary will still work,
61795 + but attaching to arbitrary processes will not. If the sysctl
61796 + option is enabled, a sysctl option with name "harden_ptrace" is
61797 + created.
61798 +
61799 +config GRKERNSEC_PTRACE_READEXEC
61800 + bool "Require read access to ptrace sensitive binaries"
61801 + default y if GRKERNSEC_CONFIG_AUTO
61802 + help
61803 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61804 + binaries. This option is useful in environments that
61805 + remove the read bits (e.g. file mode 4711) from suid binaries to
61806 + prevent infoleaking of their contents. This option adds
61807 + consistency to the use of that file mode, as the binary could normally
61808 + be read out when run without privileges while ptracing.
61809 +
61810 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61811 + is created.
61812 +
61813 +config GRKERNSEC_SETXID
61814 + bool "Enforce consistent multithreaded privileges"
61815 + default y if GRKERNSEC_CONFIG_AUTO
61816 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61817 + help
61818 + If you say Y here, a change from a root uid to a non-root uid
61819 + in a multithreaded application will cause the resulting uids,
61820 + gids, supplementary groups, and capabilities in that thread
61821 + to be propagated to the other threads of the process. In most
61822 + cases this is unnecessary, as glibc will emulate this behavior
61823 + on behalf of the application. Other libcs do not act in the
61824 + same way, allowing the other threads of the process to continue
61825 + running with root privileges. If the sysctl option is enabled,
61826 + a sysctl option with name "consistent_setxid" is created.
61827 +
61828 +config GRKERNSEC_TPE
61829 + bool "Trusted Path Execution (TPE)"
61830 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61831 + help
61832 + If you say Y here, you will be able to choose a gid to add to the
61833 + supplementary groups of users you want to mark as "untrusted."
61834 + These users will not be able to execute any files that are not in
61835 + root-owned directories writable only by root. If the sysctl option
61836 + is enabled, a sysctl option with name "tpe" is created.
61837 +
61838 +config GRKERNSEC_TPE_ALL
61839 + bool "Partially restrict all non-root users"
61840 + depends on GRKERNSEC_TPE
61841 + help
61842 + If you say Y here, all non-root users will be covered under
61843 + a weaker TPE restriction. This is separate from, and in addition to,
61844 + the main TPE options that you have selected elsewhere. Thus, if a
61845 + "trusted" GID is chosen, this restriction applies to even that GID.
61846 + Under this restriction, all non-root users will only be allowed to
61847 + execute files in directories they own that are not group or
61848 + world-writable, or in directories owned by root and writable only by
61849 + root. If the sysctl option is enabled, a sysctl option with name
61850 + "tpe_restrict_all" is created.
61851 +
61852 +config GRKERNSEC_TPE_INVERT
61853 + bool "Invert GID option"
61854 + depends on GRKERNSEC_TPE
61855 + help
61856 + If you say Y here, the group you specify in the TPE configuration will
61857 + decide what group TPE restrictions will be *disabled* for. This
61858 + option is useful if you want TPE restrictions to be applied to most
61859 + users on the system. If the sysctl option is enabled, a sysctl option
61860 + with name "tpe_invert" is created. Unlike other sysctl options, this
61861 + entry will default to on for backward-compatibility.
61862 +
61863 +config GRKERNSEC_TPE_GID
61864 + int
61865 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61866 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61867 +
61868 +config GRKERNSEC_TPE_UNTRUSTED_GID
61869 + int "GID for TPE-untrusted users"
61870 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61871 + default 1005
61872 + help
61873 + Setting this GID determines what group TPE restrictions will be
61874 + *enabled* for. If the sysctl option is enabled, a sysctl option
61875 + with name "tpe_gid" is created.
61876 +
61877 +config GRKERNSEC_TPE_TRUSTED_GID
61878 + int "GID for TPE-trusted users"
61879 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61880 + default 1005
61881 + help
61882 + Setting this GID determines what group TPE restrictions will be
61883 + *disabled* for. If the sysctl option is enabled, a sysctl option
61884 + with name "tpe_gid" is created.
61885 +
61886 +endmenu
61887 +menu "Network Protections"
61888 +depends on GRKERNSEC
61889 +
61890 +config GRKERNSEC_RANDNET
61891 + bool "Larger entropy pools"
61892 + default y if GRKERNSEC_CONFIG_AUTO
61893 + help
61894 + If you say Y here, the entropy pools used for many features of Linux
61895 + and grsecurity will be doubled in size. Since several grsecurity
61896 + features use additional randomness, it is recommended that you say Y
61897 + here. Saying Y here has a similar effect as modifying
61898 + /proc/sys/kernel/random/poolsize.
61899 +
61900 +config GRKERNSEC_BLACKHOLE
61901 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61902 + default y if GRKERNSEC_CONFIG_AUTO
61903 + depends on NET
61904 + help
61905 + If you say Y here, neither TCP resets nor ICMP
61906 + destination-unreachable packets will be sent in response to packets
61907 + sent to ports for which no associated listening process exists.
61908 + This feature supports both IPV4 and IPV6 and exempts the
61909 + loopback interface from blackholing. Enabling this feature
61910 + makes a host more resilient to DoS attacks and reduces network
61911 + visibility against scanners.
61912 +
61913 + The blackhole feature as-implemented is equivalent to the FreeBSD
61914 + blackhole feature, as it prevents RST responses to all packets, not
61915 + just SYNs. Under most application behavior this causes no
61916 + problems, but applications (like haproxy) may not close certain
61917 + connections in a way that cleanly terminates them on the remote
61918 + end, leaving the remote host in LAST_ACK state. Because of this
61919 + side-effect and to prevent intentional LAST_ACK DoSes, this
61920 + feature also adds automatic mitigation against such attacks.
61921 + The mitigation drastically reduces the amount of time a socket
61922 + can spend in LAST_ACK state. If you're using haproxy and not
61923 + all servers it connects to have this option enabled, consider
61924 + disabling this feature on the haproxy host.
61925 +
61926 + If the sysctl option is enabled, two sysctl options with names
61927 + "ip_blackhole" and "lastack_retries" will be created.
61928 + While "ip_blackhole" takes the standard zero/non-zero on/off
61929 + toggle, "lastack_retries" uses the same kinds of values as
61930 + "tcp_retries1" and "tcp_retries2". The default value of 4
61931 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61932 + state.
61933 +
61934 +config GRKERNSEC_NO_SIMULT_CONNECT
61935 + bool "Disable TCP Simultaneous Connect"
61936 + default y if GRKERNSEC_CONFIG_AUTO
61937 + depends on NET
61938 + help
61939 + If you say Y here, a feature by Willy Tarreau will be enabled that
61940 + removes a weakness in Linux's strict implementation of TCP that
61941 + allows two clients to connect to each other without either entering
61942 + a listening state. The weakness allows an attacker to easily prevent
61943 + a client from connecting to a known server provided the source port
61944 + for the connection is guessed correctly.
61945 +
61946 + As the weakness could be used to prevent an antivirus or IPS from
61947 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61948 + it should be eliminated by enabling this option. Though Linux is
61949 + one of few operating systems supporting simultaneous connect, it
61950 + has no legitimate use in practice and is rarely supported by firewalls.
61951 +
61952 +config GRKERNSEC_SOCKET
61953 + bool "Socket restrictions"
61954 + depends on NET
61955 + help
61956 + If you say Y here, you will be able to choose from several options.
61957 + If you assign a GID on your system and add it to the supplementary
61958 + groups of users you want to restrict socket access to, this patch
61959 + will perform up to three things, based on the option(s) you choose.
61960 +
61961 +config GRKERNSEC_SOCKET_ALL
61962 + bool "Deny any sockets to group"
61963 + depends on GRKERNSEC_SOCKET
61964 + help
61965 + If you say Y here, you will be able to choose a GID of whose users will
61966 + be unable to connect to other hosts from your machine or run server
61967 + applications from your machine. If the sysctl option is enabled, a
61968 + sysctl option with name "socket_all" is created.
61969 +
61970 +config GRKERNSEC_SOCKET_ALL_GID
61971 + int "GID to deny all sockets for"
61972 + depends on GRKERNSEC_SOCKET_ALL
61973 + default 1004
61974 + help
61975 + Here you can choose the GID to disable socket access for. Remember to
61976 + add the users you want socket access disabled for to the GID
61977 + specified here. If the sysctl option is enabled, a sysctl option
61978 + with name "socket_all_gid" is created.
61979 +
61980 +config GRKERNSEC_SOCKET_CLIENT
61981 + bool "Deny client sockets to group"
61982 + depends on GRKERNSEC_SOCKET
61983 + help
61984 + If you say Y here, you will be able to choose a GID of whose users will
61985 + be unable to connect to other hosts from your machine, but will be
61986 + able to run servers. If this option is enabled, all users in the group
61987 + you specify will have to use passive mode when initiating ftp transfers
61988 + from the shell on your machine. If the sysctl option is enabled, a
61989 + sysctl option with name "socket_client" is created.
61990 +
61991 +config GRKERNSEC_SOCKET_CLIENT_GID
61992 + int "GID to deny client sockets for"
61993 + depends on GRKERNSEC_SOCKET_CLIENT
61994 + default 1003
61995 + help
61996 + Here you can choose the GID to disable client socket access for.
61997 + Remember to add the users you want client socket access disabled for to
61998 + the GID specified here. If the sysctl option is enabled, a sysctl
61999 + option with name "socket_client_gid" is created.
62000 +
62001 +config GRKERNSEC_SOCKET_SERVER
62002 + bool "Deny server sockets to group"
62003 + depends on GRKERNSEC_SOCKET
62004 + help
62005 + If you say Y here, you will be able to choose a GID of whose users will
62006 + be unable to run server applications from your machine. If the sysctl
62007 + option is enabled, a sysctl option with name "socket_server" is created.
62008 +
62009 +config GRKERNSEC_SOCKET_SERVER_GID
62010 + int "GID to deny server sockets for"
62011 + depends on GRKERNSEC_SOCKET_SERVER
62012 + default 1002
62013 + help
62014 + Here you can choose the GID to disable server socket access for.
62015 + Remember to add the users you want server socket access disabled for to
62016 + the GID specified here. If the sysctl option is enabled, a sysctl
62017 + option with name "socket_server_gid" is created.
62018 +
62019 +endmenu
62020 +
62021 +menu "Physical Protections"
62022 +depends on GRKERNSEC
62023 +
62024 +config GRKERNSEC_DENYUSB
62025 + bool "Deny new USB connections after toggle"
62026 + default y if GRKERNSEC_CONFIG_AUTO
62027 + depends on SYSCTL && USB_SUPPORT
62028 + help
62029 + If you say Y here, a new sysctl option with name "deny_new_usb"
62030 + will be created. Setting its value to 1 will prevent any new
62031 + USB devices from being recognized by the OS. Any attempted USB
62032 + device insertion will be logged. This option is intended to be
62033 + used against custom USB devices designed to exploit vulnerabilities
62034 + in various USB device drivers.
62035 +
62036 + For greatest effectiveness, this sysctl should be set after any
62037 + relevant init scripts. This option is safe to enable in distros
62038 + as each user can choose whether or not to toggle the sysctl.
62039 +
62040 +config GRKERNSEC_DENYUSB_FORCE
62041 + bool "Reject all USB devices not connected at boot"
62042 + select USB
62043 + depends on GRKERNSEC_DENYUSB
62044 + help
62045 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62046 + that doesn't involve a sysctl entry. This option should only be
62047 + enabled if you're sure you want to deny all new USB connections
62048 + at runtime and don't want to modify init scripts. This should not
62049 + be enabled by distros. It forces the core USB code to be built
62050 + into the kernel image so that all devices connected at boot time
62051 + can be recognized and new USB device connections can be prevented
62052 + prior to init running.
62053 +
62054 +endmenu
62055 +
62056 +menu "Sysctl Support"
62057 +depends on GRKERNSEC && SYSCTL
62058 +
62059 +config GRKERNSEC_SYSCTL
62060 + bool "Sysctl support"
62061 + default y if GRKERNSEC_CONFIG_AUTO
62062 + help
62063 + If you say Y here, you will be able to change the options that
62064 + grsecurity runs with at bootup, without having to recompile your
62065 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62066 + to enable (1) or disable (0) various features. All the sysctl entries
62067 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62068 + All features enabled in the kernel configuration are disabled at boot
62069 + if you do not say Y to the "Turn on features by default" option.
62070 + All options should be set at startup, and the grsec_lock entry should
62071 + be set to a non-zero value after all the options are set.
62072 + *THIS IS EXTREMELY IMPORTANT*
62073 +
62074 +config GRKERNSEC_SYSCTL_DISTRO
62075 + bool "Extra sysctl support for distro makers (READ HELP)"
62076 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62077 + help
62078 + If you say Y here, additional sysctl options will be created
62079 + for features that affect processes running as root. Therefore,
62080 + it is critical when using this option that the grsec_lock entry be
62081 + enabled after boot. Only distros with prebuilt kernel packages
62082 + with this option enabled that can ensure grsec_lock is enabled
62083 + after boot should use this option.
62084 + *Failure to set grsec_lock after boot makes all grsec features
62085 + this option covers useless*
62086 +
62087 + Currently this option creates the following sysctl entries:
62088 + "Disable Privileged I/O": "disable_priv_io"
62089 +
62090 +config GRKERNSEC_SYSCTL_ON
62091 + bool "Turn on features by default"
62092 + default y if GRKERNSEC_CONFIG_AUTO
62093 + depends on GRKERNSEC_SYSCTL
62094 + help
62095 + If you say Y here, instead of having all features enabled in the
62096 + kernel configuration disabled at boot time, the features will be
62097 + enabled at boot time. It is recommended you say Y here unless
62098 + there is some reason you would want all sysctl-tunable features to
62099 + be disabled by default. As mentioned elsewhere, it is important
62100 + to enable the grsec_lock entry once you have finished modifying
62101 + the sysctl entries.
62102 +
62103 +endmenu
62104 +menu "Logging Options"
62105 +depends on GRKERNSEC
62106 +
62107 +config GRKERNSEC_FLOODTIME
62108 + int "Seconds in between log messages (minimum)"
62109 + default 10
62110 + help
62111 + This option allows you to enforce the number of seconds between
62112 + grsecurity log messages. The default should be suitable for most
62113 + people, however, if you choose to change it, choose a value small enough
62114 + to allow informative logs to be produced, but large enough to
62115 + prevent flooding.
62116 +
62117 +config GRKERNSEC_FLOODBURST
62118 + int "Number of messages in a burst (maximum)"
62119 + default 6
62120 + help
62121 + This option allows you to choose the maximum number of messages allowed
62122 + within the flood time interval you chose in a separate option. The
62123 + default should be suitable for most people, however if you find that
62124 + many of your logs are being interpreted as flooding, you may want to
62125 + raise this value.
62126 +
62127 +endmenu
62128 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62129 new file mode 100644
62130 index 0000000..b0b77d5
62131 --- /dev/null
62132 +++ b/grsecurity/Makefile
62133 @@ -0,0 +1,43 @@
62134 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62135 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62136 +# into an RBAC system
62137 +#
62138 +# All code in this directory and various hooks inserted throughout the kernel
62139 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62140 +# under the GPL v2 or higher
62141 +
62142 +KBUILD_CFLAGS += -Werror
62143 +
62144 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62145 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62146 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62147 + grsec_usb.o
62148 +
62149 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62150 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62151 + gracl_learn.o grsec_log.o
62152 +ifdef CONFIG_COMPAT
62153 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62154 +endif
62155 +
62156 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62157 +
62158 +ifdef CONFIG_NET
62159 +obj-y += grsec_sock.o
62160 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62161 +endif
62162 +
62163 +ifndef CONFIG_GRKERNSEC
62164 +obj-y += grsec_disabled.o
62165 +endif
62166 +
62167 +ifdef CONFIG_GRKERNSEC_HIDESYM
62168 +extra-y := grsec_hidesym.o
62169 +$(obj)/grsec_hidesym.o:
62170 + @-chmod -f 500 /boot
62171 + @-chmod -f 500 /lib/modules
62172 + @-chmod -f 500 /lib64/modules
62173 + @-chmod -f 500 /lib32/modules
62174 + @-chmod -f 700 .
62175 + @echo ' grsec: protected kernel image paths'
62176 +endif
62177 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62178 new file mode 100644
62179 index 0000000..c0793fd
62180 --- /dev/null
62181 +++ b/grsecurity/gracl.c
62182 @@ -0,0 +1,4178 @@
62183 +#include <linux/kernel.h>
62184 +#include <linux/module.h>
62185 +#include <linux/sched.h>
62186 +#include <linux/mm.h>
62187 +#include <linux/file.h>
62188 +#include <linux/fs.h>
62189 +#include <linux/namei.h>
62190 +#include <linux/mount.h>
62191 +#include <linux/tty.h>
62192 +#include <linux/proc_fs.h>
62193 +#include <linux/lglock.h>
62194 +#include <linux/slab.h>
62195 +#include <linux/vmalloc.h>
62196 +#include <linux/types.h>
62197 +#include <linux/sysctl.h>
62198 +#include <linux/netdevice.h>
62199 +#include <linux/ptrace.h>
62200 +#include <linux/gracl.h>
62201 +#include <linux/gralloc.h>
62202 +#include <linux/security.h>
62203 +#include <linux/grinternal.h>
62204 +#include <linux/pid_namespace.h>
62205 +#include <linux/stop_machine.h>
62206 +#include <linux/fdtable.h>
62207 +#include <linux/percpu.h>
62208 +#include <linux/lglock.h>
62209 +#include <linux/hugetlb.h>
62210 +#include <linux/posix-timers.h>
62211 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62212 +#include <linux/magic.h>
62213 +#include <linux/pagemap.h>
62214 +#include "../fs/btrfs/async-thread.h"
62215 +#include "../fs/btrfs/ctree.h"
62216 +#include "../fs/btrfs/btrfs_inode.h"
62217 +#endif
62218 +#include "../fs/mount.h"
62219 +
62220 +#include <asm/uaccess.h>
62221 +#include <asm/errno.h>
62222 +#include <asm/mman.h>
62223 +
62224 +extern struct lglock vfsmount_lock;
62225 +
62226 +static struct acl_role_db acl_role_set;
62227 +static struct name_db name_set;
62228 +static struct inodev_db inodev_set;
62229 +
62230 +/* for keeping track of userspace pointers used for subjects, so we
62231 + can share references in the kernel as well
62232 +*/
62233 +
62234 +static struct path real_root;
62235 +
62236 +static struct acl_subj_map_db subj_map_set;
62237 +
62238 +static struct acl_role_label *default_role;
62239 +
62240 +static struct acl_role_label *role_list;
62241 +
62242 +static u16 acl_sp_role_value;
62243 +
62244 +extern char *gr_shared_page[4];
62245 +static DEFINE_MUTEX(gr_dev_mutex);
62246 +DEFINE_RWLOCK(gr_inode_lock);
62247 +
62248 +struct gr_arg *gr_usermode;
62249 +
62250 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62251 +
62252 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62253 +extern void gr_clear_learn_entries(void);
62254 +
62255 +unsigned char *gr_system_salt;
62256 +unsigned char *gr_system_sum;
62257 +
62258 +static struct sprole_pw **acl_special_roles = NULL;
62259 +static __u16 num_sprole_pws = 0;
62260 +
62261 +static struct acl_role_label *kernel_role = NULL;
62262 +
62263 +static unsigned int gr_auth_attempts = 0;
62264 +static unsigned long gr_auth_expires = 0UL;
62265 +
62266 +#ifdef CONFIG_NET
62267 +extern struct vfsmount *sock_mnt;
62268 +#endif
62269 +
62270 +extern struct vfsmount *pipe_mnt;
62271 +extern struct vfsmount *shm_mnt;
62272 +
62273 +#ifdef CONFIG_HUGETLBFS
62274 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62275 +#endif
62276 +
62277 +static struct acl_object_label *fakefs_obj_rw;
62278 +static struct acl_object_label *fakefs_obj_rwx;
62279 +
62280 +extern int gr_init_uidset(void);
62281 +extern void gr_free_uidset(void);
62282 +extern void gr_remove_uid(uid_t uid);
62283 +extern int gr_find_uid(uid_t uid);
62284 +
62285 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62286 +{
62287 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62288 + return -EFAULT;
62289 +
62290 + return 0;
62291 +}
62292 +
62293 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62294 +{
62295 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62296 + return -EFAULT;
62297 +
62298 + return 0;
62299 +}
62300 +
62301 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62302 +{
62303 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62304 + return -EFAULT;
62305 +
62306 + return 0;
62307 +}
62308 +
62309 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62310 +{
62311 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62312 + return -EFAULT;
62313 +
62314 + return 0;
62315 +}
62316 +
62317 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62318 +{
62319 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62320 + return -EFAULT;
62321 +
62322 + return 0;
62323 +}
62324 +
62325 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62326 +{
62327 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62328 + return -EFAULT;
62329 +
62330 + return 0;
62331 +}
62332 +
62333 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62334 +{
62335 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62336 + return -EFAULT;
62337 +
62338 + return 0;
62339 +}
62340 +
62341 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62342 +{
62343 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62344 + return -EFAULT;
62345 +
62346 + return 0;
62347 +}
62348 +
62349 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62350 +{
62351 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62352 + return -EFAULT;
62353 +
62354 + return 0;
62355 +}
62356 +
62357 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62358 +{
62359 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62360 + return -EFAULT;
62361 +
62362 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62363 + return -EINVAL;
62364 +
62365 + return 0;
62366 +}
62367 +
62368 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62369 +{
62370 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62371 + return -EFAULT;
62372 +
62373 + return 0;
62374 +}
62375 +
62376 +static size_t get_gr_arg_wrapper_size_normal(void)
62377 +{
62378 + return sizeof(struct gr_arg_wrapper);
62379 +}
62380 +
62381 +#ifdef CONFIG_COMPAT
62382 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62383 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62384 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62385 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62386 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62387 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62388 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62389 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62390 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62391 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62392 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62393 +extern size_t get_gr_arg_wrapper_size_compat(void);
62394 +
62395 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62396 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62397 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62398 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62399 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62400 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62401 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62402 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62403 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62404 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62405 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62406 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62407 +
62408 +#else
62409 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62410 +#define copy_gr_arg copy_gr_arg_normal
62411 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62412 +#define copy_acl_object_label copy_acl_object_label_normal
62413 +#define copy_acl_subject_label copy_acl_subject_label_normal
62414 +#define copy_acl_role_label copy_acl_role_label_normal
62415 +#define copy_acl_ip_label copy_acl_ip_label_normal
62416 +#define copy_pointer_from_array copy_pointer_from_array_normal
62417 +#define copy_sprole_pw copy_sprole_pw_normal
62418 +#define copy_role_transition copy_role_transition_normal
62419 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62420 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62421 +#endif
62422 +
62423 +__inline__ int
62424 +gr_acl_is_enabled(void)
62425 +{
62426 + return (gr_status & GR_READY);
62427 +}
62428 +
62429 +static inline dev_t __get_dev(const struct dentry *dentry)
62430 +{
62431 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62432 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62433 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62434 + else
62435 +#endif
62436 + return dentry->d_sb->s_dev;
62437 +}
62438 +
62439 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62440 +{
62441 + return __get_dev(dentry);
62442 +}
62443 +
62444 +static char gr_task_roletype_to_char(struct task_struct *task)
62445 +{
62446 + switch (task->role->roletype &
62447 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62448 + GR_ROLE_SPECIAL)) {
62449 + case GR_ROLE_DEFAULT:
62450 + return 'D';
62451 + case GR_ROLE_USER:
62452 + return 'U';
62453 + case GR_ROLE_GROUP:
62454 + return 'G';
62455 + case GR_ROLE_SPECIAL:
62456 + return 'S';
62457 + }
62458 +
62459 + return 'X';
62460 +}
62461 +
62462 +char gr_roletype_to_char(void)
62463 +{
62464 + return gr_task_roletype_to_char(current);
62465 +}
62466 +
62467 +__inline__ int
62468 +gr_acl_tpe_check(void)
62469 +{
62470 + if (unlikely(!(gr_status & GR_READY)))
62471 + return 0;
62472 + if (current->role->roletype & GR_ROLE_TPE)
62473 + return 1;
62474 + else
62475 + return 0;
62476 +}
62477 +
62478 +int
62479 +gr_handle_rawio(const struct inode *inode)
62480 +{
62481 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62482 + if (inode && S_ISBLK(inode->i_mode) &&
62483 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62484 + !capable(CAP_SYS_RAWIO))
62485 + return 1;
62486 +#endif
62487 + return 0;
62488 +}
62489 +
62490 +static int
62491 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62492 +{
62493 + if (likely(lena != lenb))
62494 + return 0;
62495 +
62496 + return !memcmp(a, b, lena);
62497 +}
62498 +
62499 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62500 +{
62501 + *buflen -= namelen;
62502 + if (*buflen < 0)
62503 + return -ENAMETOOLONG;
62504 + *buffer -= namelen;
62505 + memcpy(*buffer, str, namelen);
62506 + return 0;
62507 +}
62508 +
62509 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62510 +{
62511 + return prepend(buffer, buflen, name->name, name->len);
62512 +}
62513 +
62514 +static int prepend_path(const struct path *path, struct path *root,
62515 + char **buffer, int *buflen)
62516 +{
62517 + struct dentry *dentry = path->dentry;
62518 + struct vfsmount *vfsmnt = path->mnt;
62519 + struct mount *mnt = real_mount(vfsmnt);
62520 + bool slash = false;
62521 + int error = 0;
62522 +
62523 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62524 + struct dentry * parent;
62525 +
62526 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62527 + /* Global root? */
62528 + if (!mnt_has_parent(mnt)) {
62529 + goto out;
62530 + }
62531 + dentry = mnt->mnt_mountpoint;
62532 + mnt = mnt->mnt_parent;
62533 + vfsmnt = &mnt->mnt;
62534 + continue;
62535 + }
62536 + parent = dentry->d_parent;
62537 + prefetch(parent);
62538 + spin_lock(&dentry->d_lock);
62539 + error = prepend_name(buffer, buflen, &dentry->d_name);
62540 + spin_unlock(&dentry->d_lock);
62541 + if (!error)
62542 + error = prepend(buffer, buflen, "/", 1);
62543 + if (error)
62544 + break;
62545 +
62546 + slash = true;
62547 + dentry = parent;
62548 + }
62549 +
62550 +out:
62551 + if (!error && !slash)
62552 + error = prepend(buffer, buflen, "/", 1);
62553 +
62554 + return error;
62555 +}
62556 +
62557 +/* this must be called with vfsmount_lock and rename_lock held */
62558 +
62559 +static char *__our_d_path(const struct path *path, struct path *root,
62560 + char *buf, int buflen)
62561 +{
62562 + char *res = buf + buflen;
62563 + int error;
62564 +
62565 + prepend(&res, &buflen, "\0", 1);
62566 + error = prepend_path(path, root, &res, &buflen);
62567 + if (error)
62568 + return ERR_PTR(error);
62569 +
62570 + return res;
62571 +}
62572 +
62573 +static char *
62574 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62575 +{
62576 + char *retval;
62577 +
62578 + retval = __our_d_path(path, root, buf, buflen);
62579 + if (unlikely(IS_ERR(retval)))
62580 + retval = strcpy(buf, "<path too long>");
62581 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62582 + retval[1] = '\0';
62583 +
62584 + return retval;
62585 +}
62586 +
62587 +static char *
62588 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62589 + char *buf, int buflen)
62590 +{
62591 + struct path path;
62592 + char *res;
62593 +
62594 + path.dentry = (struct dentry *)dentry;
62595 + path.mnt = (struct vfsmount *)vfsmnt;
62596 +
62597 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62598 + by the RBAC system */
62599 + res = gen_full_path(&path, &real_root, buf, buflen);
62600 +
62601 + return res;
62602 +}
62603 +
62604 +static char *
62605 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62606 + char *buf, int buflen)
62607 +{
62608 + char *res;
62609 + struct path path;
62610 + struct path root;
62611 + struct task_struct *reaper = init_pid_ns.child_reaper;
62612 +
62613 + path.dentry = (struct dentry *)dentry;
62614 + path.mnt = (struct vfsmount *)vfsmnt;
62615 +
62616 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62617 + get_fs_root(reaper->fs, &root);
62618 +
62619 + br_read_lock(&vfsmount_lock);
62620 + write_seqlock(&rename_lock);
62621 + res = gen_full_path(&path, &root, buf, buflen);
62622 + write_sequnlock(&rename_lock);
62623 + br_read_unlock(&vfsmount_lock);
62624 +
62625 + path_put(&root);
62626 + return res;
62627 +}
62628 +
62629 +static char *
62630 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62631 +{
62632 + char *ret;
62633 + br_read_lock(&vfsmount_lock);
62634 + write_seqlock(&rename_lock);
62635 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62636 + PAGE_SIZE);
62637 + write_sequnlock(&rename_lock);
62638 + br_read_unlock(&vfsmount_lock);
62639 + return ret;
62640 +}
62641 +
62642 +static char *
62643 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62644 +{
62645 + char *ret;
62646 + char *buf;
62647 + int buflen;
62648 +
62649 + br_read_lock(&vfsmount_lock);
62650 + write_seqlock(&rename_lock);
62651 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62652 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62653 + buflen = (int)(ret - buf);
62654 + if (buflen >= 5)
62655 + prepend(&ret, &buflen, "/proc", 5);
62656 + else
62657 + ret = strcpy(buf, "<path too long>");
62658 + write_sequnlock(&rename_lock);
62659 + br_read_unlock(&vfsmount_lock);
62660 + return ret;
62661 +}
62662 +
62663 +char *
62664 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62665 +{
62666 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62667 + PAGE_SIZE);
62668 +}
62669 +
62670 +char *
62671 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62672 +{
62673 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62674 + PAGE_SIZE);
62675 +}
62676 +
62677 +char *
62678 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62679 +{
62680 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62681 + PAGE_SIZE);
62682 +}
62683 +
62684 +char *
62685 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62686 +{
62687 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62688 + PAGE_SIZE);
62689 +}
62690 +
62691 +char *
62692 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62693 +{
62694 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62695 + PAGE_SIZE);
62696 +}
62697 +
62698 +__inline__ __u32
62699 +to_gr_audit(const __u32 reqmode)
62700 +{
62701 + /* masks off auditable permission flags, then shifts them to create
62702 + auditing flags, and adds the special case of append auditing if
62703 + we're requesting write */
62704 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62705 +}
62706 +
62707 +struct acl_subject_label *
62708 +lookup_subject_map(const struct acl_subject_label *userp)
62709 +{
62710 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62711 + struct subject_map *match;
62712 +
62713 + match = subj_map_set.s_hash[index];
62714 +
62715 + while (match && match->user != userp)
62716 + match = match->next;
62717 +
62718 + if (match != NULL)
62719 + return match->kernel;
62720 + else
62721 + return NULL;
62722 +}
62723 +
62724 +static void
62725 +insert_subj_map_entry(struct subject_map *subjmap)
62726 +{
62727 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62728 + struct subject_map **curr;
62729 +
62730 + subjmap->prev = NULL;
62731 +
62732 + curr = &subj_map_set.s_hash[index];
62733 + if (*curr != NULL)
62734 + (*curr)->prev = subjmap;
62735 +
62736 + subjmap->next = *curr;
62737 + *curr = subjmap;
62738 +
62739 + return;
62740 +}
62741 +
62742 +static struct acl_role_label *
62743 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62744 + const gid_t gid)
62745 +{
62746 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62747 + struct acl_role_label *match;
62748 + struct role_allowed_ip *ipp;
62749 + unsigned int x;
62750 + u32 curr_ip = task->signal->curr_ip;
62751 +
62752 + task->signal->saved_ip = curr_ip;
62753 +
62754 + match = acl_role_set.r_hash[index];
62755 +
62756 + while (match) {
62757 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62758 + for (x = 0; x < match->domain_child_num; x++) {
62759 + if (match->domain_children[x] == uid)
62760 + goto found;
62761 + }
62762 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62763 + break;
62764 + match = match->next;
62765 + }
62766 +found:
62767 + if (match == NULL) {
62768 + try_group:
62769 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62770 + match = acl_role_set.r_hash[index];
62771 +
62772 + while (match) {
62773 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62774 + for (x = 0; x < match->domain_child_num; x++) {
62775 + if (match->domain_children[x] == gid)
62776 + goto found2;
62777 + }
62778 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62779 + break;
62780 + match = match->next;
62781 + }
62782 +found2:
62783 + if (match == NULL)
62784 + match = default_role;
62785 + if (match->allowed_ips == NULL)
62786 + return match;
62787 + else {
62788 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62789 + if (likely
62790 + ((ntohl(curr_ip) & ipp->netmask) ==
62791 + (ntohl(ipp->addr) & ipp->netmask)))
62792 + return match;
62793 + }
62794 + match = default_role;
62795 + }
62796 + } else if (match->allowed_ips == NULL) {
62797 + return match;
62798 + } else {
62799 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62800 + if (likely
62801 + ((ntohl(curr_ip) & ipp->netmask) ==
62802 + (ntohl(ipp->addr) & ipp->netmask)))
62803 + return match;
62804 + }
62805 + goto try_group;
62806 + }
62807 +
62808 + return match;
62809 +}
62810 +
62811 +struct acl_subject_label *
62812 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62813 + const struct acl_role_label *role)
62814 +{
62815 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62816 + struct acl_subject_label *match;
62817 +
62818 + match = role->subj_hash[index];
62819 +
62820 + while (match && (match->inode != ino || match->device != dev ||
62821 + (match->mode & GR_DELETED))) {
62822 + match = match->next;
62823 + }
62824 +
62825 + if (match && !(match->mode & GR_DELETED))
62826 + return match;
62827 + else
62828 + return NULL;
62829 +}
62830 +
62831 +struct acl_subject_label *
62832 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62833 + const struct acl_role_label *role)
62834 +{
62835 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62836 + struct acl_subject_label *match;
62837 +
62838 + match = role->subj_hash[index];
62839 +
62840 + while (match && (match->inode != ino || match->device != dev ||
62841 + !(match->mode & GR_DELETED))) {
62842 + match = match->next;
62843 + }
62844 +
62845 + if (match && (match->mode & GR_DELETED))
62846 + return match;
62847 + else
62848 + return NULL;
62849 +}
62850 +
62851 +static struct acl_object_label *
62852 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62853 + const struct acl_subject_label *subj)
62854 +{
62855 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62856 + struct acl_object_label *match;
62857 +
62858 + match = subj->obj_hash[index];
62859 +
62860 + while (match && (match->inode != ino || match->device != dev ||
62861 + (match->mode & GR_DELETED))) {
62862 + match = match->next;
62863 + }
62864 +
62865 + if (match && !(match->mode & GR_DELETED))
62866 + return match;
62867 + else
62868 + return NULL;
62869 +}
62870 +
62871 +static struct acl_object_label *
62872 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62873 + const struct acl_subject_label *subj)
62874 +{
62875 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62876 + struct acl_object_label *match;
62877 +
62878 + match = subj->obj_hash[index];
62879 +
62880 + while (match && (match->inode != ino || match->device != dev ||
62881 + !(match->mode & GR_DELETED))) {
62882 + match = match->next;
62883 + }
62884 +
62885 + if (match && (match->mode & GR_DELETED))
62886 + return match;
62887 +
62888 + match = subj->obj_hash[index];
62889 +
62890 + while (match && (match->inode != ino || match->device != dev ||
62891 + (match->mode & GR_DELETED))) {
62892 + match = match->next;
62893 + }
62894 +
62895 + if (match && !(match->mode & GR_DELETED))
62896 + return match;
62897 + else
62898 + return NULL;
62899 +}
62900 +
62901 +static struct name_entry *
62902 +lookup_name_entry(const char *name)
62903 +{
62904 + unsigned int len = strlen(name);
62905 + unsigned int key = full_name_hash(name, len);
62906 + unsigned int index = key % name_set.n_size;
62907 + struct name_entry *match;
62908 +
62909 + match = name_set.n_hash[index];
62910 +
62911 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62912 + match = match->next;
62913 +
62914 + return match;
62915 +}
62916 +
62917 +static struct name_entry *
62918 +lookup_name_entry_create(const char *name)
62919 +{
62920 + unsigned int len = strlen(name);
62921 + unsigned int key = full_name_hash(name, len);
62922 + unsigned int index = key % name_set.n_size;
62923 + struct name_entry *match;
62924 +
62925 + match = name_set.n_hash[index];
62926 +
62927 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62928 + !match->deleted))
62929 + match = match->next;
62930 +
62931 + if (match && match->deleted)
62932 + return match;
62933 +
62934 + match = name_set.n_hash[index];
62935 +
62936 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62937 + match->deleted))
62938 + match = match->next;
62939 +
62940 + if (match && !match->deleted)
62941 + return match;
62942 + else
62943 + return NULL;
62944 +}
62945 +
62946 +static struct inodev_entry *
62947 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62948 +{
62949 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62950 + struct inodev_entry *match;
62951 +
62952 + match = inodev_set.i_hash[index];
62953 +
62954 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62955 + match = match->next;
62956 +
62957 + return match;
62958 +}
62959 +
62960 +static void
62961 +insert_inodev_entry(struct inodev_entry *entry)
62962 +{
62963 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62964 + inodev_set.i_size);
62965 + struct inodev_entry **curr;
62966 +
62967 + entry->prev = NULL;
62968 +
62969 + curr = &inodev_set.i_hash[index];
62970 + if (*curr != NULL)
62971 + (*curr)->prev = entry;
62972 +
62973 + entry->next = *curr;
62974 + *curr = entry;
62975 +
62976 + return;
62977 +}
62978 +
62979 +static void
62980 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
62981 +{
62982 + unsigned int index =
62983 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
62984 + struct acl_role_label **curr;
62985 + struct acl_role_label *tmp, *tmp2;
62986 +
62987 + curr = &acl_role_set.r_hash[index];
62988 +
62989 + /* simple case, slot is empty, just set it to our role */
62990 + if (*curr == NULL) {
62991 + *curr = role;
62992 + } else {
62993 + /* example:
62994 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
62995 + 2 -> 3
62996 + */
62997 + /* first check to see if we can already be reached via this slot */
62998 + tmp = *curr;
62999 + while (tmp && tmp != role)
63000 + tmp = tmp->next;
63001 + if (tmp == role) {
63002 + /* we don't need to add ourselves to this slot's chain */
63003 + return;
63004 + }
63005 + /* we need to add ourselves to this chain, two cases */
63006 + if (role->next == NULL) {
63007 + /* simple case, append the current chain to our role */
63008 + role->next = *curr;
63009 + *curr = role;
63010 + } else {
63011 + /* 1 -> 2 -> 3 -> 4
63012 + 2 -> 3 -> 4
63013 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63014 + */
63015 + /* trickier case: walk our role's chain until we find
63016 + the role for the start of the current slot's chain */
63017 + tmp = role;
63018 + tmp2 = *curr;
63019 + while (tmp->next && tmp->next != tmp2)
63020 + tmp = tmp->next;
63021 + if (tmp->next == tmp2) {
63022 + /* from example above, we found 3, so just
63023 + replace this slot's chain with ours */
63024 + *curr = role;
63025 + } else {
63026 + /* we didn't find a subset of our role's chain
63027 + in the current slot's chain, so append their
63028 + chain to ours, and set us as the first role in
63029 + the slot's chain
63030 +
63031 + we could fold this case with the case above,
63032 + but making it explicit for clarity
63033 + */
63034 + tmp->next = tmp2;
63035 + *curr = role;
63036 + }
63037 + }
63038 + }
63039 +
63040 + return;
63041 +}
63042 +
63043 +static void
63044 +insert_acl_role_label(struct acl_role_label *role)
63045 +{
63046 + int i;
63047 +
63048 + if (role_list == NULL) {
63049 + role_list = role;
63050 + role->prev = NULL;
63051 + } else {
63052 + role->prev = role_list;
63053 + role_list = role;
63054 + }
63055 +
63056 + /* used for hash chains */
63057 + role->next = NULL;
63058 +
63059 + if (role->roletype & GR_ROLE_DOMAIN) {
63060 + for (i = 0; i < role->domain_child_num; i++)
63061 + __insert_acl_role_label(role, role->domain_children[i]);
63062 + } else
63063 + __insert_acl_role_label(role, role->uidgid);
63064 +}
63065 +
63066 +static int
63067 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63068 +{
63069 + struct name_entry **curr, *nentry;
63070 + struct inodev_entry *ientry;
63071 + unsigned int len = strlen(name);
63072 + unsigned int key = full_name_hash(name, len);
63073 + unsigned int index = key % name_set.n_size;
63074 +
63075 + curr = &name_set.n_hash[index];
63076 +
63077 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63078 + curr = &((*curr)->next);
63079 +
63080 + if (*curr != NULL)
63081 + return 1;
63082 +
63083 + nentry = acl_alloc(sizeof (struct name_entry));
63084 + if (nentry == NULL)
63085 + return 0;
63086 + ientry = acl_alloc(sizeof (struct inodev_entry));
63087 + if (ientry == NULL)
63088 + return 0;
63089 + ientry->nentry = nentry;
63090 +
63091 + nentry->key = key;
63092 + nentry->name = name;
63093 + nentry->inode = inode;
63094 + nentry->device = device;
63095 + nentry->len = len;
63096 + nentry->deleted = deleted;
63097 +
63098 + nentry->prev = NULL;
63099 + curr = &name_set.n_hash[index];
63100 + if (*curr != NULL)
63101 + (*curr)->prev = nentry;
63102 + nentry->next = *curr;
63103 + *curr = nentry;
63104 +
63105 + /* insert us into the table searchable by inode/dev */
63106 + insert_inodev_entry(ientry);
63107 +
63108 + return 1;
63109 +}
63110 +
63111 +static void
63112 +insert_acl_obj_label(struct acl_object_label *obj,
63113 + struct acl_subject_label *subj)
63114 +{
63115 + unsigned int index =
63116 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63117 + struct acl_object_label **curr;
63118 +
63119 +
63120 + obj->prev = NULL;
63121 +
63122 + curr = &subj->obj_hash[index];
63123 + if (*curr != NULL)
63124 + (*curr)->prev = obj;
63125 +
63126 + obj->next = *curr;
63127 + *curr = obj;
63128 +
63129 + return;
63130 +}
63131 +
63132 +static void
63133 +insert_acl_subj_label(struct acl_subject_label *obj,
63134 + struct acl_role_label *role)
63135 +{
63136 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63137 + struct acl_subject_label **curr;
63138 +
63139 + obj->prev = NULL;
63140 +
63141 + curr = &role->subj_hash[index];
63142 + if (*curr != NULL)
63143 + (*curr)->prev = obj;
63144 +
63145 + obj->next = *curr;
63146 + *curr = obj;
63147 +
63148 + return;
63149 +}
63150 +
63151 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63152 +
63153 +static void *
63154 +create_table(__u32 * len, int elementsize)
63155 +{
63156 + unsigned int table_sizes[] = {
63157 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63158 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63159 + 4194301, 8388593, 16777213, 33554393, 67108859
63160 + };
63161 + void *newtable = NULL;
63162 + unsigned int pwr = 0;
63163 +
63164 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63165 + table_sizes[pwr] <= *len)
63166 + pwr++;
63167 +
63168 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63169 + return newtable;
63170 +
63171 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63172 + newtable =
63173 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63174 + else
63175 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63176 +
63177 + *len = table_sizes[pwr];
63178 +
63179 + return newtable;
63180 +}
63181 +
63182 +static int
63183 +init_variables(const struct gr_arg *arg)
63184 +{
63185 + struct task_struct *reaper = init_pid_ns.child_reaper;
63186 + unsigned int stacksize;
63187 +
63188 + subj_map_set.s_size = arg->role_db.num_subjects;
63189 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63190 + name_set.n_size = arg->role_db.num_objects;
63191 + inodev_set.i_size = arg->role_db.num_objects;
63192 +
63193 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63194 + !name_set.n_size || !inodev_set.i_size)
63195 + return 1;
63196 +
63197 + if (!gr_init_uidset())
63198 + return 1;
63199 +
63200 + /* set up the stack that holds allocation info */
63201 +
63202 + stacksize = arg->role_db.num_pointers + 5;
63203 +
63204 + if (!acl_alloc_stack_init(stacksize))
63205 + return 1;
63206 +
63207 + /* grab reference for the real root dentry and vfsmount */
63208 + get_fs_root(reaper->fs, &real_root);
63209 +
63210 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63211 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63212 +#endif
63213 +
63214 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63215 + if (fakefs_obj_rw == NULL)
63216 + return 1;
63217 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63218 +
63219 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63220 + if (fakefs_obj_rwx == NULL)
63221 + return 1;
63222 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63223 +
63224 + subj_map_set.s_hash =
63225 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63226 + acl_role_set.r_hash =
63227 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63228 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63229 + inodev_set.i_hash =
63230 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63231 +
63232 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63233 + !name_set.n_hash || !inodev_set.i_hash)
63234 + return 1;
63235 +
63236 + memset(subj_map_set.s_hash, 0,
63237 + sizeof(struct subject_map *) * subj_map_set.s_size);
63238 + memset(acl_role_set.r_hash, 0,
63239 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63240 + memset(name_set.n_hash, 0,
63241 + sizeof (struct name_entry *) * name_set.n_size);
63242 + memset(inodev_set.i_hash, 0,
63243 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63244 +
63245 + return 0;
63246 +}
63247 +
63248 +/* free information not needed after startup
63249 + currently contains user->kernel pointer mappings for subjects
63250 +*/
63251 +
63252 +static void
63253 +free_init_variables(void)
63254 +{
63255 + __u32 i;
63256 +
63257 + if (subj_map_set.s_hash) {
63258 + for (i = 0; i < subj_map_set.s_size; i++) {
63259 + if (subj_map_set.s_hash[i]) {
63260 + kfree(subj_map_set.s_hash[i]);
63261 + subj_map_set.s_hash[i] = NULL;
63262 + }
63263 + }
63264 +
63265 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63266 + PAGE_SIZE)
63267 + kfree(subj_map_set.s_hash);
63268 + else
63269 + vfree(subj_map_set.s_hash);
63270 + }
63271 +
63272 + return;
63273 +}
63274 +
63275 +static void
63276 +free_variables(void)
63277 +{
63278 + struct acl_subject_label *s;
63279 + struct acl_role_label *r;
63280 + struct task_struct *task, *task2;
63281 + unsigned int x;
63282 +
63283 + gr_clear_learn_entries();
63284 +
63285 + read_lock(&tasklist_lock);
63286 + do_each_thread(task2, task) {
63287 + task->acl_sp_role = 0;
63288 + task->acl_role_id = 0;
63289 + task->acl = NULL;
63290 + task->role = NULL;
63291 + } while_each_thread(task2, task);
63292 + read_unlock(&tasklist_lock);
63293 +
63294 + /* release the reference to the real root dentry and vfsmount */
63295 + path_put(&real_root);
63296 + memset(&real_root, 0, sizeof(real_root));
63297 +
63298 + /* free all object hash tables */
63299 +
63300 + FOR_EACH_ROLE_START(r)
63301 + if (r->subj_hash == NULL)
63302 + goto next_role;
63303 + FOR_EACH_SUBJECT_START(r, s, x)
63304 + if (s->obj_hash == NULL)
63305 + break;
63306 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63307 + kfree(s->obj_hash);
63308 + else
63309 + vfree(s->obj_hash);
63310 + FOR_EACH_SUBJECT_END(s, x)
63311 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63312 + if (s->obj_hash == NULL)
63313 + break;
63314 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63315 + kfree(s->obj_hash);
63316 + else
63317 + vfree(s->obj_hash);
63318 + FOR_EACH_NESTED_SUBJECT_END(s)
63319 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63320 + kfree(r->subj_hash);
63321 + else
63322 + vfree(r->subj_hash);
63323 + r->subj_hash = NULL;
63324 +next_role:
63325 + FOR_EACH_ROLE_END(r)
63326 +
63327 + acl_free_all();
63328 +
63329 + if (acl_role_set.r_hash) {
63330 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63331 + PAGE_SIZE)
63332 + kfree(acl_role_set.r_hash);
63333 + else
63334 + vfree(acl_role_set.r_hash);
63335 + }
63336 + if (name_set.n_hash) {
63337 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63338 + PAGE_SIZE)
63339 + kfree(name_set.n_hash);
63340 + else
63341 + vfree(name_set.n_hash);
63342 + }
63343 +
63344 + if (inodev_set.i_hash) {
63345 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63346 + PAGE_SIZE)
63347 + kfree(inodev_set.i_hash);
63348 + else
63349 + vfree(inodev_set.i_hash);
63350 + }
63351 +
63352 + gr_free_uidset();
63353 +
63354 + memset(&name_set, 0, sizeof (struct name_db));
63355 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63356 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63357 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63358 +
63359 + default_role = NULL;
63360 + kernel_role = NULL;
63361 + role_list = NULL;
63362 +
63363 + return;
63364 +}
63365 +
63366 +static struct acl_subject_label *
63367 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63368 +
63369 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63370 +{
63371 + unsigned int len = strnlen_user(*name, maxlen);
63372 + char *tmp;
63373 +
63374 + if (!len || len >= maxlen)
63375 + return -EINVAL;
63376 +
63377 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63378 + return -ENOMEM;
63379 +
63380 + if (copy_from_user(tmp, *name, len))
63381 + return -EFAULT;
63382 +
63383 + tmp[len-1] = '\0';
63384 + *name = tmp;
63385 +
63386 + return 0;
63387 +}
63388 +
63389 +static int
63390 +copy_user_glob(struct acl_object_label *obj)
63391 +{
63392 + struct acl_object_label *g_tmp, **guser;
63393 + int error;
63394 +
63395 + if (obj->globbed == NULL)
63396 + return 0;
63397 +
63398 + guser = &obj->globbed;
63399 + while (*guser) {
63400 + g_tmp = (struct acl_object_label *)
63401 + acl_alloc(sizeof (struct acl_object_label));
63402 + if (g_tmp == NULL)
63403 + return -ENOMEM;
63404 +
63405 + if (copy_acl_object_label(g_tmp, *guser))
63406 + return -EFAULT;
63407 +
63408 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63409 + if (error)
63410 + return error;
63411 +
63412 + *guser = g_tmp;
63413 + guser = &(g_tmp->next);
63414 + }
63415 +
63416 + return 0;
63417 +}
63418 +
63419 +static int
63420 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63421 + struct acl_role_label *role)
63422 +{
63423 + struct acl_object_label *o_tmp;
63424 + int ret;
63425 +
63426 + while (userp) {
63427 + if ((o_tmp = (struct acl_object_label *)
63428 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63429 + return -ENOMEM;
63430 +
63431 + if (copy_acl_object_label(o_tmp, userp))
63432 + return -EFAULT;
63433 +
63434 + userp = o_tmp->prev;
63435 +
63436 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63437 + if (ret)
63438 + return ret;
63439 +
63440 + insert_acl_obj_label(o_tmp, subj);
63441 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63442 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63443 + return -ENOMEM;
63444 +
63445 + ret = copy_user_glob(o_tmp);
63446 + if (ret)
63447 + return ret;
63448 +
63449 + if (o_tmp->nested) {
63450 + int already_copied;
63451 +
63452 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63453 + if (IS_ERR(o_tmp->nested))
63454 + return PTR_ERR(o_tmp->nested);
63455 +
63456 + /* insert into nested subject list if we haven't copied this one yet
63457 + to prevent duplicate entries */
63458 + if (!already_copied) {
63459 + o_tmp->nested->next = role->hash->first;
63460 + role->hash->first = o_tmp->nested;
63461 + }
63462 + }
63463 + }
63464 +
63465 + return 0;
63466 +}
63467 +
63468 +static __u32
63469 +count_user_subjs(struct acl_subject_label *userp)
63470 +{
63471 + struct acl_subject_label s_tmp;
63472 + __u32 num = 0;
63473 +
63474 + while (userp) {
63475 + if (copy_acl_subject_label(&s_tmp, userp))
63476 + break;
63477 +
63478 + userp = s_tmp.prev;
63479 + }
63480 +
63481 + return num;
63482 +}
63483 +
63484 +static int
63485 +copy_user_allowedips(struct acl_role_label *rolep)
63486 +{
63487 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63488 +
63489 + ruserip = rolep->allowed_ips;
63490 +
63491 + while (ruserip) {
63492 + rlast = rtmp;
63493 +
63494 + if ((rtmp = (struct role_allowed_ip *)
63495 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63496 + return -ENOMEM;
63497 +
63498 + if (copy_role_allowed_ip(rtmp, ruserip))
63499 + return -EFAULT;
63500 +
63501 + ruserip = rtmp->prev;
63502 +
63503 + if (!rlast) {
63504 + rtmp->prev = NULL;
63505 + rolep->allowed_ips = rtmp;
63506 + } else {
63507 + rlast->next = rtmp;
63508 + rtmp->prev = rlast;
63509 + }
63510 +
63511 + if (!ruserip)
63512 + rtmp->next = NULL;
63513 + }
63514 +
63515 + return 0;
63516 +}
63517 +
63518 +static int
63519 +copy_user_transitions(struct acl_role_label *rolep)
63520 +{
63521 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63522 + int error;
63523 +
63524 + rusertp = rolep->transitions;
63525 +
63526 + while (rusertp) {
63527 + rlast = rtmp;
63528 +
63529 + if ((rtmp = (struct role_transition *)
63530 + acl_alloc(sizeof (struct role_transition))) == NULL)
63531 + return -ENOMEM;
63532 +
63533 + if (copy_role_transition(rtmp, rusertp))
63534 + return -EFAULT;
63535 +
63536 + rusertp = rtmp->prev;
63537 +
63538 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63539 + if (error)
63540 + return error;
63541 +
63542 + if (!rlast) {
63543 + rtmp->prev = NULL;
63544 + rolep->transitions = rtmp;
63545 + } else {
63546 + rlast->next = rtmp;
63547 + rtmp->prev = rlast;
63548 + }
63549 +
63550 + if (!rusertp)
63551 + rtmp->next = NULL;
63552 + }
63553 +
63554 + return 0;
63555 +}
63556 +
63557 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63558 +{
63559 + struct acl_object_label o_tmp;
63560 + __u32 num = 0;
63561 +
63562 + while (userp) {
63563 + if (copy_acl_object_label(&o_tmp, userp))
63564 + break;
63565 +
63566 + userp = o_tmp.prev;
63567 + num++;
63568 + }
63569 +
63570 + return num;
63571 +}
63572 +
63573 +static struct acl_subject_label *
63574 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63575 +{
63576 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63577 + __u32 num_objs;
63578 + struct acl_ip_label **i_tmp, *i_utmp2;
63579 + struct gr_hash_struct ghash;
63580 + struct subject_map *subjmap;
63581 + unsigned int i_num;
63582 + int err;
63583 +
63584 + if (already_copied != NULL)
63585 + *already_copied = 0;
63586 +
63587 + s_tmp = lookup_subject_map(userp);
63588 +
63589 + /* we've already copied this subject into the kernel, just return
63590 + the reference to it, and don't copy it over again
63591 + */
63592 + if (s_tmp) {
63593 + if (already_copied != NULL)
63594 + *already_copied = 1;
63595 + return(s_tmp);
63596 + }
63597 +
63598 + if ((s_tmp = (struct acl_subject_label *)
63599 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63600 + return ERR_PTR(-ENOMEM);
63601 +
63602 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63603 + if (subjmap == NULL)
63604 + return ERR_PTR(-ENOMEM);
63605 +
63606 + subjmap->user = userp;
63607 + subjmap->kernel = s_tmp;
63608 + insert_subj_map_entry(subjmap);
63609 +
63610 + if (copy_acl_subject_label(s_tmp, userp))
63611 + return ERR_PTR(-EFAULT);
63612 +
63613 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63614 + if (err)
63615 + return ERR_PTR(err);
63616 +
63617 + if (!strcmp(s_tmp->filename, "/"))
63618 + role->root_label = s_tmp;
63619 +
63620 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63621 + return ERR_PTR(-EFAULT);
63622 +
63623 + /* copy user and group transition tables */
63624 +
63625 + if (s_tmp->user_trans_num) {
63626 + uid_t *uidlist;
63627 +
63628 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63629 + if (uidlist == NULL)
63630 + return ERR_PTR(-ENOMEM);
63631 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63632 + return ERR_PTR(-EFAULT);
63633 +
63634 + s_tmp->user_transitions = uidlist;
63635 + }
63636 +
63637 + if (s_tmp->group_trans_num) {
63638 + gid_t *gidlist;
63639 +
63640 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63641 + if (gidlist == NULL)
63642 + return ERR_PTR(-ENOMEM);
63643 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63644 + return ERR_PTR(-EFAULT);
63645 +
63646 + s_tmp->group_transitions = gidlist;
63647 + }
63648 +
63649 + /* set up object hash table */
63650 + num_objs = count_user_objs(ghash.first);
63651 +
63652 + s_tmp->obj_hash_size = num_objs;
63653 + s_tmp->obj_hash =
63654 + (struct acl_object_label **)
63655 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63656 +
63657 + if (!s_tmp->obj_hash)
63658 + return ERR_PTR(-ENOMEM);
63659 +
63660 + memset(s_tmp->obj_hash, 0,
63661 + s_tmp->obj_hash_size *
63662 + sizeof (struct acl_object_label *));
63663 +
63664 + /* add in objects */
63665 + err = copy_user_objs(ghash.first, s_tmp, role);
63666 +
63667 + if (err)
63668 + return ERR_PTR(err);
63669 +
63670 + /* set pointer for parent subject */
63671 + if (s_tmp->parent_subject) {
63672 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63673 +
63674 + if (IS_ERR(s_tmp2))
63675 + return s_tmp2;
63676 +
63677 + s_tmp->parent_subject = s_tmp2;
63678 + }
63679 +
63680 + /* add in ip acls */
63681 +
63682 + if (!s_tmp->ip_num) {
63683 + s_tmp->ips = NULL;
63684 + goto insert;
63685 + }
63686 +
63687 + i_tmp =
63688 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63689 + sizeof (struct acl_ip_label *));
63690 +
63691 + if (!i_tmp)
63692 + return ERR_PTR(-ENOMEM);
63693 +
63694 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63695 + *(i_tmp + i_num) =
63696 + (struct acl_ip_label *)
63697 + acl_alloc(sizeof (struct acl_ip_label));
63698 + if (!*(i_tmp + i_num))
63699 + return ERR_PTR(-ENOMEM);
63700 +
63701 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63702 + return ERR_PTR(-EFAULT);
63703 +
63704 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63705 + return ERR_PTR(-EFAULT);
63706 +
63707 + if ((*(i_tmp + i_num))->iface == NULL)
63708 + continue;
63709 +
63710 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63711 + if (err)
63712 + return ERR_PTR(err);
63713 + }
63714 +
63715 + s_tmp->ips = i_tmp;
63716 +
63717 +insert:
63718 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63719 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63720 + return ERR_PTR(-ENOMEM);
63721 +
63722 + return s_tmp;
63723 +}
63724 +
63725 +static int
63726 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63727 +{
63728 + struct acl_subject_label s_pre;
63729 + struct acl_subject_label * ret;
63730 + int err;
63731 +
63732 + while (userp) {
63733 + if (copy_acl_subject_label(&s_pre, userp))
63734 + return -EFAULT;
63735 +
63736 + ret = do_copy_user_subj(userp, role, NULL);
63737 +
63738 + err = PTR_ERR(ret);
63739 + if (IS_ERR(ret))
63740 + return err;
63741 +
63742 + insert_acl_subj_label(ret, role);
63743 +
63744 + userp = s_pre.prev;
63745 + }
63746 +
63747 + return 0;
63748 +}
63749 +
63750 +static int
63751 +copy_user_acl(struct gr_arg *arg)
63752 +{
63753 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63754 + struct acl_subject_label *subj_list;
63755 + struct sprole_pw *sptmp;
63756 + struct gr_hash_struct *ghash;
63757 + uid_t *domainlist;
63758 + unsigned int r_num;
63759 + int err = 0;
63760 + __u16 i;
63761 + __u32 num_subjs;
63762 +
63763 + /* we need a default and kernel role */
63764 + if (arg->role_db.num_roles < 2)
63765 + return -EINVAL;
63766 +
63767 + /* copy special role authentication info from userspace */
63768 +
63769 + num_sprole_pws = arg->num_sprole_pws;
63770 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63771 +
63772 + if (!acl_special_roles && num_sprole_pws)
63773 + return -ENOMEM;
63774 +
63775 + for (i = 0; i < num_sprole_pws; i++) {
63776 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63777 + if (!sptmp)
63778 + return -ENOMEM;
63779 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63780 + return -EFAULT;
63781 +
63782 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63783 + if (err)
63784 + return err;
63785 +
63786 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63787 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63788 +#endif
63789 +
63790 + acl_special_roles[i] = sptmp;
63791 + }
63792 +
63793 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63794 +
63795 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63796 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63797 +
63798 + if (!r_tmp)
63799 + return -ENOMEM;
63800 +
63801 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63802 + return -EFAULT;
63803 +
63804 + if (copy_acl_role_label(r_tmp, r_utmp2))
63805 + return -EFAULT;
63806 +
63807 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63808 + if (err)
63809 + return err;
63810 +
63811 + if (!strcmp(r_tmp->rolename, "default")
63812 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63813 + default_role = r_tmp;
63814 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63815 + kernel_role = r_tmp;
63816 + }
63817 +
63818 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63819 + return -ENOMEM;
63820 +
63821 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63822 + return -EFAULT;
63823 +
63824 + r_tmp->hash = ghash;
63825 +
63826 + num_subjs = count_user_subjs(r_tmp->hash->first);
63827 +
63828 + r_tmp->subj_hash_size = num_subjs;
63829 + r_tmp->subj_hash =
63830 + (struct acl_subject_label **)
63831 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63832 +
63833 + if (!r_tmp->subj_hash)
63834 + return -ENOMEM;
63835 +
63836 + err = copy_user_allowedips(r_tmp);
63837 + if (err)
63838 + return err;
63839 +
63840 + /* copy domain info */
63841 + if (r_tmp->domain_children != NULL) {
63842 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63843 + if (domainlist == NULL)
63844 + return -ENOMEM;
63845 +
63846 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63847 + return -EFAULT;
63848 +
63849 + r_tmp->domain_children = domainlist;
63850 + }
63851 +
63852 + err = copy_user_transitions(r_tmp);
63853 + if (err)
63854 + return err;
63855 +
63856 + memset(r_tmp->subj_hash, 0,
63857 + r_tmp->subj_hash_size *
63858 + sizeof (struct acl_subject_label *));
63859 +
63860 + /* acquire the list of subjects, then NULL out
63861 + the list prior to parsing the subjects for this role,
63862 + as during this parsing the list is replaced with a list
63863 + of *nested* subjects for the role
63864 + */
63865 + subj_list = r_tmp->hash->first;
63866 +
63867 + /* set nested subject list to null */
63868 + r_tmp->hash->first = NULL;
63869 +
63870 + err = copy_user_subjs(subj_list, r_tmp);
63871 +
63872 + if (err)
63873 + return err;
63874 +
63875 + insert_acl_role_label(r_tmp);
63876 + }
63877 +
63878 + if (default_role == NULL || kernel_role == NULL)
63879 + return -EINVAL;
63880 +
63881 + return err;
63882 +}
63883 +
63884 +static int
63885 +gracl_init(struct gr_arg *args)
63886 +{
63887 + int error = 0;
63888 +
63889 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63890 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63891 +
63892 + if (init_variables(args)) {
63893 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63894 + error = -ENOMEM;
63895 + free_variables();
63896 + goto out;
63897 + }
63898 +
63899 + error = copy_user_acl(args);
63900 + free_init_variables();
63901 + if (error) {
63902 + free_variables();
63903 + goto out;
63904 + }
63905 +
63906 + if ((error = gr_set_acls(0))) {
63907 + free_variables();
63908 + goto out;
63909 + }
63910 +
63911 + pax_open_kernel();
63912 + gr_status |= GR_READY;
63913 + pax_close_kernel();
63914 +
63915 + out:
63916 + return error;
63917 +}
63918 +
63919 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63920 +
63921 +static int
63922 +glob_match(const char *p, const char *n)
63923 +{
63924 + char c;
63925 +
63926 + while ((c = *p++) != '\0') {
63927 + switch (c) {
63928 + case '?':
63929 + if (*n == '\0')
63930 + return 1;
63931 + else if (*n == '/')
63932 + return 1;
63933 + break;
63934 + case '\\':
63935 + if (*n != c)
63936 + return 1;
63937 + break;
63938 + case '*':
63939 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63940 + if (*n == '/')
63941 + return 1;
63942 + else if (c == '?') {
63943 + if (*n == '\0')
63944 + return 1;
63945 + else
63946 + ++n;
63947 + }
63948 + }
63949 + if (c == '\0') {
63950 + return 0;
63951 + } else {
63952 + const char *endp;
63953 +
63954 + if ((endp = strchr(n, '/')) == NULL)
63955 + endp = n + strlen(n);
63956 +
63957 + if (c == '[') {
63958 + for (--p; n < endp; ++n)
63959 + if (!glob_match(p, n))
63960 + return 0;
63961 + } else if (c == '/') {
63962 + while (*n != '\0' && *n != '/')
63963 + ++n;
63964 + if (*n == '/' && !glob_match(p, n + 1))
63965 + return 0;
63966 + } else {
63967 + for (--p; n < endp; ++n)
63968 + if (*n == c && !glob_match(p, n))
63969 + return 0;
63970 + }
63971 +
63972 + return 1;
63973 + }
63974 + case '[':
63975 + {
63976 + int not;
63977 + char cold;
63978 +
63979 + if (*n == '\0' || *n == '/')
63980 + return 1;
63981 +
63982 + not = (*p == '!' || *p == '^');
63983 + if (not)
63984 + ++p;
63985 +
63986 + c = *p++;
63987 + for (;;) {
63988 + unsigned char fn = (unsigned char)*n;
63989 +
63990 + if (c == '\0')
63991 + return 1;
63992 + else {
63993 + if (c == fn)
63994 + goto matched;
63995 + cold = c;
63996 + c = *p++;
63997 +
63998 + if (c == '-' && *p != ']') {
63999 + unsigned char cend = *p++;
64000 +
64001 + if (cend == '\0')
64002 + return 1;
64003 +
64004 + if (cold <= fn && fn <= cend)
64005 + goto matched;
64006 +
64007 + c = *p++;
64008 + }
64009 + }
64010 +
64011 + if (c == ']')
64012 + break;
64013 + }
64014 + if (!not)
64015 + return 1;
64016 + break;
64017 + matched:
64018 + while (c != ']') {
64019 + if (c == '\0')
64020 + return 1;
64021 +
64022 + c = *p++;
64023 + }
64024 + if (not)
64025 + return 1;
64026 + }
64027 + break;
64028 + default:
64029 + if (c != *n)
64030 + return 1;
64031 + }
64032 +
64033 + ++n;
64034 + }
64035 +
64036 + if (*n == '\0')
64037 + return 0;
64038 +
64039 + if (*n == '/')
64040 + return 0;
64041 +
64042 + return 1;
64043 +}
64044 +
64045 +static struct acl_object_label *
64046 +chk_glob_label(struct acl_object_label *globbed,
64047 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64048 +{
64049 + struct acl_object_label *tmp;
64050 +
64051 + if (*path == NULL)
64052 + *path = gr_to_filename_nolock(dentry, mnt);
64053 +
64054 + tmp = globbed;
64055 +
64056 + while (tmp) {
64057 + if (!glob_match(tmp->filename, *path))
64058 + return tmp;
64059 + tmp = tmp->next;
64060 + }
64061 +
64062 + return NULL;
64063 +}
64064 +
64065 +static struct acl_object_label *
64066 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64067 + const ino_t curr_ino, const dev_t curr_dev,
64068 + const struct acl_subject_label *subj, char **path, const int checkglob)
64069 +{
64070 + struct acl_subject_label *tmpsubj;
64071 + struct acl_object_label *retval;
64072 + struct acl_object_label *retval2;
64073 +
64074 + tmpsubj = (struct acl_subject_label *) subj;
64075 + read_lock(&gr_inode_lock);
64076 + do {
64077 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64078 + if (retval) {
64079 + if (checkglob && retval->globbed) {
64080 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64081 + if (retval2)
64082 + retval = retval2;
64083 + }
64084 + break;
64085 + }
64086 + } while ((tmpsubj = tmpsubj->parent_subject));
64087 + read_unlock(&gr_inode_lock);
64088 +
64089 + return retval;
64090 +}
64091 +
64092 +static __inline__ struct acl_object_label *
64093 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64094 + struct dentry *curr_dentry,
64095 + const struct acl_subject_label *subj, char **path, const int checkglob)
64096 +{
64097 + int newglob = checkglob;
64098 + ino_t inode;
64099 + dev_t device;
64100 +
64101 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64102 + as we don't want a / * rule to match instead of the / object
64103 + don't do this for create lookups that call this function though, since they're looking up
64104 + on the parent and thus need globbing checks on all paths
64105 + */
64106 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64107 + newglob = GR_NO_GLOB;
64108 +
64109 + spin_lock(&curr_dentry->d_lock);
64110 + inode = curr_dentry->d_inode->i_ino;
64111 + device = __get_dev(curr_dentry);
64112 + spin_unlock(&curr_dentry->d_lock);
64113 +
64114 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64115 +}
64116 +
64117 +#ifdef CONFIG_HUGETLBFS
64118 +static inline bool
64119 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64120 +{
64121 + int i;
64122 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64123 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64124 + return true;
64125 + }
64126 +
64127 + return false;
64128 +}
64129 +#endif
64130 +
64131 +static struct acl_object_label *
64132 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64133 + const struct acl_subject_label *subj, char *path, const int checkglob)
64134 +{
64135 + struct dentry *dentry = (struct dentry *) l_dentry;
64136 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64137 + struct mount *real_mnt = real_mount(mnt);
64138 + struct acl_object_label *retval;
64139 + struct dentry *parent;
64140 +
64141 + br_read_lock(&vfsmount_lock);
64142 + write_seqlock(&rename_lock);
64143 +
64144 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64145 +#ifdef CONFIG_NET
64146 + mnt == sock_mnt ||
64147 +#endif
64148 +#ifdef CONFIG_HUGETLBFS
64149 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64150 +#endif
64151 + /* ignore Eric Biederman */
64152 + IS_PRIVATE(l_dentry->d_inode))) {
64153 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64154 + goto out;
64155 + }
64156 +
64157 + for (;;) {
64158 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64159 + break;
64160 +
64161 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64162 + if (!mnt_has_parent(real_mnt))
64163 + break;
64164 +
64165 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64166 + if (retval != NULL)
64167 + goto out;
64168 +
64169 + dentry = real_mnt->mnt_mountpoint;
64170 + real_mnt = real_mnt->mnt_parent;
64171 + mnt = &real_mnt->mnt;
64172 + continue;
64173 + }
64174 +
64175 + parent = dentry->d_parent;
64176 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64177 + if (retval != NULL)
64178 + goto out;
64179 +
64180 + dentry = parent;
64181 + }
64182 +
64183 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64184 +
64185 + /* real_root is pinned so we don't have to hold a reference */
64186 + if (retval == NULL)
64187 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64188 +out:
64189 + write_sequnlock(&rename_lock);
64190 + br_read_unlock(&vfsmount_lock);
64191 +
64192 + BUG_ON(retval == NULL);
64193 +
64194 + return retval;
64195 +}
64196 +
64197 +static __inline__ struct acl_object_label *
64198 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64199 + const struct acl_subject_label *subj)
64200 +{
64201 + char *path = NULL;
64202 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64203 +}
64204 +
64205 +static __inline__ struct acl_object_label *
64206 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64207 + const struct acl_subject_label *subj)
64208 +{
64209 + char *path = NULL;
64210 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64211 +}
64212 +
64213 +static __inline__ struct acl_object_label *
64214 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64215 + const struct acl_subject_label *subj, char *path)
64216 +{
64217 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64218 +}
64219 +
64220 +static struct acl_subject_label *
64221 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64222 + const struct acl_role_label *role)
64223 +{
64224 + struct dentry *dentry = (struct dentry *) l_dentry;
64225 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64226 + struct mount *real_mnt = real_mount(mnt);
64227 + struct acl_subject_label *retval;
64228 + struct dentry *parent;
64229 +
64230 + br_read_lock(&vfsmount_lock);
64231 + write_seqlock(&rename_lock);
64232 +
64233 + for (;;) {
64234 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64235 + break;
64236 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64237 + if (!mnt_has_parent(real_mnt))
64238 + break;
64239 +
64240 + spin_lock(&dentry->d_lock);
64241 + read_lock(&gr_inode_lock);
64242 + retval =
64243 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64244 + __get_dev(dentry), role);
64245 + read_unlock(&gr_inode_lock);
64246 + spin_unlock(&dentry->d_lock);
64247 + if (retval != NULL)
64248 + goto out;
64249 +
64250 + dentry = real_mnt->mnt_mountpoint;
64251 + real_mnt = real_mnt->mnt_parent;
64252 + mnt = &real_mnt->mnt;
64253 + continue;
64254 + }
64255 +
64256 + spin_lock(&dentry->d_lock);
64257 + read_lock(&gr_inode_lock);
64258 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64259 + __get_dev(dentry), role);
64260 + read_unlock(&gr_inode_lock);
64261 + parent = dentry->d_parent;
64262 + spin_unlock(&dentry->d_lock);
64263 +
64264 + if (retval != NULL)
64265 + goto out;
64266 +
64267 + dentry = parent;
64268 + }
64269 +
64270 + spin_lock(&dentry->d_lock);
64271 + read_lock(&gr_inode_lock);
64272 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64273 + __get_dev(dentry), role);
64274 + read_unlock(&gr_inode_lock);
64275 + spin_unlock(&dentry->d_lock);
64276 +
64277 + if (unlikely(retval == NULL)) {
64278 + /* real_root is pinned, we don't need to hold a reference */
64279 + read_lock(&gr_inode_lock);
64280 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64281 + __get_dev(real_root.dentry), role);
64282 + read_unlock(&gr_inode_lock);
64283 + }
64284 +out:
64285 + write_sequnlock(&rename_lock);
64286 + br_read_unlock(&vfsmount_lock);
64287 +
64288 + BUG_ON(retval == NULL);
64289 +
64290 + return retval;
64291 +}
64292 +
64293 +static void
64294 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64295 +{
64296 + struct task_struct *task = current;
64297 + const struct cred *cred = current_cred();
64298 +
64299 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64300 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64301 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64302 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64303 +
64304 + return;
64305 +}
64306 +
64307 +static void
64308 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64309 +{
64310 + struct task_struct *task = current;
64311 + const struct cred *cred = current_cred();
64312 +
64313 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64314 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64315 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64316 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64317 +
64318 + return;
64319 +}
64320 +
64321 +static void
64322 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64323 +{
64324 + struct task_struct *task = current;
64325 + const struct cred *cred = current_cred();
64326 +
64327 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64328 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64329 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64330 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64331 +
64332 + return;
64333 +}
64334 +
64335 +__u32
64336 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64337 + const struct vfsmount * mnt)
64338 +{
64339 + __u32 retval = mode;
64340 + struct acl_subject_label *curracl;
64341 + struct acl_object_label *currobj;
64342 +
64343 + if (unlikely(!(gr_status & GR_READY)))
64344 + return (mode & ~GR_AUDITS);
64345 +
64346 + curracl = current->acl;
64347 +
64348 + currobj = chk_obj_label(dentry, mnt, curracl);
64349 + retval = currobj->mode & mode;
64350 +
64351 + /* if we're opening a specified transfer file for writing
64352 + (e.g. /dev/initctl), then transfer our role to init
64353 + */
64354 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64355 + current->role->roletype & GR_ROLE_PERSIST)) {
64356 + struct task_struct *task = init_pid_ns.child_reaper;
64357 +
64358 + if (task->role != current->role) {
64359 + task->acl_sp_role = 0;
64360 + task->acl_role_id = current->acl_role_id;
64361 + task->role = current->role;
64362 + rcu_read_lock();
64363 + read_lock(&grsec_exec_file_lock);
64364 + gr_apply_subject_to_task(task);
64365 + read_unlock(&grsec_exec_file_lock);
64366 + rcu_read_unlock();
64367 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64368 + }
64369 + }
64370 +
64371 + if (unlikely
64372 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64373 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64374 + __u32 new_mode = mode;
64375 +
64376 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64377 +
64378 + retval = new_mode;
64379 +
64380 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64381 + new_mode |= GR_INHERIT;
64382 +
64383 + if (!(mode & GR_NOLEARN))
64384 + gr_log_learn(dentry, mnt, new_mode);
64385 + }
64386 +
64387 + return retval;
64388 +}
64389 +
64390 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64391 + const struct dentry *parent,
64392 + const struct vfsmount *mnt)
64393 +{
64394 + struct name_entry *match;
64395 + struct acl_object_label *matchpo;
64396 + struct acl_subject_label *curracl;
64397 + char *path;
64398 +
64399 + if (unlikely(!(gr_status & GR_READY)))
64400 + return NULL;
64401 +
64402 + preempt_disable();
64403 + path = gr_to_filename_rbac(new_dentry, mnt);
64404 + match = lookup_name_entry_create(path);
64405 +
64406 + curracl = current->acl;
64407 +
64408 + if (match) {
64409 + read_lock(&gr_inode_lock);
64410 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64411 + read_unlock(&gr_inode_lock);
64412 +
64413 + if (matchpo) {
64414 + preempt_enable();
64415 + return matchpo;
64416 + }
64417 + }
64418 +
64419 + // lookup parent
64420 +
64421 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64422 +
64423 + preempt_enable();
64424 + return matchpo;
64425 +}
64426 +
64427 +__u32
64428 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64429 + const struct vfsmount * mnt, const __u32 mode)
64430 +{
64431 + struct acl_object_label *matchpo;
64432 + __u32 retval;
64433 +
64434 + if (unlikely(!(gr_status & GR_READY)))
64435 + return (mode & ~GR_AUDITS);
64436 +
64437 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64438 +
64439 + retval = matchpo->mode & mode;
64440 +
64441 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64442 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64443 + __u32 new_mode = mode;
64444 +
64445 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64446 +
64447 + gr_log_learn(new_dentry, mnt, new_mode);
64448 + return new_mode;
64449 + }
64450 +
64451 + return retval;
64452 +}
64453 +
64454 +__u32
64455 +gr_check_link(const struct dentry * new_dentry,
64456 + const struct dentry * parent_dentry,
64457 + const struct vfsmount * parent_mnt,
64458 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64459 +{
64460 + struct acl_object_label *obj;
64461 + __u32 oldmode, newmode;
64462 + __u32 needmode;
64463 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64464 + GR_DELETE | GR_INHERIT;
64465 +
64466 + if (unlikely(!(gr_status & GR_READY)))
64467 + return (GR_CREATE | GR_LINK);
64468 +
64469 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64470 + oldmode = obj->mode;
64471 +
64472 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64473 + newmode = obj->mode;
64474 +
64475 + needmode = newmode & checkmodes;
64476 +
64477 + // old name for hardlink must have at least the permissions of the new name
64478 + if ((oldmode & needmode) != needmode)
64479 + goto bad;
64480 +
64481 + // if old name had restrictions/auditing, make sure the new name does as well
64482 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64483 +
64484 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64485 + if (is_privileged_binary(old_dentry))
64486 + needmode |= GR_SETID;
64487 +
64488 + if ((newmode & needmode) != needmode)
64489 + goto bad;
64490 +
64491 + // enforce minimum permissions
64492 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64493 + return newmode;
64494 +bad:
64495 + needmode = oldmode;
64496 + if (is_privileged_binary(old_dentry))
64497 + needmode |= GR_SETID;
64498 +
64499 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64500 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64501 + return (GR_CREATE | GR_LINK);
64502 + } else if (newmode & GR_SUPPRESS)
64503 + return GR_SUPPRESS;
64504 + else
64505 + return 0;
64506 +}
64507 +
64508 +int
64509 +gr_check_hidden_task(const struct task_struct *task)
64510 +{
64511 + if (unlikely(!(gr_status & GR_READY)))
64512 + return 0;
64513 +
64514 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64515 + return 1;
64516 +
64517 + return 0;
64518 +}
64519 +
64520 +int
64521 +gr_check_protected_task(const struct task_struct *task)
64522 +{
64523 + if (unlikely(!(gr_status & GR_READY) || !task))
64524 + return 0;
64525 +
64526 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64527 + task->acl != current->acl)
64528 + return 1;
64529 +
64530 + return 0;
64531 +}
64532 +
64533 +int
64534 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64535 +{
64536 + struct task_struct *p;
64537 + int ret = 0;
64538 +
64539 + if (unlikely(!(gr_status & GR_READY) || !pid))
64540 + return ret;
64541 +
64542 + read_lock(&tasklist_lock);
64543 + do_each_pid_task(pid, type, p) {
64544 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64545 + p->acl != current->acl) {
64546 + ret = 1;
64547 + goto out;
64548 + }
64549 + } while_each_pid_task(pid, type, p);
64550 +out:
64551 + read_unlock(&tasklist_lock);
64552 +
64553 + return ret;
64554 +}
64555 +
64556 +void
64557 +gr_copy_label(struct task_struct *tsk)
64558 +{
64559 + tsk->signal->used_accept = 0;
64560 + tsk->acl_sp_role = 0;
64561 + tsk->acl_role_id = current->acl_role_id;
64562 + tsk->acl = current->acl;
64563 + tsk->role = current->role;
64564 + tsk->signal->curr_ip = current->signal->curr_ip;
64565 + tsk->signal->saved_ip = current->signal->saved_ip;
64566 + if (current->exec_file)
64567 + get_file(current->exec_file);
64568 + tsk->exec_file = current->exec_file;
64569 + tsk->is_writable = current->is_writable;
64570 + if (unlikely(current->signal->used_accept)) {
64571 + current->signal->curr_ip = 0;
64572 + current->signal->saved_ip = 0;
64573 + }
64574 +
64575 + return;
64576 +}
64577 +
64578 +static void
64579 +gr_set_proc_res(struct task_struct *task)
64580 +{
64581 + struct acl_subject_label *proc;
64582 + unsigned short i;
64583 +
64584 + proc = task->acl;
64585 +
64586 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64587 + return;
64588 +
64589 + for (i = 0; i < RLIM_NLIMITS; i++) {
64590 + if (!(proc->resmask & (1U << i)))
64591 + continue;
64592 +
64593 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64594 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64595 +
64596 + if (i == RLIMIT_CPU)
64597 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64598 + }
64599 +
64600 + return;
64601 +}
64602 +
64603 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64604 +
64605 +int
64606 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64607 +{
64608 + unsigned int i;
64609 + __u16 num;
64610 + uid_t *uidlist;
64611 + uid_t curuid;
64612 + int realok = 0;
64613 + int effectiveok = 0;
64614 + int fsok = 0;
64615 + uid_t globalreal, globaleffective, globalfs;
64616 +
64617 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64618 + struct user_struct *user;
64619 +
64620 + if (!uid_valid(real))
64621 + goto skipit;
64622 +
64623 + /* find user based on global namespace */
64624 +
64625 + globalreal = GR_GLOBAL_UID(real);
64626 +
64627 + user = find_user(make_kuid(&init_user_ns, globalreal));
64628 + if (user == NULL)
64629 + goto skipit;
64630 +
64631 + if (gr_process_kernel_setuid_ban(user)) {
64632 + /* for find_user */
64633 + free_uid(user);
64634 + return 1;
64635 + }
64636 +
64637 + /* for find_user */
64638 + free_uid(user);
64639 +
64640 +skipit:
64641 +#endif
64642 +
64643 + if (unlikely(!(gr_status & GR_READY)))
64644 + return 0;
64645 +
64646 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64647 + gr_log_learn_uid_change(real, effective, fs);
64648 +
64649 + num = current->acl->user_trans_num;
64650 + uidlist = current->acl->user_transitions;
64651 +
64652 + if (uidlist == NULL)
64653 + return 0;
64654 +
64655 + if (!uid_valid(real)) {
64656 + realok = 1;
64657 + globalreal = (uid_t)-1;
64658 + } else {
64659 + globalreal = GR_GLOBAL_UID(real);
64660 + }
64661 + if (!uid_valid(effective)) {
64662 + effectiveok = 1;
64663 + globaleffective = (uid_t)-1;
64664 + } else {
64665 + globaleffective = GR_GLOBAL_UID(effective);
64666 + }
64667 + if (!uid_valid(fs)) {
64668 + fsok = 1;
64669 + globalfs = (uid_t)-1;
64670 + } else {
64671 + globalfs = GR_GLOBAL_UID(fs);
64672 + }
64673 +
64674 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64675 + for (i = 0; i < num; i++) {
64676 + curuid = uidlist[i];
64677 + if (globalreal == curuid)
64678 + realok = 1;
64679 + if (globaleffective == curuid)
64680 + effectiveok = 1;
64681 + if (globalfs == curuid)
64682 + fsok = 1;
64683 + }
64684 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64685 + for (i = 0; i < num; i++) {
64686 + curuid = uidlist[i];
64687 + if (globalreal == curuid)
64688 + break;
64689 + if (globaleffective == curuid)
64690 + break;
64691 + if (globalfs == curuid)
64692 + break;
64693 + }
64694 + /* not in deny list */
64695 + if (i == num) {
64696 + realok = 1;
64697 + effectiveok = 1;
64698 + fsok = 1;
64699 + }
64700 + }
64701 +
64702 + if (realok && effectiveok && fsok)
64703 + return 0;
64704 + else {
64705 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64706 + return 1;
64707 + }
64708 +}
64709 +
64710 +int
64711 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64712 +{
64713 + unsigned int i;
64714 + __u16 num;
64715 + gid_t *gidlist;
64716 + gid_t curgid;
64717 + int realok = 0;
64718 + int effectiveok = 0;
64719 + int fsok = 0;
64720 + gid_t globalreal, globaleffective, globalfs;
64721 +
64722 + if (unlikely(!(gr_status & GR_READY)))
64723 + return 0;
64724 +
64725 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64726 + gr_log_learn_gid_change(real, effective, fs);
64727 +
64728 + num = current->acl->group_trans_num;
64729 + gidlist = current->acl->group_transitions;
64730 +
64731 + if (gidlist == NULL)
64732 + return 0;
64733 +
64734 + if (!gid_valid(real)) {
64735 + realok = 1;
64736 + globalreal = (gid_t)-1;
64737 + } else {
64738 + globalreal = GR_GLOBAL_GID(real);
64739 + }
64740 + if (!gid_valid(effective)) {
64741 + effectiveok = 1;
64742 + globaleffective = (gid_t)-1;
64743 + } else {
64744 + globaleffective = GR_GLOBAL_GID(effective);
64745 + }
64746 + if (!gid_valid(fs)) {
64747 + fsok = 1;
64748 + globalfs = (gid_t)-1;
64749 + } else {
64750 + globalfs = GR_GLOBAL_GID(fs);
64751 + }
64752 +
64753 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64754 + for (i = 0; i < num; i++) {
64755 + curgid = gidlist[i];
64756 + if (globalreal == curgid)
64757 + realok = 1;
64758 + if (globaleffective == curgid)
64759 + effectiveok = 1;
64760 + if (globalfs == curgid)
64761 + fsok = 1;
64762 + }
64763 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64764 + for (i = 0; i < num; i++) {
64765 + curgid = gidlist[i];
64766 + if (globalreal == curgid)
64767 + break;
64768 + if (globaleffective == curgid)
64769 + break;
64770 + if (globalfs == curgid)
64771 + break;
64772 + }
64773 + /* not in deny list */
64774 + if (i == num) {
64775 + realok = 1;
64776 + effectiveok = 1;
64777 + fsok = 1;
64778 + }
64779 + }
64780 +
64781 + if (realok && effectiveok && fsok)
64782 + return 0;
64783 + else {
64784 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64785 + return 1;
64786 + }
64787 +}
64788 +
64789 +extern int gr_acl_is_capable(const int cap);
64790 +
64791 +void
64792 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64793 +{
64794 + struct acl_role_label *role = task->role;
64795 + struct acl_subject_label *subj = NULL;
64796 + struct acl_object_label *obj;
64797 + struct file *filp;
64798 + uid_t uid;
64799 + gid_t gid;
64800 +
64801 + if (unlikely(!(gr_status & GR_READY)))
64802 + return;
64803 +
64804 + uid = GR_GLOBAL_UID(kuid);
64805 + gid = GR_GLOBAL_GID(kgid);
64806 +
64807 + filp = task->exec_file;
64808 +
64809 + /* kernel process, we'll give them the kernel role */
64810 + if (unlikely(!filp)) {
64811 + task->role = kernel_role;
64812 + task->acl = kernel_role->root_label;
64813 + return;
64814 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64815 + role = lookup_acl_role_label(task, uid, gid);
64816 +
64817 + /* don't change the role if we're not a privileged process */
64818 + if (role && task->role != role &&
64819 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64820 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64821 + return;
64822 +
64823 + /* perform subject lookup in possibly new role
64824 + we can use this result below in the case where role == task->role
64825 + */
64826 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64827 +
64828 + /* if we changed uid/gid, but result in the same role
64829 + and are using inheritance, don't lose the inherited subject
64830 + if current subject is other than what normal lookup
64831 + would result in, we arrived via inheritance, don't
64832 + lose subject
64833 + */
64834 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64835 + (subj == task->acl)))
64836 + task->acl = subj;
64837 +
64838 + task->role = role;
64839 +
64840 + task->is_writable = 0;
64841 +
64842 + /* ignore additional mmap checks for processes that are writable
64843 + by the default ACL */
64844 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64845 + if (unlikely(obj->mode & GR_WRITE))
64846 + task->is_writable = 1;
64847 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64848 + if (unlikely(obj->mode & GR_WRITE))
64849 + task->is_writable = 1;
64850 +
64851 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64852 + 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);
64853 +#endif
64854 +
64855 + gr_set_proc_res(task);
64856 +
64857 + return;
64858 +}
64859 +
64860 +int
64861 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64862 + const int unsafe_flags)
64863 +{
64864 + struct task_struct *task = current;
64865 + struct acl_subject_label *newacl;
64866 + struct acl_object_label *obj;
64867 + __u32 retmode;
64868 +
64869 + if (unlikely(!(gr_status & GR_READY)))
64870 + return 0;
64871 +
64872 + newacl = chk_subj_label(dentry, mnt, task->role);
64873 +
64874 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64875 + did an exec
64876 + */
64877 + rcu_read_lock();
64878 + read_lock(&tasklist_lock);
64879 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64880 + (task->parent->acl->mode & GR_POVERRIDE))) {
64881 + read_unlock(&tasklist_lock);
64882 + rcu_read_unlock();
64883 + goto skip_check;
64884 + }
64885 + read_unlock(&tasklist_lock);
64886 + rcu_read_unlock();
64887 +
64888 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64889 + !(task->role->roletype & GR_ROLE_GOD) &&
64890 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64891 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64892 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64893 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64894 + else
64895 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64896 + return -EACCES;
64897 + }
64898 +
64899 +skip_check:
64900 +
64901 + obj = chk_obj_label(dentry, mnt, task->acl);
64902 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64903 +
64904 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64905 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64906 + if (obj->nested)
64907 + task->acl = obj->nested;
64908 + else
64909 + task->acl = newacl;
64910 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64911 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64912 +
64913 + task->is_writable = 0;
64914 +
64915 + /* ignore additional mmap checks for processes that are writable
64916 + by the default ACL */
64917 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64918 + if (unlikely(obj->mode & GR_WRITE))
64919 + task->is_writable = 1;
64920 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64921 + if (unlikely(obj->mode & GR_WRITE))
64922 + task->is_writable = 1;
64923 +
64924 + gr_set_proc_res(task);
64925 +
64926 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64927 + 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);
64928 +#endif
64929 + return 0;
64930 +}
64931 +
64932 +/* always called with valid inodev ptr */
64933 +static void
64934 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64935 +{
64936 + struct acl_object_label *matchpo;
64937 + struct acl_subject_label *matchps;
64938 + struct acl_subject_label *subj;
64939 + struct acl_role_label *role;
64940 + unsigned int x;
64941 +
64942 + FOR_EACH_ROLE_START(role)
64943 + FOR_EACH_SUBJECT_START(role, subj, x)
64944 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64945 + matchpo->mode |= GR_DELETED;
64946 + FOR_EACH_SUBJECT_END(subj,x)
64947 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64948 + /* nested subjects aren't in the role's subj_hash table */
64949 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64950 + matchpo->mode |= GR_DELETED;
64951 + FOR_EACH_NESTED_SUBJECT_END(subj)
64952 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64953 + matchps->mode |= GR_DELETED;
64954 + FOR_EACH_ROLE_END(role)
64955 +
64956 + inodev->nentry->deleted = 1;
64957 +
64958 + return;
64959 +}
64960 +
64961 +void
64962 +gr_handle_delete(const ino_t ino, const dev_t dev)
64963 +{
64964 + struct inodev_entry *inodev;
64965 +
64966 + if (unlikely(!(gr_status & GR_READY)))
64967 + return;
64968 +
64969 + write_lock(&gr_inode_lock);
64970 + inodev = lookup_inodev_entry(ino, dev);
64971 + if (inodev != NULL)
64972 + do_handle_delete(inodev, ino, dev);
64973 + write_unlock(&gr_inode_lock);
64974 +
64975 + return;
64976 +}
64977 +
64978 +static void
64979 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64980 + const ino_t newinode, const dev_t newdevice,
64981 + struct acl_subject_label *subj)
64982 +{
64983 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64984 + struct acl_object_label *match;
64985 +
64986 + match = subj->obj_hash[index];
64987 +
64988 + while (match && (match->inode != oldinode ||
64989 + match->device != olddevice ||
64990 + !(match->mode & GR_DELETED)))
64991 + match = match->next;
64992 +
64993 + if (match && (match->inode == oldinode)
64994 + && (match->device == olddevice)
64995 + && (match->mode & GR_DELETED)) {
64996 + if (match->prev == NULL) {
64997 + subj->obj_hash[index] = match->next;
64998 + if (match->next != NULL)
64999 + match->next->prev = NULL;
65000 + } else {
65001 + match->prev->next = match->next;
65002 + if (match->next != NULL)
65003 + match->next->prev = match->prev;
65004 + }
65005 + match->prev = NULL;
65006 + match->next = NULL;
65007 + match->inode = newinode;
65008 + match->device = newdevice;
65009 + match->mode &= ~GR_DELETED;
65010 +
65011 + insert_acl_obj_label(match, subj);
65012 + }
65013 +
65014 + return;
65015 +}
65016 +
65017 +static void
65018 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65019 + const ino_t newinode, const dev_t newdevice,
65020 + struct acl_role_label *role)
65021 +{
65022 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65023 + struct acl_subject_label *match;
65024 +
65025 + match = role->subj_hash[index];
65026 +
65027 + while (match && (match->inode != oldinode ||
65028 + match->device != olddevice ||
65029 + !(match->mode & GR_DELETED)))
65030 + match = match->next;
65031 +
65032 + if (match && (match->inode == oldinode)
65033 + && (match->device == olddevice)
65034 + && (match->mode & GR_DELETED)) {
65035 + if (match->prev == NULL) {
65036 + role->subj_hash[index] = match->next;
65037 + if (match->next != NULL)
65038 + match->next->prev = NULL;
65039 + } else {
65040 + match->prev->next = match->next;
65041 + if (match->next != NULL)
65042 + match->next->prev = match->prev;
65043 + }
65044 + match->prev = NULL;
65045 + match->next = NULL;
65046 + match->inode = newinode;
65047 + match->device = newdevice;
65048 + match->mode &= ~GR_DELETED;
65049 +
65050 + insert_acl_subj_label(match, role);
65051 + }
65052 +
65053 + return;
65054 +}
65055 +
65056 +static void
65057 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65058 + const ino_t newinode, const dev_t newdevice)
65059 +{
65060 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65061 + struct inodev_entry *match;
65062 +
65063 + match = inodev_set.i_hash[index];
65064 +
65065 + while (match && (match->nentry->inode != oldinode ||
65066 + match->nentry->device != olddevice || !match->nentry->deleted))
65067 + match = match->next;
65068 +
65069 + if (match && (match->nentry->inode == oldinode)
65070 + && (match->nentry->device == olddevice) &&
65071 + match->nentry->deleted) {
65072 + if (match->prev == NULL) {
65073 + inodev_set.i_hash[index] = match->next;
65074 + if (match->next != NULL)
65075 + match->next->prev = NULL;
65076 + } else {
65077 + match->prev->next = match->next;
65078 + if (match->next != NULL)
65079 + match->next->prev = match->prev;
65080 + }
65081 + match->prev = NULL;
65082 + match->next = NULL;
65083 + match->nentry->inode = newinode;
65084 + match->nentry->device = newdevice;
65085 + match->nentry->deleted = 0;
65086 +
65087 + insert_inodev_entry(match);
65088 + }
65089 +
65090 + return;
65091 +}
65092 +
65093 +static void
65094 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65095 +{
65096 + struct acl_subject_label *subj;
65097 + struct acl_role_label *role;
65098 + unsigned int x;
65099 +
65100 + FOR_EACH_ROLE_START(role)
65101 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65102 +
65103 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65104 + if ((subj->inode == ino) && (subj->device == dev)) {
65105 + subj->inode = ino;
65106 + subj->device = dev;
65107 + }
65108 + /* nested subjects aren't in the role's subj_hash table */
65109 + update_acl_obj_label(matchn->inode, matchn->device,
65110 + ino, dev, subj);
65111 + FOR_EACH_NESTED_SUBJECT_END(subj)
65112 + FOR_EACH_SUBJECT_START(role, subj, x)
65113 + update_acl_obj_label(matchn->inode, matchn->device,
65114 + ino, dev, subj);
65115 + FOR_EACH_SUBJECT_END(subj,x)
65116 + FOR_EACH_ROLE_END(role)
65117 +
65118 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65119 +
65120 + return;
65121 +}
65122 +
65123 +static void
65124 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65125 + const struct vfsmount *mnt)
65126 +{
65127 + ino_t ino = dentry->d_inode->i_ino;
65128 + dev_t dev = __get_dev(dentry);
65129 +
65130 + __do_handle_create(matchn, ino, dev);
65131 +
65132 + return;
65133 +}
65134 +
65135 +void
65136 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65137 +{
65138 + struct name_entry *matchn;
65139 +
65140 + if (unlikely(!(gr_status & GR_READY)))
65141 + return;
65142 +
65143 + preempt_disable();
65144 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65145 +
65146 + if (unlikely((unsigned long)matchn)) {
65147 + write_lock(&gr_inode_lock);
65148 + do_handle_create(matchn, dentry, mnt);
65149 + write_unlock(&gr_inode_lock);
65150 + }
65151 + preempt_enable();
65152 +
65153 + return;
65154 +}
65155 +
65156 +void
65157 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65158 +{
65159 + struct name_entry *matchn;
65160 +
65161 + if (unlikely(!(gr_status & GR_READY)))
65162 + return;
65163 +
65164 + preempt_disable();
65165 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65166 +
65167 + if (unlikely((unsigned long)matchn)) {
65168 + write_lock(&gr_inode_lock);
65169 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65170 + write_unlock(&gr_inode_lock);
65171 + }
65172 + preempt_enable();
65173 +
65174 + return;
65175 +}
65176 +
65177 +void
65178 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65179 + struct dentry *old_dentry,
65180 + struct dentry *new_dentry,
65181 + struct vfsmount *mnt, const __u8 replace)
65182 +{
65183 + struct name_entry *matchn;
65184 + struct inodev_entry *inodev;
65185 + struct inode *inode = new_dentry->d_inode;
65186 + ino_t old_ino = old_dentry->d_inode->i_ino;
65187 + dev_t old_dev = __get_dev(old_dentry);
65188 +
65189 + /* vfs_rename swaps the name and parent link for old_dentry and
65190 + new_dentry
65191 + at this point, old_dentry has the new name, parent link, and inode
65192 + for the renamed file
65193 + if a file is being replaced by a rename, new_dentry has the inode
65194 + and name for the replaced file
65195 + */
65196 +
65197 + if (unlikely(!(gr_status & GR_READY)))
65198 + return;
65199 +
65200 + preempt_disable();
65201 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65202 +
65203 + /* we wouldn't have to check d_inode if it weren't for
65204 + NFS silly-renaming
65205 + */
65206 +
65207 + write_lock(&gr_inode_lock);
65208 + if (unlikely(replace && inode)) {
65209 + ino_t new_ino = inode->i_ino;
65210 + dev_t new_dev = __get_dev(new_dentry);
65211 +
65212 + inodev = lookup_inodev_entry(new_ino, new_dev);
65213 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65214 + do_handle_delete(inodev, new_ino, new_dev);
65215 + }
65216 +
65217 + inodev = lookup_inodev_entry(old_ino, old_dev);
65218 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65219 + do_handle_delete(inodev, old_ino, old_dev);
65220 +
65221 + if (unlikely((unsigned long)matchn))
65222 + do_handle_create(matchn, old_dentry, mnt);
65223 +
65224 + write_unlock(&gr_inode_lock);
65225 + preempt_enable();
65226 +
65227 + return;
65228 +}
65229 +
65230 +static int
65231 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65232 + unsigned char **sum)
65233 +{
65234 + struct acl_role_label *r;
65235 + struct role_allowed_ip *ipp;
65236 + struct role_transition *trans;
65237 + unsigned int i;
65238 + int found = 0;
65239 + u32 curr_ip = current->signal->curr_ip;
65240 +
65241 + current->signal->saved_ip = curr_ip;
65242 +
65243 + /* check transition table */
65244 +
65245 + for (trans = current->role->transitions; trans; trans = trans->next) {
65246 + if (!strcmp(rolename, trans->rolename)) {
65247 + found = 1;
65248 + break;
65249 + }
65250 + }
65251 +
65252 + if (!found)
65253 + return 0;
65254 +
65255 + /* handle special roles that do not require authentication
65256 + and check ip */
65257 +
65258 + FOR_EACH_ROLE_START(r)
65259 + if (!strcmp(rolename, r->rolename) &&
65260 + (r->roletype & GR_ROLE_SPECIAL)) {
65261 + found = 0;
65262 + if (r->allowed_ips != NULL) {
65263 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65264 + if ((ntohl(curr_ip) & ipp->netmask) ==
65265 + (ntohl(ipp->addr) & ipp->netmask))
65266 + found = 1;
65267 + }
65268 + } else
65269 + found = 2;
65270 + if (!found)
65271 + return 0;
65272 +
65273 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65274 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65275 + *salt = NULL;
65276 + *sum = NULL;
65277 + return 1;
65278 + }
65279 + }
65280 + FOR_EACH_ROLE_END(r)
65281 +
65282 + for (i = 0; i < num_sprole_pws; i++) {
65283 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65284 + *salt = acl_special_roles[i]->salt;
65285 + *sum = acl_special_roles[i]->sum;
65286 + return 1;
65287 + }
65288 + }
65289 +
65290 + return 0;
65291 +}
65292 +
65293 +static void
65294 +assign_special_role(char *rolename)
65295 +{
65296 + struct acl_object_label *obj;
65297 + struct acl_role_label *r;
65298 + struct acl_role_label *assigned = NULL;
65299 + struct task_struct *tsk;
65300 + struct file *filp;
65301 +
65302 + FOR_EACH_ROLE_START(r)
65303 + if (!strcmp(rolename, r->rolename) &&
65304 + (r->roletype & GR_ROLE_SPECIAL)) {
65305 + assigned = r;
65306 + break;
65307 + }
65308 + FOR_EACH_ROLE_END(r)
65309 +
65310 + if (!assigned)
65311 + return;
65312 +
65313 + read_lock(&tasklist_lock);
65314 + read_lock(&grsec_exec_file_lock);
65315 +
65316 + tsk = current->real_parent;
65317 + if (tsk == NULL)
65318 + goto out_unlock;
65319 +
65320 + filp = tsk->exec_file;
65321 + if (filp == NULL)
65322 + goto out_unlock;
65323 +
65324 + tsk->is_writable = 0;
65325 +
65326 + tsk->acl_sp_role = 1;
65327 + tsk->acl_role_id = ++acl_sp_role_value;
65328 + tsk->role = assigned;
65329 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65330 +
65331 + /* ignore additional mmap checks for processes that are writable
65332 + by the default ACL */
65333 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65334 + if (unlikely(obj->mode & GR_WRITE))
65335 + tsk->is_writable = 1;
65336 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65337 + if (unlikely(obj->mode & GR_WRITE))
65338 + tsk->is_writable = 1;
65339 +
65340 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65341 + 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));
65342 +#endif
65343 +
65344 +out_unlock:
65345 + read_unlock(&grsec_exec_file_lock);
65346 + read_unlock(&tasklist_lock);
65347 + return;
65348 +}
65349 +
65350 +int gr_check_secure_terminal(struct task_struct *task)
65351 +{
65352 + struct task_struct *p, *p2, *p3;
65353 + struct files_struct *files;
65354 + struct fdtable *fdt;
65355 + struct file *our_file = NULL, *file;
65356 + int i;
65357 +
65358 + if (task->signal->tty == NULL)
65359 + return 1;
65360 +
65361 + files = get_files_struct(task);
65362 + if (files != NULL) {
65363 + rcu_read_lock();
65364 + fdt = files_fdtable(files);
65365 + for (i=0; i < fdt->max_fds; i++) {
65366 + file = fcheck_files(files, i);
65367 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65368 + get_file(file);
65369 + our_file = file;
65370 + }
65371 + }
65372 + rcu_read_unlock();
65373 + put_files_struct(files);
65374 + }
65375 +
65376 + if (our_file == NULL)
65377 + return 1;
65378 +
65379 + read_lock(&tasklist_lock);
65380 + do_each_thread(p2, p) {
65381 + files = get_files_struct(p);
65382 + if (files == NULL ||
65383 + (p->signal && p->signal->tty == task->signal->tty)) {
65384 + if (files != NULL)
65385 + put_files_struct(files);
65386 + continue;
65387 + }
65388 + rcu_read_lock();
65389 + fdt = files_fdtable(files);
65390 + for (i=0; i < fdt->max_fds; i++) {
65391 + file = fcheck_files(files, i);
65392 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65393 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65394 + p3 = task;
65395 + while (task_pid_nr(p3) > 0) {
65396 + if (p3 == p)
65397 + break;
65398 + p3 = p3->real_parent;
65399 + }
65400 + if (p3 == p)
65401 + break;
65402 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65403 + gr_handle_alertkill(p);
65404 + rcu_read_unlock();
65405 + put_files_struct(files);
65406 + read_unlock(&tasklist_lock);
65407 + fput(our_file);
65408 + return 0;
65409 + }
65410 + }
65411 + rcu_read_unlock();
65412 + put_files_struct(files);
65413 + } while_each_thread(p2, p);
65414 + read_unlock(&tasklist_lock);
65415 +
65416 + fput(our_file);
65417 + return 1;
65418 +}
65419 +
65420 +static int gr_rbac_disable(void *unused)
65421 +{
65422 + pax_open_kernel();
65423 + gr_status &= ~GR_READY;
65424 + pax_close_kernel();
65425 +
65426 + return 0;
65427 +}
65428 +
65429 +ssize_t
65430 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65431 +{
65432 + struct gr_arg_wrapper uwrap;
65433 + unsigned char *sprole_salt = NULL;
65434 + unsigned char *sprole_sum = NULL;
65435 + int error = 0;
65436 + int error2 = 0;
65437 + size_t req_count = 0;
65438 +
65439 + mutex_lock(&gr_dev_mutex);
65440 +
65441 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65442 + error = -EPERM;
65443 + goto out;
65444 + }
65445 +
65446 +#ifdef CONFIG_COMPAT
65447 + pax_open_kernel();
65448 + if (is_compat_task()) {
65449 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65450 + copy_gr_arg = &copy_gr_arg_compat;
65451 + copy_acl_object_label = &copy_acl_object_label_compat;
65452 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65453 + copy_acl_role_label = &copy_acl_role_label_compat;
65454 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65455 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65456 + copy_role_transition = &copy_role_transition_compat;
65457 + copy_sprole_pw = &copy_sprole_pw_compat;
65458 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65459 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65460 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65461 + } else {
65462 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65463 + copy_gr_arg = &copy_gr_arg_normal;
65464 + copy_acl_object_label = &copy_acl_object_label_normal;
65465 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65466 + copy_acl_role_label = &copy_acl_role_label_normal;
65467 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65468 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65469 + copy_role_transition = &copy_role_transition_normal;
65470 + copy_sprole_pw = &copy_sprole_pw_normal;
65471 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65472 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65473 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65474 + }
65475 + pax_close_kernel();
65476 +#endif
65477 +
65478 + req_count = get_gr_arg_wrapper_size();
65479 +
65480 + if (count != req_count) {
65481 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65482 + error = -EINVAL;
65483 + goto out;
65484 + }
65485 +
65486 +
65487 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65488 + gr_auth_expires = 0;
65489 + gr_auth_attempts = 0;
65490 + }
65491 +
65492 + error = copy_gr_arg_wrapper(buf, &uwrap);
65493 + if (error)
65494 + goto out;
65495 +
65496 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65497 + if (error)
65498 + goto out;
65499 +
65500 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65501 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65502 + time_after(gr_auth_expires, get_seconds())) {
65503 + error = -EBUSY;
65504 + goto out;
65505 + }
65506 +
65507 + /* if non-root trying to do anything other than use a special role,
65508 + do not attempt authentication, do not count towards authentication
65509 + locking
65510 + */
65511 +
65512 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65513 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65514 + gr_is_global_nonroot(current_uid())) {
65515 + error = -EPERM;
65516 + goto out;
65517 + }
65518 +
65519 + /* ensure pw and special role name are null terminated */
65520 +
65521 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65522 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65523 +
65524 + /* Okay.
65525 + * We have our enough of the argument structure..(we have yet
65526 + * to copy_from_user the tables themselves) . Copy the tables
65527 + * only if we need them, i.e. for loading operations. */
65528 +
65529 + switch (gr_usermode->mode) {
65530 + case GR_STATUS:
65531 + if (gr_status & GR_READY) {
65532 + error = 1;
65533 + if (!gr_check_secure_terminal(current))
65534 + error = 3;
65535 + } else
65536 + error = 2;
65537 + goto out;
65538 + case GR_SHUTDOWN:
65539 + if ((gr_status & GR_READY)
65540 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65541 + stop_machine(gr_rbac_disable, NULL, NULL);
65542 + free_variables();
65543 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65544 + memset(gr_system_salt, 0, GR_SALT_LEN);
65545 + memset(gr_system_sum, 0, GR_SHA_LEN);
65546 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65547 + } else if (gr_status & GR_READY) {
65548 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65549 + error = -EPERM;
65550 + } else {
65551 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65552 + error = -EAGAIN;
65553 + }
65554 + break;
65555 + case GR_ENABLE:
65556 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65557 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65558 + else {
65559 + if (gr_status & GR_READY)
65560 + error = -EAGAIN;
65561 + else
65562 + error = error2;
65563 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65564 + }
65565 + break;
65566 + case GR_RELOAD:
65567 + if (!(gr_status & GR_READY)) {
65568 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65569 + error = -EAGAIN;
65570 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65571 + stop_machine(gr_rbac_disable, NULL, NULL);
65572 + free_variables();
65573 + error2 = gracl_init(gr_usermode);
65574 + if (!error2)
65575 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65576 + else {
65577 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65578 + error = error2;
65579 + }
65580 + } else {
65581 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65582 + error = -EPERM;
65583 + }
65584 + break;
65585 + case GR_SEGVMOD:
65586 + if (unlikely(!(gr_status & GR_READY))) {
65587 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65588 + error = -EAGAIN;
65589 + break;
65590 + }
65591 +
65592 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65593 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65594 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65595 + struct acl_subject_label *segvacl;
65596 + segvacl =
65597 + lookup_acl_subj_label(gr_usermode->segv_inode,
65598 + gr_usermode->segv_device,
65599 + current->role);
65600 + if (segvacl) {
65601 + segvacl->crashes = 0;
65602 + segvacl->expires = 0;
65603 + }
65604 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65605 + gr_remove_uid(gr_usermode->segv_uid);
65606 + }
65607 + } else {
65608 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65609 + error = -EPERM;
65610 + }
65611 + break;
65612 + case GR_SPROLE:
65613 + case GR_SPROLEPAM:
65614 + if (unlikely(!(gr_status & GR_READY))) {
65615 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65616 + error = -EAGAIN;
65617 + break;
65618 + }
65619 +
65620 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65621 + current->role->expires = 0;
65622 + current->role->auth_attempts = 0;
65623 + }
65624 +
65625 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65626 + time_after(current->role->expires, get_seconds())) {
65627 + error = -EBUSY;
65628 + goto out;
65629 + }
65630 +
65631 + if (lookup_special_role_auth
65632 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65633 + && ((!sprole_salt && !sprole_sum)
65634 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65635 + char *p = "";
65636 + assign_special_role(gr_usermode->sp_role);
65637 + read_lock(&tasklist_lock);
65638 + if (current->real_parent)
65639 + p = current->real_parent->role->rolename;
65640 + read_unlock(&tasklist_lock);
65641 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65642 + p, acl_sp_role_value);
65643 + } else {
65644 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65645 + error = -EPERM;
65646 + if(!(current->role->auth_attempts++))
65647 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65648 +
65649 + goto out;
65650 + }
65651 + break;
65652 + case GR_UNSPROLE:
65653 + if (unlikely(!(gr_status & GR_READY))) {
65654 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65655 + error = -EAGAIN;
65656 + break;
65657 + }
65658 +
65659 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65660 + char *p = "";
65661 + int i = 0;
65662 +
65663 + read_lock(&tasklist_lock);
65664 + if (current->real_parent) {
65665 + p = current->real_parent->role->rolename;
65666 + i = current->real_parent->acl_role_id;
65667 + }
65668 + read_unlock(&tasklist_lock);
65669 +
65670 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65671 + gr_set_acls(1);
65672 + } else {
65673 + error = -EPERM;
65674 + goto out;
65675 + }
65676 + break;
65677 + default:
65678 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65679 + error = -EINVAL;
65680 + break;
65681 + }
65682 +
65683 + if (error != -EPERM)
65684 + goto out;
65685 +
65686 + if(!(gr_auth_attempts++))
65687 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65688 +
65689 + out:
65690 + mutex_unlock(&gr_dev_mutex);
65691 +
65692 + if (!error)
65693 + error = req_count;
65694 +
65695 + return error;
65696 +}
65697 +
65698 +/* must be called with
65699 + rcu_read_lock();
65700 + read_lock(&tasklist_lock);
65701 + read_lock(&grsec_exec_file_lock);
65702 +*/
65703 +int gr_apply_subject_to_task(struct task_struct *task)
65704 +{
65705 + struct acl_object_label *obj;
65706 + char *tmpname;
65707 + struct acl_subject_label *tmpsubj;
65708 + struct file *filp;
65709 + struct name_entry *nmatch;
65710 +
65711 + filp = task->exec_file;
65712 + if (filp == NULL)
65713 + return 0;
65714 +
65715 + /* the following is to apply the correct subject
65716 + on binaries running when the RBAC system
65717 + is enabled, when the binaries have been
65718 + replaced or deleted since their execution
65719 + -----
65720 + when the RBAC system starts, the inode/dev
65721 + from exec_file will be one the RBAC system
65722 + is unaware of. It only knows the inode/dev
65723 + of the present file on disk, or the absence
65724 + of it.
65725 + */
65726 + preempt_disable();
65727 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65728 +
65729 + nmatch = lookup_name_entry(tmpname);
65730 + preempt_enable();
65731 + tmpsubj = NULL;
65732 + if (nmatch) {
65733 + if (nmatch->deleted)
65734 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65735 + else
65736 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65737 + if (tmpsubj != NULL)
65738 + task->acl = tmpsubj;
65739 + }
65740 + if (tmpsubj == NULL)
65741 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65742 + task->role);
65743 + if (task->acl) {
65744 + task->is_writable = 0;
65745 + /* ignore additional mmap checks for processes that are writable
65746 + by the default ACL */
65747 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65748 + if (unlikely(obj->mode & GR_WRITE))
65749 + task->is_writable = 1;
65750 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65751 + if (unlikely(obj->mode & GR_WRITE))
65752 + task->is_writable = 1;
65753 +
65754 + gr_set_proc_res(task);
65755 +
65756 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65757 + 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);
65758 +#endif
65759 + } else {
65760 + return 1;
65761 + }
65762 +
65763 + return 0;
65764 +}
65765 +
65766 +int
65767 +gr_set_acls(const int type)
65768 +{
65769 + struct task_struct *task, *task2;
65770 + struct acl_role_label *role = current->role;
65771 + __u16 acl_role_id = current->acl_role_id;
65772 + const struct cred *cred;
65773 + int ret;
65774 +
65775 + rcu_read_lock();
65776 + read_lock(&tasklist_lock);
65777 + read_lock(&grsec_exec_file_lock);
65778 + do_each_thread(task2, task) {
65779 + /* check to see if we're called from the exit handler,
65780 + if so, only replace ACLs that have inherited the admin
65781 + ACL */
65782 +
65783 + if (type && (task->role != role ||
65784 + task->acl_role_id != acl_role_id))
65785 + continue;
65786 +
65787 + task->acl_role_id = 0;
65788 + task->acl_sp_role = 0;
65789 +
65790 + if (task->exec_file) {
65791 + cred = __task_cred(task);
65792 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65793 + ret = gr_apply_subject_to_task(task);
65794 + if (ret) {
65795 + read_unlock(&grsec_exec_file_lock);
65796 + read_unlock(&tasklist_lock);
65797 + rcu_read_unlock();
65798 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65799 + return ret;
65800 + }
65801 + } else {
65802 + // it's a kernel process
65803 + task->role = kernel_role;
65804 + task->acl = kernel_role->root_label;
65805 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65806 + task->acl->mode &= ~GR_PROCFIND;
65807 +#endif
65808 + }
65809 + } while_each_thread(task2, task);
65810 + read_unlock(&grsec_exec_file_lock);
65811 + read_unlock(&tasklist_lock);
65812 + rcu_read_unlock();
65813 +
65814 + return 0;
65815 +}
65816 +
65817 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65818 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65819 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65820 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65821 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65822 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65823 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65824 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65825 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65826 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65827 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65828 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65829 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65830 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65831 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65832 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65833 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65834 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65835 +};
65836 +
65837 +void
65838 +gr_learn_resource(const struct task_struct *task,
65839 + const int res, const unsigned long wanted, const int gt)
65840 +{
65841 + struct acl_subject_label *acl;
65842 + const struct cred *cred;
65843 +
65844 + if (unlikely((gr_status & GR_READY) &&
65845 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65846 + goto skip_reslog;
65847 +
65848 + gr_log_resource(task, res, wanted, gt);
65849 +skip_reslog:
65850 +
65851 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65852 + return;
65853 +
65854 + acl = task->acl;
65855 +
65856 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65857 + !(acl->resmask & (1U << (unsigned short) res))))
65858 + return;
65859 +
65860 + if (wanted >= acl->res[res].rlim_cur) {
65861 + unsigned long res_add;
65862 +
65863 + res_add = wanted + res_learn_bumps[res];
65864 +
65865 + acl->res[res].rlim_cur = res_add;
65866 +
65867 + if (wanted > acl->res[res].rlim_max)
65868 + acl->res[res].rlim_max = res_add;
65869 +
65870 + /* only log the subject filename, since resource logging is supported for
65871 + single-subject learning only */
65872 + rcu_read_lock();
65873 + cred = __task_cred(task);
65874 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65875 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65876 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65877 + "", (unsigned long) res, &task->signal->saved_ip);
65878 + rcu_read_unlock();
65879 + }
65880 +
65881 + return;
65882 +}
65883 +EXPORT_SYMBOL(gr_learn_resource);
65884 +#endif
65885 +
65886 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65887 +void
65888 +pax_set_initial_flags(struct linux_binprm *bprm)
65889 +{
65890 + struct task_struct *task = current;
65891 + struct acl_subject_label *proc;
65892 + unsigned long flags;
65893 +
65894 + if (unlikely(!(gr_status & GR_READY)))
65895 + return;
65896 +
65897 + flags = pax_get_flags(task);
65898 +
65899 + proc = task->acl;
65900 +
65901 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65902 + flags &= ~MF_PAX_PAGEEXEC;
65903 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65904 + flags &= ~MF_PAX_SEGMEXEC;
65905 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65906 + flags &= ~MF_PAX_RANDMMAP;
65907 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65908 + flags &= ~MF_PAX_EMUTRAMP;
65909 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65910 + flags &= ~MF_PAX_MPROTECT;
65911 +
65912 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65913 + flags |= MF_PAX_PAGEEXEC;
65914 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65915 + flags |= MF_PAX_SEGMEXEC;
65916 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65917 + flags |= MF_PAX_RANDMMAP;
65918 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65919 + flags |= MF_PAX_EMUTRAMP;
65920 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65921 + flags |= MF_PAX_MPROTECT;
65922 +
65923 + pax_set_flags(task, flags);
65924 +
65925 + return;
65926 +}
65927 +#endif
65928 +
65929 +int
65930 +gr_handle_proc_ptrace(struct task_struct *task)
65931 +{
65932 + struct file *filp;
65933 + struct task_struct *tmp = task;
65934 + struct task_struct *curtemp = current;
65935 + __u32 retmode;
65936 +
65937 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65938 + if (unlikely(!(gr_status & GR_READY)))
65939 + return 0;
65940 +#endif
65941 +
65942 + read_lock(&tasklist_lock);
65943 + read_lock(&grsec_exec_file_lock);
65944 + filp = task->exec_file;
65945 +
65946 + while (task_pid_nr(tmp) > 0) {
65947 + if (tmp == curtemp)
65948 + break;
65949 + tmp = tmp->real_parent;
65950 + }
65951 +
65952 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65953 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65954 + read_unlock(&grsec_exec_file_lock);
65955 + read_unlock(&tasklist_lock);
65956 + return 1;
65957 + }
65958 +
65959 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65960 + if (!(gr_status & GR_READY)) {
65961 + read_unlock(&grsec_exec_file_lock);
65962 + read_unlock(&tasklist_lock);
65963 + return 0;
65964 + }
65965 +#endif
65966 +
65967 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65968 + read_unlock(&grsec_exec_file_lock);
65969 + read_unlock(&tasklist_lock);
65970 +
65971 + if (retmode & GR_NOPTRACE)
65972 + return 1;
65973 +
65974 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65975 + && (current->acl != task->acl || (current->acl != current->role->root_label
65976 + && task_pid_nr(current) != task_pid_nr(task))))
65977 + return 1;
65978 +
65979 + return 0;
65980 +}
65981 +
65982 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65983 +{
65984 + if (unlikely(!(gr_status & GR_READY)))
65985 + return;
65986 +
65987 + if (!(current->role->roletype & GR_ROLE_GOD))
65988 + return;
65989 +
65990 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65991 + p->role->rolename, gr_task_roletype_to_char(p),
65992 + p->acl->filename);
65993 +}
65994 +
65995 +int
65996 +gr_handle_ptrace(struct task_struct *task, const long request)
65997 +{
65998 + struct task_struct *tmp = task;
65999 + struct task_struct *curtemp = current;
66000 + __u32 retmode;
66001 +
66002 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66003 + if (unlikely(!(gr_status & GR_READY)))
66004 + return 0;
66005 +#endif
66006 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66007 + read_lock(&tasklist_lock);
66008 + while (task_pid_nr(tmp) > 0) {
66009 + if (tmp == curtemp)
66010 + break;
66011 + tmp = tmp->real_parent;
66012 + }
66013 +
66014 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66015 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66016 + read_unlock(&tasklist_lock);
66017 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66018 + return 1;
66019 + }
66020 + read_unlock(&tasklist_lock);
66021 + }
66022 +
66023 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66024 + if (!(gr_status & GR_READY))
66025 + return 0;
66026 +#endif
66027 +
66028 + read_lock(&grsec_exec_file_lock);
66029 + if (unlikely(!task->exec_file)) {
66030 + read_unlock(&grsec_exec_file_lock);
66031 + return 0;
66032 + }
66033 +
66034 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66035 + read_unlock(&grsec_exec_file_lock);
66036 +
66037 + if (retmode & GR_NOPTRACE) {
66038 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66039 + return 1;
66040 + }
66041 +
66042 + if (retmode & GR_PTRACERD) {
66043 + switch (request) {
66044 + case PTRACE_SEIZE:
66045 + case PTRACE_POKETEXT:
66046 + case PTRACE_POKEDATA:
66047 + case PTRACE_POKEUSR:
66048 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66049 + case PTRACE_SETREGS:
66050 + case PTRACE_SETFPREGS:
66051 +#endif
66052 +#ifdef CONFIG_X86
66053 + case PTRACE_SETFPXREGS:
66054 +#endif
66055 +#ifdef CONFIG_ALTIVEC
66056 + case PTRACE_SETVRREGS:
66057 +#endif
66058 + return 1;
66059 + default:
66060 + return 0;
66061 + }
66062 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66063 + !(current->role->roletype & GR_ROLE_GOD) &&
66064 + (current->acl != task->acl)) {
66065 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66066 + return 1;
66067 + }
66068 +
66069 + return 0;
66070 +}
66071 +
66072 +static int is_writable_mmap(const struct file *filp)
66073 +{
66074 + struct task_struct *task = current;
66075 + struct acl_object_label *obj, *obj2;
66076 +
66077 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66078 + !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))) {
66079 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66080 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66081 + task->role->root_label);
66082 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66083 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66084 + return 1;
66085 + }
66086 + }
66087 + return 0;
66088 +}
66089 +
66090 +int
66091 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66092 +{
66093 + __u32 mode;
66094 +
66095 + if (unlikely(!file || !(prot & PROT_EXEC)))
66096 + return 1;
66097 +
66098 + if (is_writable_mmap(file))
66099 + return 0;
66100 +
66101 + mode =
66102 + gr_search_file(file->f_path.dentry,
66103 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66104 + file->f_path.mnt);
66105 +
66106 + if (!gr_tpe_allow(file))
66107 + return 0;
66108 +
66109 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66110 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66111 + return 0;
66112 + } else if (unlikely(!(mode & GR_EXEC))) {
66113 + return 0;
66114 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66115 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66116 + return 1;
66117 + }
66118 +
66119 + return 1;
66120 +}
66121 +
66122 +int
66123 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66124 +{
66125 + __u32 mode;
66126 +
66127 + if (unlikely(!file || !(prot & PROT_EXEC)))
66128 + return 1;
66129 +
66130 + if (is_writable_mmap(file))
66131 + return 0;
66132 +
66133 + mode =
66134 + gr_search_file(file->f_path.dentry,
66135 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66136 + file->f_path.mnt);
66137 +
66138 + if (!gr_tpe_allow(file))
66139 + return 0;
66140 +
66141 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66142 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66143 + return 0;
66144 + } else if (unlikely(!(mode & GR_EXEC))) {
66145 + return 0;
66146 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66147 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66148 + return 1;
66149 + }
66150 +
66151 + return 1;
66152 +}
66153 +
66154 +void
66155 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66156 +{
66157 + unsigned long runtime;
66158 + unsigned long cputime;
66159 + unsigned int wday, cday;
66160 + __u8 whr, chr;
66161 + __u8 wmin, cmin;
66162 + __u8 wsec, csec;
66163 + struct timespec timeval;
66164 +
66165 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66166 + !(task->acl->mode & GR_PROCACCT)))
66167 + return;
66168 +
66169 + do_posix_clock_monotonic_gettime(&timeval);
66170 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66171 + wday = runtime / (3600 * 24);
66172 + runtime -= wday * (3600 * 24);
66173 + whr = runtime / 3600;
66174 + runtime -= whr * 3600;
66175 + wmin = runtime / 60;
66176 + runtime -= wmin * 60;
66177 + wsec = runtime;
66178 +
66179 + cputime = (task->utime + task->stime) / HZ;
66180 + cday = cputime / (3600 * 24);
66181 + cputime -= cday * (3600 * 24);
66182 + chr = cputime / 3600;
66183 + cputime -= chr * 3600;
66184 + cmin = cputime / 60;
66185 + cputime -= cmin * 60;
66186 + csec = cputime;
66187 +
66188 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66189 +
66190 + return;
66191 +}
66192 +
66193 +void gr_set_kernel_label(struct task_struct *task)
66194 +{
66195 + if (gr_status & GR_READY) {
66196 + task->role = kernel_role;
66197 + task->acl = kernel_role->root_label;
66198 + }
66199 + return;
66200 +}
66201 +
66202 +#ifdef CONFIG_TASKSTATS
66203 +int gr_is_taskstats_denied(int pid)
66204 +{
66205 + struct task_struct *task;
66206 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66207 + const struct cred *cred;
66208 +#endif
66209 + int ret = 0;
66210 +
66211 + /* restrict taskstats viewing to un-chrooted root users
66212 + who have the 'view' subject flag if the RBAC system is enabled
66213 + */
66214 +
66215 + rcu_read_lock();
66216 + read_lock(&tasklist_lock);
66217 + task = find_task_by_vpid(pid);
66218 + if (task) {
66219 +#ifdef CONFIG_GRKERNSEC_CHROOT
66220 + if (proc_is_chrooted(task))
66221 + ret = -EACCES;
66222 +#endif
66223 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66224 + cred = __task_cred(task);
66225 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66226 + if (gr_is_global_nonroot(cred->uid))
66227 + ret = -EACCES;
66228 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66229 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66230 + ret = -EACCES;
66231 +#endif
66232 +#endif
66233 + if (gr_status & GR_READY) {
66234 + if (!(task->acl->mode & GR_VIEW))
66235 + ret = -EACCES;
66236 + }
66237 + } else
66238 + ret = -ENOENT;
66239 +
66240 + read_unlock(&tasklist_lock);
66241 + rcu_read_unlock();
66242 +
66243 + return ret;
66244 +}
66245 +#endif
66246 +
66247 +/* AUXV entries are filled via a descendant of search_binary_handler
66248 + after we've already applied the subject for the target
66249 +*/
66250 +int gr_acl_enable_at_secure(void)
66251 +{
66252 + if (unlikely(!(gr_status & GR_READY)))
66253 + return 0;
66254 +
66255 + if (current->acl->mode & GR_ATSECURE)
66256 + return 1;
66257 +
66258 + return 0;
66259 +}
66260 +
66261 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66262 +{
66263 + struct task_struct *task = current;
66264 + struct dentry *dentry = file->f_path.dentry;
66265 + struct vfsmount *mnt = file->f_path.mnt;
66266 + struct acl_object_label *obj, *tmp;
66267 + struct acl_subject_label *subj;
66268 + unsigned int bufsize;
66269 + int is_not_root;
66270 + char *path;
66271 + dev_t dev = __get_dev(dentry);
66272 +
66273 + if (unlikely(!(gr_status & GR_READY)))
66274 + return 1;
66275 +
66276 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66277 + return 1;
66278 +
66279 + /* ignore Eric Biederman */
66280 + if (IS_PRIVATE(dentry->d_inode))
66281 + return 1;
66282 +
66283 + subj = task->acl;
66284 + read_lock(&gr_inode_lock);
66285 + do {
66286 + obj = lookup_acl_obj_label(ino, dev, subj);
66287 + if (obj != NULL) {
66288 + read_unlock(&gr_inode_lock);
66289 + return (obj->mode & GR_FIND) ? 1 : 0;
66290 + }
66291 + } while ((subj = subj->parent_subject));
66292 + read_unlock(&gr_inode_lock);
66293 +
66294 + /* this is purely an optimization since we're looking for an object
66295 + for the directory we're doing a readdir on
66296 + if it's possible for any globbed object to match the entry we're
66297 + filling into the directory, then the object we find here will be
66298 + an anchor point with attached globbed objects
66299 + */
66300 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66301 + if (obj->globbed == NULL)
66302 + return (obj->mode & GR_FIND) ? 1 : 0;
66303 +
66304 + is_not_root = ((obj->filename[0] == '/') &&
66305 + (obj->filename[1] == '\0')) ? 0 : 1;
66306 + bufsize = PAGE_SIZE - namelen - is_not_root;
66307 +
66308 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66309 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66310 + return 1;
66311 +
66312 + preempt_disable();
66313 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66314 + bufsize);
66315 +
66316 + bufsize = strlen(path);
66317 +
66318 + /* if base is "/", don't append an additional slash */
66319 + if (is_not_root)
66320 + *(path + bufsize) = '/';
66321 + memcpy(path + bufsize + is_not_root, name, namelen);
66322 + *(path + bufsize + namelen + is_not_root) = '\0';
66323 +
66324 + tmp = obj->globbed;
66325 + while (tmp) {
66326 + if (!glob_match(tmp->filename, path)) {
66327 + preempt_enable();
66328 + return (tmp->mode & GR_FIND) ? 1 : 0;
66329 + }
66330 + tmp = tmp->next;
66331 + }
66332 + preempt_enable();
66333 + return (obj->mode & GR_FIND) ? 1 : 0;
66334 +}
66335 +
66336 +void gr_put_exec_file(struct task_struct *task)
66337 +{
66338 + struct file *filp;
66339 +
66340 + write_lock(&grsec_exec_file_lock);
66341 + filp = task->exec_file;
66342 + task->exec_file = NULL;
66343 + write_unlock(&grsec_exec_file_lock);
66344 +
66345 + if (filp)
66346 + fput(filp);
66347 +
66348 + return;
66349 +}
66350 +
66351 +
66352 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66353 +EXPORT_SYMBOL(gr_acl_is_enabled);
66354 +#endif
66355 +EXPORT_SYMBOL(gr_set_kernel_label);
66356 +#ifdef CONFIG_SECURITY
66357 +EXPORT_SYMBOL(gr_check_user_change);
66358 +EXPORT_SYMBOL(gr_check_group_change);
66359 +#endif
66360 +
66361 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66362 new file mode 100644
66363 index 0000000..34fefda
66364 --- /dev/null
66365 +++ b/grsecurity/gracl_alloc.c
66366 @@ -0,0 +1,105 @@
66367 +#include <linux/kernel.h>
66368 +#include <linux/mm.h>
66369 +#include <linux/slab.h>
66370 +#include <linux/vmalloc.h>
66371 +#include <linux/gracl.h>
66372 +#include <linux/grsecurity.h>
66373 +
66374 +static unsigned long alloc_stack_next = 1;
66375 +static unsigned long alloc_stack_size = 1;
66376 +static void **alloc_stack;
66377 +
66378 +static __inline__ int
66379 +alloc_pop(void)
66380 +{
66381 + if (alloc_stack_next == 1)
66382 + return 0;
66383 +
66384 + kfree(alloc_stack[alloc_stack_next - 2]);
66385 +
66386 + alloc_stack_next--;
66387 +
66388 + return 1;
66389 +}
66390 +
66391 +static __inline__ int
66392 +alloc_push(void *buf)
66393 +{
66394 + if (alloc_stack_next >= alloc_stack_size)
66395 + return 1;
66396 +
66397 + alloc_stack[alloc_stack_next - 1] = buf;
66398 +
66399 + alloc_stack_next++;
66400 +
66401 + return 0;
66402 +}
66403 +
66404 +void *
66405 +acl_alloc(unsigned long len)
66406 +{
66407 + void *ret = NULL;
66408 +
66409 + if (!len || len > PAGE_SIZE)
66410 + goto out;
66411 +
66412 + ret = kmalloc(len, GFP_KERNEL);
66413 +
66414 + if (ret) {
66415 + if (alloc_push(ret)) {
66416 + kfree(ret);
66417 + ret = NULL;
66418 + }
66419 + }
66420 +
66421 +out:
66422 + return ret;
66423 +}
66424 +
66425 +void *
66426 +acl_alloc_num(unsigned long num, unsigned long len)
66427 +{
66428 + if (!len || (num > (PAGE_SIZE / len)))
66429 + return NULL;
66430 +
66431 + return acl_alloc(num * len);
66432 +}
66433 +
66434 +void
66435 +acl_free_all(void)
66436 +{
66437 + if (gr_acl_is_enabled() || !alloc_stack)
66438 + return;
66439 +
66440 + while (alloc_pop()) ;
66441 +
66442 + if (alloc_stack) {
66443 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66444 + kfree(alloc_stack);
66445 + else
66446 + vfree(alloc_stack);
66447 + }
66448 +
66449 + alloc_stack = NULL;
66450 + alloc_stack_size = 1;
66451 + alloc_stack_next = 1;
66452 +
66453 + return;
66454 +}
66455 +
66456 +int
66457 +acl_alloc_stack_init(unsigned long size)
66458 +{
66459 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66460 + alloc_stack =
66461 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66462 + else
66463 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66464 +
66465 + alloc_stack_size = size;
66466 +
66467 + if (!alloc_stack)
66468 + return 0;
66469 + else
66470 + return 1;
66471 +}
66472 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66473 new file mode 100644
66474 index 0000000..bdd51ea
66475 --- /dev/null
66476 +++ b/grsecurity/gracl_cap.c
66477 @@ -0,0 +1,110 @@
66478 +#include <linux/kernel.h>
66479 +#include <linux/module.h>
66480 +#include <linux/sched.h>
66481 +#include <linux/gracl.h>
66482 +#include <linux/grsecurity.h>
66483 +#include <linux/grinternal.h>
66484 +
66485 +extern const char *captab_log[];
66486 +extern int captab_log_entries;
66487 +
66488 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66489 +{
66490 + struct acl_subject_label *curracl;
66491 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66492 + kernel_cap_t cap_audit = __cap_empty_set;
66493 +
66494 + if (!gr_acl_is_enabled())
66495 + return 1;
66496 +
66497 + curracl = task->acl;
66498 +
66499 + cap_drop = curracl->cap_lower;
66500 + cap_mask = curracl->cap_mask;
66501 + cap_audit = curracl->cap_invert_audit;
66502 +
66503 + while ((curracl = curracl->parent_subject)) {
66504 + /* if the cap isn't specified in the current computed mask but is specified in the
66505 + current level subject, and is lowered in the current level subject, then add
66506 + it to the set of dropped capabilities
66507 + otherwise, add the current level subject's mask to the current computed mask
66508 + */
66509 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66510 + cap_raise(cap_mask, cap);
66511 + if (cap_raised(curracl->cap_lower, cap))
66512 + cap_raise(cap_drop, cap);
66513 + if (cap_raised(curracl->cap_invert_audit, cap))
66514 + cap_raise(cap_audit, cap);
66515 + }
66516 + }
66517 +
66518 + if (!cap_raised(cap_drop, cap)) {
66519 + if (cap_raised(cap_audit, cap))
66520 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66521 + return 1;
66522 + }
66523 +
66524 + curracl = task->acl;
66525 +
66526 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66527 + && cap_raised(cred->cap_effective, cap)) {
66528 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66529 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66530 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66531 + gr_to_filename(task->exec_file->f_path.dentry,
66532 + task->exec_file->f_path.mnt) : curracl->filename,
66533 + curracl->filename, 0UL,
66534 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66535 + return 1;
66536 + }
66537 +
66538 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66539 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66540 +
66541 + return 0;
66542 +}
66543 +
66544 +int
66545 +gr_acl_is_capable(const int cap)
66546 +{
66547 + return gr_task_acl_is_capable(current, current_cred(), cap);
66548 +}
66549 +
66550 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66551 +{
66552 + struct acl_subject_label *curracl;
66553 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66554 +
66555 + if (!gr_acl_is_enabled())
66556 + return 1;
66557 +
66558 + curracl = task->acl;
66559 +
66560 + cap_drop = curracl->cap_lower;
66561 + cap_mask = curracl->cap_mask;
66562 +
66563 + while ((curracl = curracl->parent_subject)) {
66564 + /* if the cap isn't specified in the current computed mask but is specified in the
66565 + current level subject, and is lowered in the current level subject, then add
66566 + it to the set of dropped capabilities
66567 + otherwise, add the current level subject's mask to the current computed mask
66568 + */
66569 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66570 + cap_raise(cap_mask, cap);
66571 + if (cap_raised(curracl->cap_lower, cap))
66572 + cap_raise(cap_drop, cap);
66573 + }
66574 + }
66575 +
66576 + if (!cap_raised(cap_drop, cap))
66577 + return 1;
66578 +
66579 + return 0;
66580 +}
66581 +
66582 +int
66583 +gr_acl_is_capable_nolog(const int cap)
66584 +{
66585 + return gr_task_acl_is_capable_nolog(current, cap);
66586 +}
66587 +
66588 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66589 new file mode 100644
66590 index 0000000..a43dd06
66591 --- /dev/null
66592 +++ b/grsecurity/gracl_compat.c
66593 @@ -0,0 +1,269 @@
66594 +#include <linux/kernel.h>
66595 +#include <linux/gracl.h>
66596 +#include <linux/compat.h>
66597 +#include <linux/gracl_compat.h>
66598 +
66599 +#include <asm/uaccess.h>
66600 +
66601 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66602 +{
66603 + struct gr_arg_wrapper_compat uwrapcompat;
66604 +
66605 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66606 + return -EFAULT;
66607 +
66608 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66609 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66610 + return -EINVAL;
66611 +
66612 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66613 + uwrap->version = uwrapcompat.version;
66614 + uwrap->size = sizeof(struct gr_arg);
66615 +
66616 + return 0;
66617 +}
66618 +
66619 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66620 +{
66621 + struct gr_arg_compat argcompat;
66622 +
66623 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66624 + return -EFAULT;
66625 +
66626 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66627 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66628 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66629 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66630 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66631 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66632 +
66633 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66634 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66635 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66636 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66637 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66638 + arg->segv_device = argcompat.segv_device;
66639 + arg->segv_inode = argcompat.segv_inode;
66640 + arg->segv_uid = argcompat.segv_uid;
66641 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66642 + arg->mode = argcompat.mode;
66643 +
66644 + return 0;
66645 +}
66646 +
66647 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66648 +{
66649 + struct acl_object_label_compat objcompat;
66650 +
66651 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66652 + return -EFAULT;
66653 +
66654 + obj->filename = compat_ptr(objcompat.filename);
66655 + obj->inode = objcompat.inode;
66656 + obj->device = objcompat.device;
66657 + obj->mode = objcompat.mode;
66658 +
66659 + obj->nested = compat_ptr(objcompat.nested);
66660 + obj->globbed = compat_ptr(objcompat.globbed);
66661 +
66662 + obj->prev = compat_ptr(objcompat.prev);
66663 + obj->next = compat_ptr(objcompat.next);
66664 +
66665 + return 0;
66666 +}
66667 +
66668 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66669 +{
66670 + unsigned int i;
66671 + struct acl_subject_label_compat subjcompat;
66672 +
66673 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66674 + return -EFAULT;
66675 +
66676 + subj->filename = compat_ptr(subjcompat.filename);
66677 + subj->inode = subjcompat.inode;
66678 + subj->device = subjcompat.device;
66679 + subj->mode = subjcompat.mode;
66680 + subj->cap_mask = subjcompat.cap_mask;
66681 + subj->cap_lower = subjcompat.cap_lower;
66682 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66683 +
66684 + for (i = 0; i < GR_NLIMITS; i++) {
66685 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66686 + subj->res[i].rlim_cur = RLIM_INFINITY;
66687 + else
66688 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66689 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66690 + subj->res[i].rlim_max = RLIM_INFINITY;
66691 + else
66692 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66693 + }
66694 + subj->resmask = subjcompat.resmask;
66695 +
66696 + subj->user_trans_type = subjcompat.user_trans_type;
66697 + subj->group_trans_type = subjcompat.group_trans_type;
66698 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66699 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66700 + subj->user_trans_num = subjcompat.user_trans_num;
66701 + subj->group_trans_num = subjcompat.group_trans_num;
66702 +
66703 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66704 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66705 + subj->ip_type = subjcompat.ip_type;
66706 + subj->ips = compat_ptr(subjcompat.ips);
66707 + subj->ip_num = subjcompat.ip_num;
66708 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66709 +
66710 + subj->crashes = subjcompat.crashes;
66711 + subj->expires = subjcompat.expires;
66712 +
66713 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66714 + subj->hash = compat_ptr(subjcompat.hash);
66715 + subj->prev = compat_ptr(subjcompat.prev);
66716 + subj->next = compat_ptr(subjcompat.next);
66717 +
66718 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66719 + subj->obj_hash_size = subjcompat.obj_hash_size;
66720 + subj->pax_flags = subjcompat.pax_flags;
66721 +
66722 + return 0;
66723 +}
66724 +
66725 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66726 +{
66727 + struct acl_role_label_compat rolecompat;
66728 +
66729 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66730 + return -EFAULT;
66731 +
66732 + role->rolename = compat_ptr(rolecompat.rolename);
66733 + role->uidgid = rolecompat.uidgid;
66734 + role->roletype = rolecompat.roletype;
66735 +
66736 + role->auth_attempts = rolecompat.auth_attempts;
66737 + role->expires = rolecompat.expires;
66738 +
66739 + role->root_label = compat_ptr(rolecompat.root_label);
66740 + role->hash = compat_ptr(rolecompat.hash);
66741 +
66742 + role->prev = compat_ptr(rolecompat.prev);
66743 + role->next = compat_ptr(rolecompat.next);
66744 +
66745 + role->transitions = compat_ptr(rolecompat.transitions);
66746 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66747 + role->domain_children = compat_ptr(rolecompat.domain_children);
66748 + role->domain_child_num = rolecompat.domain_child_num;
66749 +
66750 + role->umask = rolecompat.umask;
66751 +
66752 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66753 + role->subj_hash_size = rolecompat.subj_hash_size;
66754 +
66755 + return 0;
66756 +}
66757 +
66758 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66759 +{
66760 + struct role_allowed_ip_compat roleip_compat;
66761 +
66762 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66763 + return -EFAULT;
66764 +
66765 + roleip->addr = roleip_compat.addr;
66766 + roleip->netmask = roleip_compat.netmask;
66767 +
66768 + roleip->prev = compat_ptr(roleip_compat.prev);
66769 + roleip->next = compat_ptr(roleip_compat.next);
66770 +
66771 + return 0;
66772 +}
66773 +
66774 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66775 +{
66776 + struct role_transition_compat trans_compat;
66777 +
66778 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66779 + return -EFAULT;
66780 +
66781 + trans->rolename = compat_ptr(trans_compat.rolename);
66782 +
66783 + trans->prev = compat_ptr(trans_compat.prev);
66784 + trans->next = compat_ptr(trans_compat.next);
66785 +
66786 + return 0;
66787 +
66788 +}
66789 +
66790 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66791 +{
66792 + struct gr_hash_struct_compat hash_compat;
66793 +
66794 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66795 + return -EFAULT;
66796 +
66797 + hash->table = compat_ptr(hash_compat.table);
66798 + hash->nametable = compat_ptr(hash_compat.nametable);
66799 + hash->first = compat_ptr(hash_compat.first);
66800 +
66801 + hash->table_size = hash_compat.table_size;
66802 + hash->used_size = hash_compat.used_size;
66803 +
66804 + hash->type = hash_compat.type;
66805 +
66806 + return 0;
66807 +}
66808 +
66809 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66810 +{
66811 + compat_uptr_t ptrcompat;
66812 +
66813 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66814 + return -EFAULT;
66815 +
66816 + *(void **)ptr = compat_ptr(ptrcompat);
66817 +
66818 + return 0;
66819 +}
66820 +
66821 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66822 +{
66823 + struct acl_ip_label_compat ip_compat;
66824 +
66825 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66826 + return -EFAULT;
66827 +
66828 + ip->iface = compat_ptr(ip_compat.iface);
66829 + ip->addr = ip_compat.addr;
66830 + ip->netmask = ip_compat.netmask;
66831 + ip->low = ip_compat.low;
66832 + ip->high = ip_compat.high;
66833 + ip->mode = ip_compat.mode;
66834 + ip->type = ip_compat.type;
66835 +
66836 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66837 +
66838 + ip->prev = compat_ptr(ip_compat.prev);
66839 + ip->next = compat_ptr(ip_compat.next);
66840 +
66841 + return 0;
66842 +}
66843 +
66844 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66845 +{
66846 + struct sprole_pw_compat pw_compat;
66847 +
66848 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66849 + return -EFAULT;
66850 +
66851 + pw->rolename = compat_ptr(pw_compat.rolename);
66852 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66853 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66854 +
66855 + return 0;
66856 +}
66857 +
66858 +size_t get_gr_arg_wrapper_size_compat(void)
66859 +{
66860 + return sizeof(struct gr_arg_wrapper_compat);
66861 +}
66862 +
66863 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66864 new file mode 100644
66865 index 0000000..a340c17
66866 --- /dev/null
66867 +++ b/grsecurity/gracl_fs.c
66868 @@ -0,0 +1,431 @@
66869 +#include <linux/kernel.h>
66870 +#include <linux/sched.h>
66871 +#include <linux/types.h>
66872 +#include <linux/fs.h>
66873 +#include <linux/file.h>
66874 +#include <linux/stat.h>
66875 +#include <linux/grsecurity.h>
66876 +#include <linux/grinternal.h>
66877 +#include <linux/gracl.h>
66878 +
66879 +umode_t
66880 +gr_acl_umask(void)
66881 +{
66882 + if (unlikely(!gr_acl_is_enabled()))
66883 + return 0;
66884 +
66885 + return current->role->umask;
66886 +}
66887 +
66888 +__u32
66889 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66890 + const struct vfsmount * mnt)
66891 +{
66892 + __u32 mode;
66893 +
66894 + if (unlikely(!dentry->d_inode))
66895 + return GR_FIND;
66896 +
66897 + mode =
66898 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66899 +
66900 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66901 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66902 + return mode;
66903 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66904 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66905 + return 0;
66906 + } else if (unlikely(!(mode & GR_FIND)))
66907 + return 0;
66908 +
66909 + return GR_FIND;
66910 +}
66911 +
66912 +__u32
66913 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66914 + int acc_mode)
66915 +{
66916 + __u32 reqmode = GR_FIND;
66917 + __u32 mode;
66918 +
66919 + if (unlikely(!dentry->d_inode))
66920 + return reqmode;
66921 +
66922 + if (acc_mode & MAY_APPEND)
66923 + reqmode |= GR_APPEND;
66924 + else if (acc_mode & MAY_WRITE)
66925 + reqmode |= GR_WRITE;
66926 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66927 + reqmode |= GR_READ;
66928 +
66929 + mode =
66930 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66931 + mnt);
66932 +
66933 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66934 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66935 + reqmode & GR_READ ? " reading" : "",
66936 + reqmode & GR_WRITE ? " writing" : reqmode &
66937 + GR_APPEND ? " appending" : "");
66938 + return reqmode;
66939 + } else
66940 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66941 + {
66942 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66943 + reqmode & GR_READ ? " reading" : "",
66944 + reqmode & GR_WRITE ? " writing" : reqmode &
66945 + GR_APPEND ? " appending" : "");
66946 + return 0;
66947 + } else if (unlikely((mode & reqmode) != reqmode))
66948 + return 0;
66949 +
66950 + return reqmode;
66951 +}
66952 +
66953 +__u32
66954 +gr_acl_handle_creat(const struct dentry * dentry,
66955 + const struct dentry * p_dentry,
66956 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66957 + const int imode)
66958 +{
66959 + __u32 reqmode = GR_WRITE | GR_CREATE;
66960 + __u32 mode;
66961 +
66962 + if (acc_mode & MAY_APPEND)
66963 + reqmode |= GR_APPEND;
66964 + // if a directory was required or the directory already exists, then
66965 + // don't count this open as a read
66966 + if ((acc_mode & MAY_READ) &&
66967 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66968 + reqmode |= GR_READ;
66969 + if ((open_flags & O_CREAT) &&
66970 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66971 + reqmode |= GR_SETID;
66972 +
66973 + mode =
66974 + gr_check_create(dentry, p_dentry, p_mnt,
66975 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66976 +
66977 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66978 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66979 + reqmode & GR_READ ? " reading" : "",
66980 + reqmode & GR_WRITE ? " writing" : reqmode &
66981 + GR_APPEND ? " appending" : "");
66982 + return reqmode;
66983 + } else
66984 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66985 + {
66986 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66987 + reqmode & GR_READ ? " reading" : "",
66988 + reqmode & GR_WRITE ? " writing" : reqmode &
66989 + GR_APPEND ? " appending" : "");
66990 + return 0;
66991 + } else if (unlikely((mode & reqmode) != reqmode))
66992 + return 0;
66993 +
66994 + return reqmode;
66995 +}
66996 +
66997 +__u32
66998 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66999 + const int fmode)
67000 +{
67001 + __u32 mode, reqmode = GR_FIND;
67002 +
67003 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67004 + reqmode |= GR_EXEC;
67005 + if (fmode & S_IWOTH)
67006 + reqmode |= GR_WRITE;
67007 + if (fmode & S_IROTH)
67008 + reqmode |= GR_READ;
67009 +
67010 + mode =
67011 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67012 + mnt);
67013 +
67014 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67015 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67016 + reqmode & GR_READ ? " reading" : "",
67017 + reqmode & GR_WRITE ? " writing" : "",
67018 + reqmode & GR_EXEC ? " executing" : "");
67019 + return reqmode;
67020 + } else
67021 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67022 + {
67023 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67024 + reqmode & GR_READ ? " reading" : "",
67025 + reqmode & GR_WRITE ? " writing" : "",
67026 + reqmode & GR_EXEC ? " executing" : "");
67027 + return 0;
67028 + } else if (unlikely((mode & reqmode) != reqmode))
67029 + return 0;
67030 +
67031 + return reqmode;
67032 +}
67033 +
67034 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67035 +{
67036 + __u32 mode;
67037 +
67038 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67039 +
67040 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67041 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67042 + return mode;
67043 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67044 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67045 + return 0;
67046 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67047 + return 0;
67048 +
67049 + return (reqmode);
67050 +}
67051 +
67052 +__u32
67053 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67054 +{
67055 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67056 +}
67057 +
67058 +__u32
67059 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67060 +{
67061 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67062 +}
67063 +
67064 +__u32
67065 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67066 +{
67067 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67068 +}
67069 +
67070 +__u32
67071 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67072 +{
67073 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67074 +}
67075 +
67076 +__u32
67077 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67078 + umode_t *modeptr)
67079 +{
67080 + umode_t mode;
67081 +
67082 + *modeptr &= ~gr_acl_umask();
67083 + mode = *modeptr;
67084 +
67085 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67086 + return 1;
67087 +
67088 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67089 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67090 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67091 + GR_CHMOD_ACL_MSG);
67092 + } else {
67093 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67094 + }
67095 +}
67096 +
67097 +__u32
67098 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67099 +{
67100 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67101 +}
67102 +
67103 +__u32
67104 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67105 +{
67106 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67107 +}
67108 +
67109 +__u32
67110 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67111 +{
67112 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67113 +}
67114 +
67115 +__u32
67116 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67117 +{
67118 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67119 + GR_UNIXCONNECT_ACL_MSG);
67120 +}
67121 +
67122 +/* hardlinks require at minimum create and link permission,
67123 + any additional privilege required is based on the
67124 + privilege of the file being linked to
67125 +*/
67126 +__u32
67127 +gr_acl_handle_link(const struct dentry * new_dentry,
67128 + const struct dentry * parent_dentry,
67129 + const struct vfsmount * parent_mnt,
67130 + const struct dentry * old_dentry,
67131 + const struct vfsmount * old_mnt, const struct filename *to)
67132 +{
67133 + __u32 mode;
67134 + __u32 needmode = GR_CREATE | GR_LINK;
67135 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67136 +
67137 + mode =
67138 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67139 + old_mnt);
67140 +
67141 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67142 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67143 + return mode;
67144 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67145 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67146 + return 0;
67147 + } else if (unlikely((mode & needmode) != needmode))
67148 + return 0;
67149 +
67150 + return 1;
67151 +}
67152 +
67153 +__u32
67154 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67155 + const struct dentry * parent_dentry,
67156 + const struct vfsmount * parent_mnt, const struct filename *from)
67157 +{
67158 + __u32 needmode = GR_WRITE | GR_CREATE;
67159 + __u32 mode;
67160 +
67161 + mode =
67162 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67163 + GR_CREATE | GR_AUDIT_CREATE |
67164 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67165 +
67166 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67167 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67168 + return mode;
67169 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67170 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67171 + return 0;
67172 + } else if (unlikely((mode & needmode) != needmode))
67173 + return 0;
67174 +
67175 + return (GR_WRITE | GR_CREATE);
67176 +}
67177 +
67178 +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)
67179 +{
67180 + __u32 mode;
67181 +
67182 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67183 +
67184 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67185 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67186 + return mode;
67187 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67188 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67189 + return 0;
67190 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67191 + return 0;
67192 +
67193 + return (reqmode);
67194 +}
67195 +
67196 +__u32
67197 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67198 + const struct dentry * parent_dentry,
67199 + const struct vfsmount * parent_mnt,
67200 + const int mode)
67201 +{
67202 + __u32 reqmode = GR_WRITE | GR_CREATE;
67203 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67204 + reqmode |= GR_SETID;
67205 +
67206 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67207 + reqmode, GR_MKNOD_ACL_MSG);
67208 +}
67209 +
67210 +__u32
67211 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67212 + const struct dentry *parent_dentry,
67213 + const struct vfsmount *parent_mnt)
67214 +{
67215 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67216 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67217 +}
67218 +
67219 +#define RENAME_CHECK_SUCCESS(old, new) \
67220 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67221 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67222 +
67223 +int
67224 +gr_acl_handle_rename(struct dentry *new_dentry,
67225 + struct dentry *parent_dentry,
67226 + const struct vfsmount *parent_mnt,
67227 + struct dentry *old_dentry,
67228 + struct inode *old_parent_inode,
67229 + struct vfsmount *old_mnt, const struct filename *newname)
67230 +{
67231 + __u32 comp1, comp2;
67232 + int error = 0;
67233 +
67234 + if (unlikely(!gr_acl_is_enabled()))
67235 + return 0;
67236 +
67237 + if (!new_dentry->d_inode) {
67238 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67239 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67240 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67241 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67242 + GR_DELETE | GR_AUDIT_DELETE |
67243 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67244 + GR_SUPPRESS, old_mnt);
67245 + } else {
67246 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67247 + GR_CREATE | GR_DELETE |
67248 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67249 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67250 + GR_SUPPRESS, parent_mnt);
67251 + comp2 =
67252 + gr_search_file(old_dentry,
67253 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67254 + GR_DELETE | GR_AUDIT_DELETE |
67255 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67256 + }
67257 +
67258 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67259 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67260 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67261 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67262 + && !(comp2 & GR_SUPPRESS)) {
67263 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67264 + error = -EACCES;
67265 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67266 + error = -EACCES;
67267 +
67268 + return error;
67269 +}
67270 +
67271 +void
67272 +gr_acl_handle_exit(void)
67273 +{
67274 + u16 id;
67275 + char *rolename;
67276 +
67277 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67278 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67279 + id = current->acl_role_id;
67280 + rolename = current->role->rolename;
67281 + gr_set_acls(1);
67282 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67283 + }
67284 +
67285 + gr_put_exec_file(current);
67286 + return;
67287 +}
67288 +
67289 +int
67290 +gr_acl_handle_procpidmem(const struct task_struct *task)
67291 +{
67292 + if (unlikely(!gr_acl_is_enabled()))
67293 + return 0;
67294 +
67295 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67296 + return -EACCES;
67297 +
67298 + return 0;
67299 +}
67300 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67301 new file mode 100644
67302 index 0000000..f056b81
67303 --- /dev/null
67304 +++ b/grsecurity/gracl_ip.c
67305 @@ -0,0 +1,386 @@
67306 +#include <linux/kernel.h>
67307 +#include <asm/uaccess.h>
67308 +#include <asm/errno.h>
67309 +#include <net/sock.h>
67310 +#include <linux/file.h>
67311 +#include <linux/fs.h>
67312 +#include <linux/net.h>
67313 +#include <linux/in.h>
67314 +#include <linux/skbuff.h>
67315 +#include <linux/ip.h>
67316 +#include <linux/udp.h>
67317 +#include <linux/types.h>
67318 +#include <linux/sched.h>
67319 +#include <linux/netdevice.h>
67320 +#include <linux/inetdevice.h>
67321 +#include <linux/gracl.h>
67322 +#include <linux/grsecurity.h>
67323 +#include <linux/grinternal.h>
67324 +
67325 +#define GR_BIND 0x01
67326 +#define GR_CONNECT 0x02
67327 +#define GR_INVERT 0x04
67328 +#define GR_BINDOVERRIDE 0x08
67329 +#define GR_CONNECTOVERRIDE 0x10
67330 +#define GR_SOCK_FAMILY 0x20
67331 +
67332 +static const char * gr_protocols[IPPROTO_MAX] = {
67333 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67334 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67335 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67336 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67337 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67338 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67339 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67340 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67341 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67342 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67343 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67344 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67345 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67346 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67347 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67348 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67349 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67350 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67351 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67352 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67353 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67354 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67355 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67356 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67357 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67358 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67359 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67360 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67361 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67362 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67363 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67364 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67365 + };
67366 +
67367 +static const char * gr_socktypes[SOCK_MAX] = {
67368 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67369 + "unknown:7", "unknown:8", "unknown:9", "packet"
67370 + };
67371 +
67372 +static const char * gr_sockfamilies[AF_MAX+1] = {
67373 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67374 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67375 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67376 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67377 + };
67378 +
67379 +const char *
67380 +gr_proto_to_name(unsigned char proto)
67381 +{
67382 + return gr_protocols[proto];
67383 +}
67384 +
67385 +const char *
67386 +gr_socktype_to_name(unsigned char type)
67387 +{
67388 + return gr_socktypes[type];
67389 +}
67390 +
67391 +const char *
67392 +gr_sockfamily_to_name(unsigned char family)
67393 +{
67394 + return gr_sockfamilies[family];
67395 +}
67396 +
67397 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67398 +
67399 +int
67400 +gr_search_socket(const int domain, const int type, const int protocol)
67401 +{
67402 + struct acl_subject_label *curr;
67403 + const struct cred *cred = current_cred();
67404 +
67405 + if (unlikely(!gr_acl_is_enabled()))
67406 + goto exit;
67407 +
67408 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67409 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67410 + goto exit; // let the kernel handle it
67411 +
67412 + curr = current->acl;
67413 +
67414 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67415 + /* the family is allowed, if this is PF_INET allow it only if
67416 + the extra sock type/protocol checks pass */
67417 + if (domain == PF_INET)
67418 + goto inet_check;
67419 + goto exit;
67420 + } else {
67421 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67422 + __u32 fakeip = 0;
67423 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67424 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67425 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67426 + gr_to_filename(current->exec_file->f_path.dentry,
67427 + current->exec_file->f_path.mnt) :
67428 + curr->filename, curr->filename,
67429 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67430 + &current->signal->saved_ip);
67431 + goto exit;
67432 + }
67433 + goto exit_fail;
67434 + }
67435 +
67436 +inet_check:
67437 + /* the rest of this checking is for IPv4 only */
67438 + if (!curr->ips)
67439 + goto exit;
67440 +
67441 + if ((curr->ip_type & (1U << type)) &&
67442 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67443 + goto exit;
67444 +
67445 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67446 + /* we don't place acls on raw sockets , and sometimes
67447 + dgram/ip sockets are opened for ioctl and not
67448 + bind/connect, so we'll fake a bind learn log */
67449 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67450 + __u32 fakeip = 0;
67451 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67452 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67453 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67454 + gr_to_filename(current->exec_file->f_path.dentry,
67455 + current->exec_file->f_path.mnt) :
67456 + curr->filename, curr->filename,
67457 + &fakeip, 0, type,
67458 + protocol, GR_CONNECT, &current->signal->saved_ip);
67459 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67460 + __u32 fakeip = 0;
67461 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67462 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67463 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67464 + gr_to_filename(current->exec_file->f_path.dentry,
67465 + current->exec_file->f_path.mnt) :
67466 + curr->filename, curr->filename,
67467 + &fakeip, 0, type,
67468 + protocol, GR_BIND, &current->signal->saved_ip);
67469 + }
67470 + /* we'll log when they use connect or bind */
67471 + goto exit;
67472 + }
67473 +
67474 +exit_fail:
67475 + if (domain == PF_INET)
67476 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67477 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67478 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67479 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67480 + gr_socktype_to_name(type), protocol);
67481 +
67482 + return 0;
67483 +exit:
67484 + return 1;
67485 +}
67486 +
67487 +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)
67488 +{
67489 + if ((ip->mode & mode) &&
67490 + (ip_port >= ip->low) &&
67491 + (ip_port <= ip->high) &&
67492 + ((ntohl(ip_addr) & our_netmask) ==
67493 + (ntohl(our_addr) & our_netmask))
67494 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67495 + && (ip->type & (1U << type))) {
67496 + if (ip->mode & GR_INVERT)
67497 + return 2; // specifically denied
67498 + else
67499 + return 1; // allowed
67500 + }
67501 +
67502 + return 0; // not specifically allowed, may continue parsing
67503 +}
67504 +
67505 +static int
67506 +gr_search_connectbind(const int full_mode, struct sock *sk,
67507 + struct sockaddr_in *addr, const int type)
67508 +{
67509 + char iface[IFNAMSIZ] = {0};
67510 + struct acl_subject_label *curr;
67511 + struct acl_ip_label *ip;
67512 + struct inet_sock *isk;
67513 + struct net_device *dev;
67514 + struct in_device *idev;
67515 + unsigned long i;
67516 + int ret;
67517 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67518 + __u32 ip_addr = 0;
67519 + __u32 our_addr;
67520 + __u32 our_netmask;
67521 + char *p;
67522 + __u16 ip_port = 0;
67523 + const struct cred *cred = current_cred();
67524 +
67525 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67526 + return 0;
67527 +
67528 + curr = current->acl;
67529 + isk = inet_sk(sk);
67530 +
67531 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67532 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67533 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67534 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67535 + struct sockaddr_in saddr;
67536 + int err;
67537 +
67538 + saddr.sin_family = AF_INET;
67539 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67540 + saddr.sin_port = isk->inet_sport;
67541 +
67542 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67543 + if (err)
67544 + return err;
67545 +
67546 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67547 + if (err)
67548 + return err;
67549 + }
67550 +
67551 + if (!curr->ips)
67552 + return 0;
67553 +
67554 + ip_addr = addr->sin_addr.s_addr;
67555 + ip_port = ntohs(addr->sin_port);
67556 +
67557 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67558 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67559 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67560 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67561 + gr_to_filename(current->exec_file->f_path.dentry,
67562 + current->exec_file->f_path.mnt) :
67563 + curr->filename, curr->filename,
67564 + &ip_addr, ip_port, type,
67565 + sk->sk_protocol, mode, &current->signal->saved_ip);
67566 + return 0;
67567 + }
67568 +
67569 + for (i = 0; i < curr->ip_num; i++) {
67570 + ip = *(curr->ips + i);
67571 + if (ip->iface != NULL) {
67572 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67573 + p = strchr(iface, ':');
67574 + if (p != NULL)
67575 + *p = '\0';
67576 + dev = dev_get_by_name(sock_net(sk), iface);
67577 + if (dev == NULL)
67578 + continue;
67579 + idev = in_dev_get(dev);
67580 + if (idev == NULL) {
67581 + dev_put(dev);
67582 + continue;
67583 + }
67584 + rcu_read_lock();
67585 + for_ifa(idev) {
67586 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67587 + our_addr = ifa->ifa_address;
67588 + our_netmask = 0xffffffff;
67589 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67590 + if (ret == 1) {
67591 + rcu_read_unlock();
67592 + in_dev_put(idev);
67593 + dev_put(dev);
67594 + return 0;
67595 + } else if (ret == 2) {
67596 + rcu_read_unlock();
67597 + in_dev_put(idev);
67598 + dev_put(dev);
67599 + goto denied;
67600 + }
67601 + }
67602 + } endfor_ifa(idev);
67603 + rcu_read_unlock();
67604 + in_dev_put(idev);
67605 + dev_put(dev);
67606 + } else {
67607 + our_addr = ip->addr;
67608 + our_netmask = ip->netmask;
67609 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67610 + if (ret == 1)
67611 + return 0;
67612 + else if (ret == 2)
67613 + goto denied;
67614 + }
67615 + }
67616 +
67617 +denied:
67618 + if (mode == GR_BIND)
67619 + 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));
67620 + else if (mode == GR_CONNECT)
67621 + 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));
67622 +
67623 + return -EACCES;
67624 +}
67625 +
67626 +int
67627 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67628 +{
67629 + /* always allow disconnection of dgram sockets with connect */
67630 + if (addr->sin_family == AF_UNSPEC)
67631 + return 0;
67632 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67633 +}
67634 +
67635 +int
67636 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67637 +{
67638 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67639 +}
67640 +
67641 +int gr_search_listen(struct socket *sock)
67642 +{
67643 + struct sock *sk = sock->sk;
67644 + struct sockaddr_in addr;
67645 +
67646 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67647 + addr.sin_port = inet_sk(sk)->inet_sport;
67648 +
67649 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67650 +}
67651 +
67652 +int gr_search_accept(struct socket *sock)
67653 +{
67654 + struct sock *sk = sock->sk;
67655 + struct sockaddr_in addr;
67656 +
67657 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67658 + addr.sin_port = inet_sk(sk)->inet_sport;
67659 +
67660 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67661 +}
67662 +
67663 +int
67664 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67665 +{
67666 + if (addr)
67667 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67668 + else {
67669 + struct sockaddr_in sin;
67670 + const struct inet_sock *inet = inet_sk(sk);
67671 +
67672 + sin.sin_addr.s_addr = inet->inet_daddr;
67673 + sin.sin_port = inet->inet_dport;
67674 +
67675 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67676 + }
67677 +}
67678 +
67679 +int
67680 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67681 +{
67682 + struct sockaddr_in sin;
67683 +
67684 + if (unlikely(skb->len < sizeof (struct udphdr)))
67685 + return 0; // skip this packet
67686 +
67687 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67688 + sin.sin_port = udp_hdr(skb)->source;
67689 +
67690 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67691 +}
67692 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67693 new file mode 100644
67694 index 0000000..25f54ef
67695 --- /dev/null
67696 +++ b/grsecurity/gracl_learn.c
67697 @@ -0,0 +1,207 @@
67698 +#include <linux/kernel.h>
67699 +#include <linux/mm.h>
67700 +#include <linux/sched.h>
67701 +#include <linux/poll.h>
67702 +#include <linux/string.h>
67703 +#include <linux/file.h>
67704 +#include <linux/types.h>
67705 +#include <linux/vmalloc.h>
67706 +#include <linux/grinternal.h>
67707 +
67708 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67709 + size_t count, loff_t *ppos);
67710 +extern int gr_acl_is_enabled(void);
67711 +
67712 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67713 +static int gr_learn_attached;
67714 +
67715 +/* use a 512k buffer */
67716 +#define LEARN_BUFFER_SIZE (512 * 1024)
67717 +
67718 +static DEFINE_SPINLOCK(gr_learn_lock);
67719 +static DEFINE_MUTEX(gr_learn_user_mutex);
67720 +
67721 +/* we need to maintain two buffers, so that the kernel context of grlearn
67722 + uses a semaphore around the userspace copying, and the other kernel contexts
67723 + use a spinlock when copying into the buffer, since they cannot sleep
67724 +*/
67725 +static char *learn_buffer;
67726 +static char *learn_buffer_user;
67727 +static int learn_buffer_len;
67728 +static int learn_buffer_user_len;
67729 +
67730 +static ssize_t
67731 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67732 +{
67733 + DECLARE_WAITQUEUE(wait, current);
67734 + ssize_t retval = 0;
67735 +
67736 + add_wait_queue(&learn_wait, &wait);
67737 + set_current_state(TASK_INTERRUPTIBLE);
67738 + do {
67739 + mutex_lock(&gr_learn_user_mutex);
67740 + spin_lock(&gr_learn_lock);
67741 + if (learn_buffer_len)
67742 + break;
67743 + spin_unlock(&gr_learn_lock);
67744 + mutex_unlock(&gr_learn_user_mutex);
67745 + if (file->f_flags & O_NONBLOCK) {
67746 + retval = -EAGAIN;
67747 + goto out;
67748 + }
67749 + if (signal_pending(current)) {
67750 + retval = -ERESTARTSYS;
67751 + goto out;
67752 + }
67753 +
67754 + schedule();
67755 + } while (1);
67756 +
67757 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67758 + learn_buffer_user_len = learn_buffer_len;
67759 + retval = learn_buffer_len;
67760 + learn_buffer_len = 0;
67761 +
67762 + spin_unlock(&gr_learn_lock);
67763 +
67764 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67765 + retval = -EFAULT;
67766 +
67767 + mutex_unlock(&gr_learn_user_mutex);
67768 +out:
67769 + set_current_state(TASK_RUNNING);
67770 + remove_wait_queue(&learn_wait, &wait);
67771 + return retval;
67772 +}
67773 +
67774 +static unsigned int
67775 +poll_learn(struct file * file, poll_table * wait)
67776 +{
67777 + poll_wait(file, &learn_wait, wait);
67778 +
67779 + if (learn_buffer_len)
67780 + return (POLLIN | POLLRDNORM);
67781 +
67782 + return 0;
67783 +}
67784 +
67785 +void
67786 +gr_clear_learn_entries(void)
67787 +{
67788 + char *tmp;
67789 +
67790 + mutex_lock(&gr_learn_user_mutex);
67791 + spin_lock(&gr_learn_lock);
67792 + tmp = learn_buffer;
67793 + learn_buffer = NULL;
67794 + spin_unlock(&gr_learn_lock);
67795 + if (tmp)
67796 + vfree(tmp);
67797 + if (learn_buffer_user != NULL) {
67798 + vfree(learn_buffer_user);
67799 + learn_buffer_user = NULL;
67800 + }
67801 + learn_buffer_len = 0;
67802 + mutex_unlock(&gr_learn_user_mutex);
67803 +
67804 + return;
67805 +}
67806 +
67807 +void
67808 +gr_add_learn_entry(const char *fmt, ...)
67809 +{
67810 + va_list args;
67811 + unsigned int len;
67812 +
67813 + if (!gr_learn_attached)
67814 + return;
67815 +
67816 + spin_lock(&gr_learn_lock);
67817 +
67818 + /* leave a gap at the end so we know when it's "full" but don't have to
67819 + compute the exact length of the string we're trying to append
67820 + */
67821 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67822 + spin_unlock(&gr_learn_lock);
67823 + wake_up_interruptible(&learn_wait);
67824 + return;
67825 + }
67826 + if (learn_buffer == NULL) {
67827 + spin_unlock(&gr_learn_lock);
67828 + return;
67829 + }
67830 +
67831 + va_start(args, fmt);
67832 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67833 + va_end(args);
67834 +
67835 + learn_buffer_len += len + 1;
67836 +
67837 + spin_unlock(&gr_learn_lock);
67838 + wake_up_interruptible(&learn_wait);
67839 +
67840 + return;
67841 +}
67842 +
67843 +static int
67844 +open_learn(struct inode *inode, struct file *file)
67845 +{
67846 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67847 + return -EBUSY;
67848 + if (file->f_mode & FMODE_READ) {
67849 + int retval = 0;
67850 + mutex_lock(&gr_learn_user_mutex);
67851 + if (learn_buffer == NULL)
67852 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67853 + if (learn_buffer_user == NULL)
67854 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67855 + if (learn_buffer == NULL) {
67856 + retval = -ENOMEM;
67857 + goto out_error;
67858 + }
67859 + if (learn_buffer_user == NULL) {
67860 + retval = -ENOMEM;
67861 + goto out_error;
67862 + }
67863 + learn_buffer_len = 0;
67864 + learn_buffer_user_len = 0;
67865 + gr_learn_attached = 1;
67866 +out_error:
67867 + mutex_unlock(&gr_learn_user_mutex);
67868 + return retval;
67869 + }
67870 + return 0;
67871 +}
67872 +
67873 +static int
67874 +close_learn(struct inode *inode, struct file *file)
67875 +{
67876 + if (file->f_mode & FMODE_READ) {
67877 + char *tmp = NULL;
67878 + mutex_lock(&gr_learn_user_mutex);
67879 + spin_lock(&gr_learn_lock);
67880 + tmp = learn_buffer;
67881 + learn_buffer = NULL;
67882 + spin_unlock(&gr_learn_lock);
67883 + if (tmp)
67884 + vfree(tmp);
67885 + if (learn_buffer_user != NULL) {
67886 + vfree(learn_buffer_user);
67887 + learn_buffer_user = NULL;
67888 + }
67889 + learn_buffer_len = 0;
67890 + learn_buffer_user_len = 0;
67891 + gr_learn_attached = 0;
67892 + mutex_unlock(&gr_learn_user_mutex);
67893 + }
67894 +
67895 + return 0;
67896 +}
67897 +
67898 +const struct file_operations grsec_fops = {
67899 + .read = read_learn,
67900 + .write = write_grsec_handler,
67901 + .open = open_learn,
67902 + .release = close_learn,
67903 + .poll = poll_learn,
67904 +};
67905 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67906 new file mode 100644
67907 index 0000000..39645c9
67908 --- /dev/null
67909 +++ b/grsecurity/gracl_res.c
67910 @@ -0,0 +1,68 @@
67911 +#include <linux/kernel.h>
67912 +#include <linux/sched.h>
67913 +#include <linux/gracl.h>
67914 +#include <linux/grinternal.h>
67915 +
67916 +static const char *restab_log[] = {
67917 + [RLIMIT_CPU] = "RLIMIT_CPU",
67918 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67919 + [RLIMIT_DATA] = "RLIMIT_DATA",
67920 + [RLIMIT_STACK] = "RLIMIT_STACK",
67921 + [RLIMIT_CORE] = "RLIMIT_CORE",
67922 + [RLIMIT_RSS] = "RLIMIT_RSS",
67923 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67924 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67925 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67926 + [RLIMIT_AS] = "RLIMIT_AS",
67927 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67928 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67929 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67930 + [RLIMIT_NICE] = "RLIMIT_NICE",
67931 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67932 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67933 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67934 +};
67935 +
67936 +void
67937 +gr_log_resource(const struct task_struct *task,
67938 + const int res, const unsigned long wanted, const int gt)
67939 +{
67940 + const struct cred *cred;
67941 + unsigned long rlim;
67942 +
67943 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67944 + return;
67945 +
67946 + // not yet supported resource
67947 + if (unlikely(!restab_log[res]))
67948 + return;
67949 +
67950 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67951 + rlim = task_rlimit_max(task, res);
67952 + else
67953 + rlim = task_rlimit(task, res);
67954 +
67955 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67956 + return;
67957 +
67958 + rcu_read_lock();
67959 + cred = __task_cred(task);
67960 +
67961 + if (res == RLIMIT_NPROC &&
67962 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67963 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
67964 + goto out_rcu_unlock;
67965 + else if (res == RLIMIT_MEMLOCK &&
67966 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
67967 + goto out_rcu_unlock;
67968 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
67969 + goto out_rcu_unlock;
67970 + rcu_read_unlock();
67971 +
67972 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
67973 +
67974 + return;
67975 +out_rcu_unlock:
67976 + rcu_read_unlock();
67977 + return;
67978 +}
67979 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
67980 new file mode 100644
67981 index 0000000..3c38bfe
67982 --- /dev/null
67983 +++ b/grsecurity/gracl_segv.c
67984 @@ -0,0 +1,305 @@
67985 +#include <linux/kernel.h>
67986 +#include <linux/mm.h>
67987 +#include <asm/uaccess.h>
67988 +#include <asm/errno.h>
67989 +#include <asm/mman.h>
67990 +#include <net/sock.h>
67991 +#include <linux/file.h>
67992 +#include <linux/fs.h>
67993 +#include <linux/net.h>
67994 +#include <linux/in.h>
67995 +#include <linux/slab.h>
67996 +#include <linux/types.h>
67997 +#include <linux/sched.h>
67998 +#include <linux/timer.h>
67999 +#include <linux/gracl.h>
68000 +#include <linux/grsecurity.h>
68001 +#include <linux/grinternal.h>
68002 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68003 +#include <linux/magic.h>
68004 +#include <linux/pagemap.h>
68005 +#include "../fs/btrfs/async-thread.h"
68006 +#include "../fs/btrfs/ctree.h"
68007 +#include "../fs/btrfs/btrfs_inode.h"
68008 +#endif
68009 +
68010 +static struct crash_uid *uid_set;
68011 +static unsigned short uid_used;
68012 +static DEFINE_SPINLOCK(gr_uid_lock);
68013 +extern rwlock_t gr_inode_lock;
68014 +extern struct acl_subject_label *
68015 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68016 + struct acl_role_label *role);
68017 +
68018 +static inline dev_t __get_dev(const struct dentry *dentry)
68019 +{
68020 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68021 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68022 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68023 + else
68024 +#endif
68025 + return dentry->d_sb->s_dev;
68026 +}
68027 +
68028 +int
68029 +gr_init_uidset(void)
68030 +{
68031 + uid_set =
68032 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68033 + uid_used = 0;
68034 +
68035 + return uid_set ? 1 : 0;
68036 +}
68037 +
68038 +void
68039 +gr_free_uidset(void)
68040 +{
68041 + if (uid_set)
68042 + kfree(uid_set);
68043 +
68044 + return;
68045 +}
68046 +
68047 +int
68048 +gr_find_uid(const uid_t uid)
68049 +{
68050 + struct crash_uid *tmp = uid_set;
68051 + uid_t buid;
68052 + int low = 0, high = uid_used - 1, mid;
68053 +
68054 + while (high >= low) {
68055 + mid = (low + high) >> 1;
68056 + buid = tmp[mid].uid;
68057 + if (buid == uid)
68058 + return mid;
68059 + if (buid > uid)
68060 + high = mid - 1;
68061 + if (buid < uid)
68062 + low = mid + 1;
68063 + }
68064 +
68065 + return -1;
68066 +}
68067 +
68068 +static __inline__ void
68069 +gr_insertsort(void)
68070 +{
68071 + unsigned short i, j;
68072 + struct crash_uid index;
68073 +
68074 + for (i = 1; i < uid_used; i++) {
68075 + index = uid_set[i];
68076 + j = i;
68077 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68078 + uid_set[j] = uid_set[j - 1];
68079 + j--;
68080 + }
68081 + uid_set[j] = index;
68082 + }
68083 +
68084 + return;
68085 +}
68086 +
68087 +static __inline__ void
68088 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68089 +{
68090 + int loc;
68091 + uid_t uid = GR_GLOBAL_UID(kuid);
68092 +
68093 + if (uid_used == GR_UIDTABLE_MAX)
68094 + return;
68095 +
68096 + loc = gr_find_uid(uid);
68097 +
68098 + if (loc >= 0) {
68099 + uid_set[loc].expires = expires;
68100 + return;
68101 + }
68102 +
68103 + uid_set[uid_used].uid = uid;
68104 + uid_set[uid_used].expires = expires;
68105 + uid_used++;
68106 +
68107 + gr_insertsort();
68108 +
68109 + return;
68110 +}
68111 +
68112 +void
68113 +gr_remove_uid(const unsigned short loc)
68114 +{
68115 + unsigned short i;
68116 +
68117 + for (i = loc + 1; i < uid_used; i++)
68118 + uid_set[i - 1] = uid_set[i];
68119 +
68120 + uid_used--;
68121 +
68122 + return;
68123 +}
68124 +
68125 +int
68126 +gr_check_crash_uid(const kuid_t kuid)
68127 +{
68128 + int loc;
68129 + int ret = 0;
68130 + uid_t uid;
68131 +
68132 + if (unlikely(!gr_acl_is_enabled()))
68133 + return 0;
68134 +
68135 + uid = GR_GLOBAL_UID(kuid);
68136 +
68137 + spin_lock(&gr_uid_lock);
68138 + loc = gr_find_uid(uid);
68139 +
68140 + if (loc < 0)
68141 + goto out_unlock;
68142 +
68143 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68144 + gr_remove_uid(loc);
68145 + else
68146 + ret = 1;
68147 +
68148 +out_unlock:
68149 + spin_unlock(&gr_uid_lock);
68150 + return ret;
68151 +}
68152 +
68153 +static __inline__ int
68154 +proc_is_setxid(const struct cred *cred)
68155 +{
68156 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68157 + !uid_eq(cred->uid, cred->fsuid))
68158 + return 1;
68159 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68160 + !gid_eq(cred->gid, cred->fsgid))
68161 + return 1;
68162 +
68163 + return 0;
68164 +}
68165 +
68166 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68167 +
68168 +void
68169 +gr_handle_crash(struct task_struct *task, const int sig)
68170 +{
68171 + struct acl_subject_label *curr;
68172 + struct task_struct *tsk, *tsk2;
68173 + const struct cred *cred;
68174 + const struct cred *cred2;
68175 +
68176 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68177 + return;
68178 +
68179 + if (unlikely(!gr_acl_is_enabled()))
68180 + return;
68181 +
68182 + curr = task->acl;
68183 +
68184 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68185 + return;
68186 +
68187 + if (time_before_eq(curr->expires, get_seconds())) {
68188 + curr->expires = 0;
68189 + curr->crashes = 0;
68190 + }
68191 +
68192 + curr->crashes++;
68193 +
68194 + if (!curr->expires)
68195 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68196 +
68197 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68198 + time_after(curr->expires, get_seconds())) {
68199 + rcu_read_lock();
68200 + cred = __task_cred(task);
68201 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68202 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68203 + spin_lock(&gr_uid_lock);
68204 + gr_insert_uid(cred->uid, curr->expires);
68205 + spin_unlock(&gr_uid_lock);
68206 + curr->expires = 0;
68207 + curr->crashes = 0;
68208 + read_lock(&tasklist_lock);
68209 + do_each_thread(tsk2, tsk) {
68210 + cred2 = __task_cred(tsk);
68211 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68212 + gr_fake_force_sig(SIGKILL, tsk);
68213 + } while_each_thread(tsk2, tsk);
68214 + read_unlock(&tasklist_lock);
68215 + } else {
68216 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68217 + read_lock(&tasklist_lock);
68218 + read_lock(&grsec_exec_file_lock);
68219 + do_each_thread(tsk2, tsk) {
68220 + if (likely(tsk != task)) {
68221 + // if this thread has the same subject as the one that triggered
68222 + // RES_CRASH and it's the same binary, kill it
68223 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68224 + gr_fake_force_sig(SIGKILL, tsk);
68225 + }
68226 + } while_each_thread(tsk2, tsk);
68227 + read_unlock(&grsec_exec_file_lock);
68228 + read_unlock(&tasklist_lock);
68229 + }
68230 + rcu_read_unlock();
68231 + }
68232 +
68233 + return;
68234 +}
68235 +
68236 +int
68237 +gr_check_crash_exec(const struct file *filp)
68238 +{
68239 + struct acl_subject_label *curr;
68240 +
68241 + if (unlikely(!gr_acl_is_enabled()))
68242 + return 0;
68243 +
68244 + read_lock(&gr_inode_lock);
68245 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68246 + __get_dev(filp->f_path.dentry),
68247 + current->role);
68248 + read_unlock(&gr_inode_lock);
68249 +
68250 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68251 + (!curr->crashes && !curr->expires))
68252 + return 0;
68253 +
68254 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68255 + time_after(curr->expires, get_seconds()))
68256 + return 1;
68257 + else if (time_before_eq(curr->expires, get_seconds())) {
68258 + curr->crashes = 0;
68259 + curr->expires = 0;
68260 + }
68261 +
68262 + return 0;
68263 +}
68264 +
68265 +void
68266 +gr_handle_alertkill(struct task_struct *task)
68267 +{
68268 + struct acl_subject_label *curracl;
68269 + __u32 curr_ip;
68270 + struct task_struct *p, *p2;
68271 +
68272 + if (unlikely(!gr_acl_is_enabled()))
68273 + return;
68274 +
68275 + curracl = task->acl;
68276 + curr_ip = task->signal->curr_ip;
68277 +
68278 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68279 + read_lock(&tasklist_lock);
68280 + do_each_thread(p2, p) {
68281 + if (p->signal->curr_ip == curr_ip)
68282 + gr_fake_force_sig(SIGKILL, p);
68283 + } while_each_thread(p2, p);
68284 + read_unlock(&tasklist_lock);
68285 + } else if (curracl->mode & GR_KILLPROC)
68286 + gr_fake_force_sig(SIGKILL, task);
68287 +
68288 + return;
68289 +}
68290 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68291 new file mode 100644
68292 index 0000000..98011b0
68293 --- /dev/null
68294 +++ b/grsecurity/gracl_shm.c
68295 @@ -0,0 +1,40 @@
68296 +#include <linux/kernel.h>
68297 +#include <linux/mm.h>
68298 +#include <linux/sched.h>
68299 +#include <linux/file.h>
68300 +#include <linux/ipc.h>
68301 +#include <linux/gracl.h>
68302 +#include <linux/grsecurity.h>
68303 +#include <linux/grinternal.h>
68304 +
68305 +int
68306 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68307 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68308 +{
68309 + struct task_struct *task;
68310 +
68311 + if (!gr_acl_is_enabled())
68312 + return 1;
68313 +
68314 + rcu_read_lock();
68315 + read_lock(&tasklist_lock);
68316 +
68317 + task = find_task_by_vpid(shm_cprid);
68318 +
68319 + if (unlikely(!task))
68320 + task = find_task_by_vpid(shm_lapid);
68321 +
68322 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68323 + (task_pid_nr(task) == shm_lapid)) &&
68324 + (task->acl->mode & GR_PROTSHM) &&
68325 + (task->acl != current->acl))) {
68326 + read_unlock(&tasklist_lock);
68327 + rcu_read_unlock();
68328 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68329 + return 0;
68330 + }
68331 + read_unlock(&tasklist_lock);
68332 + rcu_read_unlock();
68333 +
68334 + return 1;
68335 +}
68336 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68337 new file mode 100644
68338 index 0000000..bc0be01
68339 --- /dev/null
68340 +++ b/grsecurity/grsec_chdir.c
68341 @@ -0,0 +1,19 @@
68342 +#include <linux/kernel.h>
68343 +#include <linux/sched.h>
68344 +#include <linux/fs.h>
68345 +#include <linux/file.h>
68346 +#include <linux/grsecurity.h>
68347 +#include <linux/grinternal.h>
68348 +
68349 +void
68350 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68351 +{
68352 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68353 + if ((grsec_enable_chdir && grsec_enable_group &&
68354 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68355 + !grsec_enable_group)) {
68356 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68357 + }
68358 +#endif
68359 + return;
68360 +}
68361 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68362 new file mode 100644
68363 index 0000000..bd6e105
68364 --- /dev/null
68365 +++ b/grsecurity/grsec_chroot.c
68366 @@ -0,0 +1,370 @@
68367 +#include <linux/kernel.h>
68368 +#include <linux/module.h>
68369 +#include <linux/sched.h>
68370 +#include <linux/file.h>
68371 +#include <linux/fs.h>
68372 +#include <linux/mount.h>
68373 +#include <linux/types.h>
68374 +#include "../fs/mount.h"
68375 +#include <linux/grsecurity.h>
68376 +#include <linux/grinternal.h>
68377 +
68378 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68379 +static int gr_init_ran;
68380 +#endif
68381 +
68382 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68383 +{
68384 +#ifdef CONFIG_GRKERNSEC
68385 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68386 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68387 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68388 + && gr_init_ran
68389 +#endif
68390 + )
68391 + task->gr_is_chrooted = 1;
68392 + else {
68393 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68394 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68395 + gr_init_ran = 1;
68396 +#endif
68397 + task->gr_is_chrooted = 0;
68398 + }
68399 +
68400 + task->gr_chroot_dentry = path->dentry;
68401 +#endif
68402 + return;
68403 +}
68404 +
68405 +void gr_clear_chroot_entries(struct task_struct *task)
68406 +{
68407 +#ifdef CONFIG_GRKERNSEC
68408 + task->gr_is_chrooted = 0;
68409 + task->gr_chroot_dentry = NULL;
68410 +#endif
68411 + return;
68412 +}
68413 +
68414 +int
68415 +gr_handle_chroot_unix(const pid_t pid)
68416 +{
68417 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68418 + struct task_struct *p;
68419 +
68420 + if (unlikely(!grsec_enable_chroot_unix))
68421 + return 1;
68422 +
68423 + if (likely(!proc_is_chrooted(current)))
68424 + return 1;
68425 +
68426 + rcu_read_lock();
68427 + read_lock(&tasklist_lock);
68428 + p = find_task_by_vpid_unrestricted(pid);
68429 + if (unlikely(p && !have_same_root(current, p))) {
68430 + read_unlock(&tasklist_lock);
68431 + rcu_read_unlock();
68432 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68433 + return 0;
68434 + }
68435 + read_unlock(&tasklist_lock);
68436 + rcu_read_unlock();
68437 +#endif
68438 + return 1;
68439 +}
68440 +
68441 +int
68442 +gr_handle_chroot_nice(void)
68443 +{
68444 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68445 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68446 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68447 + return -EPERM;
68448 + }
68449 +#endif
68450 + return 0;
68451 +}
68452 +
68453 +int
68454 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68455 +{
68456 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68457 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68458 + && proc_is_chrooted(current)) {
68459 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68460 + return -EACCES;
68461 + }
68462 +#endif
68463 + return 0;
68464 +}
68465 +
68466 +int
68467 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68468 +{
68469 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68470 + struct task_struct *p;
68471 + int ret = 0;
68472 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68473 + return ret;
68474 +
68475 + read_lock(&tasklist_lock);
68476 + do_each_pid_task(pid, type, p) {
68477 + if (!have_same_root(current, p)) {
68478 + ret = 1;
68479 + goto out;
68480 + }
68481 + } while_each_pid_task(pid, type, p);
68482 +out:
68483 + read_unlock(&tasklist_lock);
68484 + return ret;
68485 +#endif
68486 + return 0;
68487 +}
68488 +
68489 +int
68490 +gr_pid_is_chrooted(struct task_struct *p)
68491 +{
68492 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68493 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68494 + return 0;
68495 +
68496 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68497 + !have_same_root(current, p)) {
68498 + return 1;
68499 + }
68500 +#endif
68501 + return 0;
68502 +}
68503 +
68504 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68505 +
68506 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68507 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68508 +{
68509 + struct path path, currentroot;
68510 + int ret = 0;
68511 +
68512 + path.dentry = (struct dentry *)u_dentry;
68513 + path.mnt = (struct vfsmount *)u_mnt;
68514 + get_fs_root(current->fs, &currentroot);
68515 + if (path_is_under(&path, &currentroot))
68516 + ret = 1;
68517 + path_put(&currentroot);
68518 +
68519 + return ret;
68520 +}
68521 +#endif
68522 +
68523 +int
68524 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68525 +{
68526 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68527 + if (!grsec_enable_chroot_fchdir)
68528 + return 1;
68529 +
68530 + if (!proc_is_chrooted(current))
68531 + return 1;
68532 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68533 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68534 + return 0;
68535 + }
68536 +#endif
68537 + return 1;
68538 +}
68539 +
68540 +int
68541 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68542 + const time_t shm_createtime)
68543 +{
68544 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68545 + struct task_struct *p;
68546 + time_t starttime;
68547 +
68548 + if (unlikely(!grsec_enable_chroot_shmat))
68549 + return 1;
68550 +
68551 + if (likely(!proc_is_chrooted(current)))
68552 + return 1;
68553 +
68554 + rcu_read_lock();
68555 + read_lock(&tasklist_lock);
68556 +
68557 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68558 + starttime = p->start_time.tv_sec;
68559 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68560 + if (have_same_root(current, p)) {
68561 + goto allow;
68562 + } else {
68563 + read_unlock(&tasklist_lock);
68564 + rcu_read_unlock();
68565 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68566 + return 0;
68567 + }
68568 + }
68569 + /* creator exited, pid reuse, fall through to next check */
68570 + }
68571 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68572 + if (unlikely(!have_same_root(current, p))) {
68573 + read_unlock(&tasklist_lock);
68574 + rcu_read_unlock();
68575 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68576 + return 0;
68577 + }
68578 + }
68579 +
68580 +allow:
68581 + read_unlock(&tasklist_lock);
68582 + rcu_read_unlock();
68583 +#endif
68584 + return 1;
68585 +}
68586 +
68587 +void
68588 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68589 +{
68590 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68591 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68592 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68593 +#endif
68594 + return;
68595 +}
68596 +
68597 +int
68598 +gr_handle_chroot_mknod(const struct dentry *dentry,
68599 + const struct vfsmount *mnt, const int mode)
68600 +{
68601 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68602 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68603 + proc_is_chrooted(current)) {
68604 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68605 + return -EPERM;
68606 + }
68607 +#endif
68608 + return 0;
68609 +}
68610 +
68611 +int
68612 +gr_handle_chroot_mount(const struct dentry *dentry,
68613 + const struct vfsmount *mnt, const char *dev_name)
68614 +{
68615 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68616 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68617 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68618 + return -EPERM;
68619 + }
68620 +#endif
68621 + return 0;
68622 +}
68623 +
68624 +int
68625 +gr_handle_chroot_pivot(void)
68626 +{
68627 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68628 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68629 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68630 + return -EPERM;
68631 + }
68632 +#endif
68633 + return 0;
68634 +}
68635 +
68636 +int
68637 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68638 +{
68639 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68640 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68641 + !gr_is_outside_chroot(dentry, mnt)) {
68642 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68643 + return -EPERM;
68644 + }
68645 +#endif
68646 + return 0;
68647 +}
68648 +
68649 +extern const char *captab_log[];
68650 +extern int captab_log_entries;
68651 +
68652 +int
68653 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68654 +{
68655 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68656 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68657 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68658 + if (cap_raised(chroot_caps, cap)) {
68659 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68660 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68661 + }
68662 + return 0;
68663 + }
68664 + }
68665 +#endif
68666 + return 1;
68667 +}
68668 +
68669 +int
68670 +gr_chroot_is_capable(const int cap)
68671 +{
68672 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68673 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68674 +#endif
68675 + return 1;
68676 +}
68677 +
68678 +int
68679 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68680 +{
68681 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68682 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68683 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68684 + if (cap_raised(chroot_caps, cap)) {
68685 + return 0;
68686 + }
68687 + }
68688 +#endif
68689 + return 1;
68690 +}
68691 +
68692 +int
68693 +gr_chroot_is_capable_nolog(const int cap)
68694 +{
68695 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68696 + return gr_task_chroot_is_capable_nolog(current, cap);
68697 +#endif
68698 + return 1;
68699 +}
68700 +
68701 +int
68702 +gr_handle_chroot_sysctl(const int op)
68703 +{
68704 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68705 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68706 + proc_is_chrooted(current))
68707 + return -EACCES;
68708 +#endif
68709 + return 0;
68710 +}
68711 +
68712 +void
68713 +gr_handle_chroot_chdir(const struct path *path)
68714 +{
68715 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68716 + if (grsec_enable_chroot_chdir)
68717 + set_fs_pwd(current->fs, path);
68718 +#endif
68719 + return;
68720 +}
68721 +
68722 +int
68723 +gr_handle_chroot_chmod(const struct dentry *dentry,
68724 + const struct vfsmount *mnt, const int mode)
68725 +{
68726 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68727 + /* allow chmod +s on directories, but not files */
68728 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68729 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68730 + proc_is_chrooted(current)) {
68731 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68732 + return -EPERM;
68733 + }
68734 +#endif
68735 + return 0;
68736 +}
68737 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68738 new file mode 100644
68739 index 0000000..ce65ceb
68740 --- /dev/null
68741 +++ b/grsecurity/grsec_disabled.c
68742 @@ -0,0 +1,434 @@
68743 +#include <linux/kernel.h>
68744 +#include <linux/module.h>
68745 +#include <linux/sched.h>
68746 +#include <linux/file.h>
68747 +#include <linux/fs.h>
68748 +#include <linux/kdev_t.h>
68749 +#include <linux/net.h>
68750 +#include <linux/in.h>
68751 +#include <linux/ip.h>
68752 +#include <linux/skbuff.h>
68753 +#include <linux/sysctl.h>
68754 +
68755 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68756 +void
68757 +pax_set_initial_flags(struct linux_binprm *bprm)
68758 +{
68759 + return;
68760 +}
68761 +#endif
68762 +
68763 +#ifdef CONFIG_SYSCTL
68764 +__u32
68765 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68766 +{
68767 + return 0;
68768 +}
68769 +#endif
68770 +
68771 +#ifdef CONFIG_TASKSTATS
68772 +int gr_is_taskstats_denied(int pid)
68773 +{
68774 + return 0;
68775 +}
68776 +#endif
68777 +
68778 +int
68779 +gr_acl_is_enabled(void)
68780 +{
68781 + return 0;
68782 +}
68783 +
68784 +void
68785 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68786 +{
68787 + return;
68788 +}
68789 +
68790 +int
68791 +gr_handle_rawio(const struct inode *inode)
68792 +{
68793 + return 0;
68794 +}
68795 +
68796 +void
68797 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68798 +{
68799 + return;
68800 +}
68801 +
68802 +int
68803 +gr_handle_ptrace(struct task_struct *task, const long request)
68804 +{
68805 + return 0;
68806 +}
68807 +
68808 +int
68809 +gr_handle_proc_ptrace(struct task_struct *task)
68810 +{
68811 + return 0;
68812 +}
68813 +
68814 +int
68815 +gr_set_acls(const int type)
68816 +{
68817 + return 0;
68818 +}
68819 +
68820 +int
68821 +gr_check_hidden_task(const struct task_struct *tsk)
68822 +{
68823 + return 0;
68824 +}
68825 +
68826 +int
68827 +gr_check_protected_task(const struct task_struct *task)
68828 +{
68829 + return 0;
68830 +}
68831 +
68832 +int
68833 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68834 +{
68835 + return 0;
68836 +}
68837 +
68838 +void
68839 +gr_copy_label(struct task_struct *tsk)
68840 +{
68841 + return;
68842 +}
68843 +
68844 +void
68845 +gr_set_pax_flags(struct task_struct *task)
68846 +{
68847 + return;
68848 +}
68849 +
68850 +int
68851 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68852 + const int unsafe_share)
68853 +{
68854 + return 0;
68855 +}
68856 +
68857 +void
68858 +gr_handle_delete(const ino_t ino, const dev_t dev)
68859 +{
68860 + return;
68861 +}
68862 +
68863 +void
68864 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68865 +{
68866 + return;
68867 +}
68868 +
68869 +void
68870 +gr_handle_crash(struct task_struct *task, const int sig)
68871 +{
68872 + return;
68873 +}
68874 +
68875 +int
68876 +gr_check_crash_exec(const struct file *filp)
68877 +{
68878 + return 0;
68879 +}
68880 +
68881 +int
68882 +gr_check_crash_uid(const kuid_t uid)
68883 +{
68884 + return 0;
68885 +}
68886 +
68887 +void
68888 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68889 + struct dentry *old_dentry,
68890 + struct dentry *new_dentry,
68891 + struct vfsmount *mnt, const __u8 replace)
68892 +{
68893 + return;
68894 +}
68895 +
68896 +int
68897 +gr_search_socket(const int family, const int type, const int protocol)
68898 +{
68899 + return 1;
68900 +}
68901 +
68902 +int
68903 +gr_search_connectbind(const int mode, const struct socket *sock,
68904 + const struct sockaddr_in *addr)
68905 +{
68906 + return 0;
68907 +}
68908 +
68909 +void
68910 +gr_handle_alertkill(struct task_struct *task)
68911 +{
68912 + return;
68913 +}
68914 +
68915 +__u32
68916 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68917 +{
68918 + return 1;
68919 +}
68920 +
68921 +__u32
68922 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68923 + const struct vfsmount * mnt)
68924 +{
68925 + return 1;
68926 +}
68927 +
68928 +__u32
68929 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68930 + int acc_mode)
68931 +{
68932 + return 1;
68933 +}
68934 +
68935 +__u32
68936 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68937 +{
68938 + return 1;
68939 +}
68940 +
68941 +__u32
68942 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68943 +{
68944 + return 1;
68945 +}
68946 +
68947 +int
68948 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68949 + unsigned int *vm_flags)
68950 +{
68951 + return 1;
68952 +}
68953 +
68954 +__u32
68955 +gr_acl_handle_truncate(const struct dentry * dentry,
68956 + const struct vfsmount * mnt)
68957 +{
68958 + return 1;
68959 +}
68960 +
68961 +__u32
68962 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68963 +{
68964 + return 1;
68965 +}
68966 +
68967 +__u32
68968 +gr_acl_handle_access(const struct dentry * dentry,
68969 + const struct vfsmount * mnt, const int fmode)
68970 +{
68971 + return 1;
68972 +}
68973 +
68974 +__u32
68975 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
68976 + umode_t *mode)
68977 +{
68978 + return 1;
68979 +}
68980 +
68981 +__u32
68982 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
68983 +{
68984 + return 1;
68985 +}
68986 +
68987 +__u32
68988 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
68989 +{
68990 + return 1;
68991 +}
68992 +
68993 +void
68994 +grsecurity_init(void)
68995 +{
68996 + return;
68997 +}
68998 +
68999 +umode_t gr_acl_umask(void)
69000 +{
69001 + return 0;
69002 +}
69003 +
69004 +__u32
69005 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69006 + const struct dentry * parent_dentry,
69007 + const struct vfsmount * parent_mnt,
69008 + const int mode)
69009 +{
69010 + return 1;
69011 +}
69012 +
69013 +__u32
69014 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69015 + const struct dentry * parent_dentry,
69016 + const struct vfsmount * parent_mnt)
69017 +{
69018 + return 1;
69019 +}
69020 +
69021 +__u32
69022 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69023 + const struct dentry * parent_dentry,
69024 + const struct vfsmount * parent_mnt, const struct filename *from)
69025 +{
69026 + return 1;
69027 +}
69028 +
69029 +__u32
69030 +gr_acl_handle_link(const struct dentry * new_dentry,
69031 + const struct dentry * parent_dentry,
69032 + const struct vfsmount * parent_mnt,
69033 + const struct dentry * old_dentry,
69034 + const struct vfsmount * old_mnt, const struct filename *to)
69035 +{
69036 + return 1;
69037 +}
69038 +
69039 +int
69040 +gr_acl_handle_rename(const struct dentry *new_dentry,
69041 + const struct dentry *parent_dentry,
69042 + const struct vfsmount *parent_mnt,
69043 + const struct dentry *old_dentry,
69044 + const struct inode *old_parent_inode,
69045 + const struct vfsmount *old_mnt, const struct filename *newname)
69046 +{
69047 + return 0;
69048 +}
69049 +
69050 +int
69051 +gr_acl_handle_filldir(const struct file *file, const char *name,
69052 + const int namelen, const ino_t ino)
69053 +{
69054 + return 1;
69055 +}
69056 +
69057 +int
69058 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69059 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69060 +{
69061 + return 1;
69062 +}
69063 +
69064 +int
69065 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69066 +{
69067 + return 0;
69068 +}
69069 +
69070 +int
69071 +gr_search_accept(const struct socket *sock)
69072 +{
69073 + return 0;
69074 +}
69075 +
69076 +int
69077 +gr_search_listen(const struct socket *sock)
69078 +{
69079 + return 0;
69080 +}
69081 +
69082 +int
69083 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69084 +{
69085 + return 0;
69086 +}
69087 +
69088 +__u32
69089 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69090 +{
69091 + return 1;
69092 +}
69093 +
69094 +__u32
69095 +gr_acl_handle_creat(const struct dentry * dentry,
69096 + const struct dentry * p_dentry,
69097 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69098 + const int imode)
69099 +{
69100 + return 1;
69101 +}
69102 +
69103 +void
69104 +gr_acl_handle_exit(void)
69105 +{
69106 + return;
69107 +}
69108 +
69109 +int
69110 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69111 +{
69112 + return 1;
69113 +}
69114 +
69115 +void
69116 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69117 +{
69118 + return;
69119 +}
69120 +
69121 +int
69122 +gr_acl_handle_procpidmem(const struct task_struct *task)
69123 +{
69124 + return 0;
69125 +}
69126 +
69127 +int
69128 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69129 +{
69130 + return 0;
69131 +}
69132 +
69133 +int
69134 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69135 +{
69136 + return 0;
69137 +}
69138 +
69139 +void
69140 +gr_set_kernel_label(struct task_struct *task)
69141 +{
69142 + return;
69143 +}
69144 +
69145 +int
69146 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69147 +{
69148 + return 0;
69149 +}
69150 +
69151 +int
69152 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69153 +{
69154 + return 0;
69155 +}
69156 +
69157 +int gr_acl_enable_at_secure(void)
69158 +{
69159 + return 0;
69160 +}
69161 +
69162 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69163 +{
69164 + return dentry->d_sb->s_dev;
69165 +}
69166 +
69167 +void gr_put_exec_file(struct task_struct *task)
69168 +{
69169 + return;
69170 +}
69171 +
69172 +EXPORT_SYMBOL(gr_set_kernel_label);
69173 +#ifdef CONFIG_SECURITY
69174 +EXPORT_SYMBOL(gr_check_user_change);
69175 +EXPORT_SYMBOL(gr_check_group_change);
69176 +#endif
69177 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69178 new file mode 100644
69179 index 0000000..387032b
69180 --- /dev/null
69181 +++ b/grsecurity/grsec_exec.c
69182 @@ -0,0 +1,187 @@
69183 +#include <linux/kernel.h>
69184 +#include <linux/sched.h>
69185 +#include <linux/file.h>
69186 +#include <linux/binfmts.h>
69187 +#include <linux/fs.h>
69188 +#include <linux/types.h>
69189 +#include <linux/grdefs.h>
69190 +#include <linux/grsecurity.h>
69191 +#include <linux/grinternal.h>
69192 +#include <linux/capability.h>
69193 +#include <linux/module.h>
69194 +#include <linux/compat.h>
69195 +
69196 +#include <asm/uaccess.h>
69197 +
69198 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69199 +static char gr_exec_arg_buf[132];
69200 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69201 +#endif
69202 +
69203 +struct user_arg_ptr {
69204 +#ifdef CONFIG_COMPAT
69205 + bool is_compat;
69206 +#endif
69207 + union {
69208 + const char __user *const __user *native;
69209 +#ifdef CONFIG_COMPAT
69210 + const compat_uptr_t __user *compat;
69211 +#endif
69212 + } ptr;
69213 +};
69214 +
69215 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69216 +
69217 +void
69218 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69219 +{
69220 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69221 + char *grarg = gr_exec_arg_buf;
69222 + unsigned int i, x, execlen = 0;
69223 + char c;
69224 +
69225 + if (!((grsec_enable_execlog && grsec_enable_group &&
69226 + in_group_p(grsec_audit_gid))
69227 + || (grsec_enable_execlog && !grsec_enable_group)))
69228 + return;
69229 +
69230 + mutex_lock(&gr_exec_arg_mutex);
69231 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69232 +
69233 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69234 + const char __user *p;
69235 + unsigned int len;
69236 +
69237 + p = get_user_arg_ptr(argv, i);
69238 + if (IS_ERR(p))
69239 + goto log;
69240 +
69241 + len = strnlen_user(p, 128 - execlen);
69242 + if (len > 128 - execlen)
69243 + len = 128 - execlen;
69244 + else if (len > 0)
69245 + len--;
69246 + if (copy_from_user(grarg + execlen, p, len))
69247 + goto log;
69248 +
69249 + /* rewrite unprintable characters */
69250 + for (x = 0; x < len; x++) {
69251 + c = *(grarg + execlen + x);
69252 + if (c < 32 || c > 126)
69253 + *(grarg + execlen + x) = ' ';
69254 + }
69255 +
69256 + execlen += len;
69257 + *(grarg + execlen) = ' ';
69258 + *(grarg + execlen + 1) = '\0';
69259 + execlen++;
69260 + }
69261 +
69262 + log:
69263 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69264 + bprm->file->f_path.mnt, grarg);
69265 + mutex_unlock(&gr_exec_arg_mutex);
69266 +#endif
69267 + return;
69268 +}
69269 +
69270 +#ifdef CONFIG_GRKERNSEC
69271 +extern int gr_acl_is_capable(const int cap);
69272 +extern int gr_acl_is_capable_nolog(const int cap);
69273 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69274 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69275 +extern int gr_chroot_is_capable(const int cap);
69276 +extern int gr_chroot_is_capable_nolog(const int cap);
69277 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69278 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69279 +#endif
69280 +
69281 +const char *captab_log[] = {
69282 + "CAP_CHOWN",
69283 + "CAP_DAC_OVERRIDE",
69284 + "CAP_DAC_READ_SEARCH",
69285 + "CAP_FOWNER",
69286 + "CAP_FSETID",
69287 + "CAP_KILL",
69288 + "CAP_SETGID",
69289 + "CAP_SETUID",
69290 + "CAP_SETPCAP",
69291 + "CAP_LINUX_IMMUTABLE",
69292 + "CAP_NET_BIND_SERVICE",
69293 + "CAP_NET_BROADCAST",
69294 + "CAP_NET_ADMIN",
69295 + "CAP_NET_RAW",
69296 + "CAP_IPC_LOCK",
69297 + "CAP_IPC_OWNER",
69298 + "CAP_SYS_MODULE",
69299 + "CAP_SYS_RAWIO",
69300 + "CAP_SYS_CHROOT",
69301 + "CAP_SYS_PTRACE",
69302 + "CAP_SYS_PACCT",
69303 + "CAP_SYS_ADMIN",
69304 + "CAP_SYS_BOOT",
69305 + "CAP_SYS_NICE",
69306 + "CAP_SYS_RESOURCE",
69307 + "CAP_SYS_TIME",
69308 + "CAP_SYS_TTY_CONFIG",
69309 + "CAP_MKNOD",
69310 + "CAP_LEASE",
69311 + "CAP_AUDIT_WRITE",
69312 + "CAP_AUDIT_CONTROL",
69313 + "CAP_SETFCAP",
69314 + "CAP_MAC_OVERRIDE",
69315 + "CAP_MAC_ADMIN",
69316 + "CAP_SYSLOG",
69317 + "CAP_WAKE_ALARM"
69318 +};
69319 +
69320 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69321 +
69322 +int gr_is_capable(const int cap)
69323 +{
69324 +#ifdef CONFIG_GRKERNSEC
69325 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69326 + return 1;
69327 + return 0;
69328 +#else
69329 + return 1;
69330 +#endif
69331 +}
69332 +
69333 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69334 +{
69335 +#ifdef CONFIG_GRKERNSEC
69336 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69337 + return 1;
69338 + return 0;
69339 +#else
69340 + return 1;
69341 +#endif
69342 +}
69343 +
69344 +int gr_is_capable_nolog(const int cap)
69345 +{
69346 +#ifdef CONFIG_GRKERNSEC
69347 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69348 + return 1;
69349 + return 0;
69350 +#else
69351 + return 1;
69352 +#endif
69353 +}
69354 +
69355 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69356 +{
69357 +#ifdef CONFIG_GRKERNSEC
69358 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69359 + return 1;
69360 + return 0;
69361 +#else
69362 + return 1;
69363 +#endif
69364 +}
69365 +
69366 +EXPORT_SYMBOL(gr_is_capable);
69367 +EXPORT_SYMBOL(gr_is_capable_nolog);
69368 +EXPORT_SYMBOL(gr_task_is_capable);
69369 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69370 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69371 new file mode 100644
69372 index 0000000..06cc6ea
69373 --- /dev/null
69374 +++ b/grsecurity/grsec_fifo.c
69375 @@ -0,0 +1,24 @@
69376 +#include <linux/kernel.h>
69377 +#include <linux/sched.h>
69378 +#include <linux/fs.h>
69379 +#include <linux/file.h>
69380 +#include <linux/grinternal.h>
69381 +
69382 +int
69383 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69384 + const struct dentry *dir, const int flag, const int acc_mode)
69385 +{
69386 +#ifdef CONFIG_GRKERNSEC_FIFO
69387 + const struct cred *cred = current_cred();
69388 +
69389 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69390 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69391 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69392 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69393 + if (!inode_permission(dentry->d_inode, acc_mode))
69394 + 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));
69395 + return -EACCES;
69396 + }
69397 +#endif
69398 + return 0;
69399 +}
69400 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69401 new file mode 100644
69402 index 0000000..8ca18bf
69403 --- /dev/null
69404 +++ b/grsecurity/grsec_fork.c
69405 @@ -0,0 +1,23 @@
69406 +#include <linux/kernel.h>
69407 +#include <linux/sched.h>
69408 +#include <linux/grsecurity.h>
69409 +#include <linux/grinternal.h>
69410 +#include <linux/errno.h>
69411 +
69412 +void
69413 +gr_log_forkfail(const int retval)
69414 +{
69415 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69416 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69417 + switch (retval) {
69418 + case -EAGAIN:
69419 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69420 + break;
69421 + case -ENOMEM:
69422 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69423 + break;
69424 + }
69425 + }
69426 +#endif
69427 + return;
69428 +}
69429 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69430 new file mode 100644
69431 index 0000000..99a0cb9
69432 --- /dev/null
69433 +++ b/grsecurity/grsec_init.c
69434 @@ -0,0 +1,283 @@
69435 +#include <linux/kernel.h>
69436 +#include <linux/sched.h>
69437 +#include <linux/mm.h>
69438 +#include <linux/gracl.h>
69439 +#include <linux/slab.h>
69440 +#include <linux/vmalloc.h>
69441 +#include <linux/percpu.h>
69442 +#include <linux/module.h>
69443 +
69444 +int grsec_enable_ptrace_readexec;
69445 +int grsec_enable_setxid;
69446 +int grsec_enable_symlinkown;
69447 +kgid_t grsec_symlinkown_gid;
69448 +int grsec_enable_brute;
69449 +int grsec_enable_link;
69450 +int grsec_enable_dmesg;
69451 +int grsec_enable_harden_ptrace;
69452 +int grsec_enable_fifo;
69453 +int grsec_enable_execlog;
69454 +int grsec_enable_signal;
69455 +int grsec_enable_forkfail;
69456 +int grsec_enable_audit_ptrace;
69457 +int grsec_enable_time;
69458 +int grsec_enable_group;
69459 +kgid_t grsec_audit_gid;
69460 +int grsec_enable_chdir;
69461 +int grsec_enable_mount;
69462 +int grsec_enable_rofs;
69463 +int grsec_deny_new_usb;
69464 +int grsec_enable_chroot_findtask;
69465 +int grsec_enable_chroot_mount;
69466 +int grsec_enable_chroot_shmat;
69467 +int grsec_enable_chroot_fchdir;
69468 +int grsec_enable_chroot_double;
69469 +int grsec_enable_chroot_pivot;
69470 +int grsec_enable_chroot_chdir;
69471 +int grsec_enable_chroot_chmod;
69472 +int grsec_enable_chroot_mknod;
69473 +int grsec_enable_chroot_nice;
69474 +int grsec_enable_chroot_execlog;
69475 +int grsec_enable_chroot_caps;
69476 +int grsec_enable_chroot_sysctl;
69477 +int grsec_enable_chroot_unix;
69478 +int grsec_enable_tpe;
69479 +kgid_t grsec_tpe_gid;
69480 +int grsec_enable_blackhole;
69481 +#ifdef CONFIG_IPV6_MODULE
69482 +EXPORT_SYMBOL(grsec_enable_blackhole);
69483 +#endif
69484 +int grsec_lastack_retries;
69485 +int grsec_enable_tpe_all;
69486 +int grsec_enable_tpe_invert;
69487 +int grsec_enable_socket_all;
69488 +kgid_t grsec_socket_all_gid;
69489 +int grsec_enable_socket_client;
69490 +kgid_t grsec_socket_client_gid;
69491 +int grsec_enable_socket_server;
69492 +kgid_t grsec_socket_server_gid;
69493 +int grsec_resource_logging;
69494 +int grsec_disable_privio;
69495 +int grsec_enable_log_rwxmaps;
69496 +int grsec_lock;
69497 +
69498 +DEFINE_SPINLOCK(grsec_alert_lock);
69499 +unsigned long grsec_alert_wtime = 0;
69500 +unsigned long grsec_alert_fyet = 0;
69501 +
69502 +DEFINE_SPINLOCK(grsec_audit_lock);
69503 +
69504 +DEFINE_RWLOCK(grsec_exec_file_lock);
69505 +
69506 +char *gr_shared_page[4];
69507 +
69508 +char *gr_alert_log_fmt;
69509 +char *gr_audit_log_fmt;
69510 +char *gr_alert_log_buf;
69511 +char *gr_audit_log_buf;
69512 +
69513 +extern struct gr_arg *gr_usermode;
69514 +extern unsigned char *gr_system_salt;
69515 +extern unsigned char *gr_system_sum;
69516 +
69517 +void __init
69518 +grsecurity_init(void)
69519 +{
69520 + int j;
69521 + /* create the per-cpu shared pages */
69522 +
69523 +#ifdef CONFIG_X86
69524 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69525 +#endif
69526 +
69527 + for (j = 0; j < 4; j++) {
69528 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69529 + if (gr_shared_page[j] == NULL) {
69530 + panic("Unable to allocate grsecurity shared page");
69531 + return;
69532 + }
69533 + }
69534 +
69535 + /* allocate log buffers */
69536 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69537 + if (!gr_alert_log_fmt) {
69538 + panic("Unable to allocate grsecurity alert log format buffer");
69539 + return;
69540 + }
69541 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69542 + if (!gr_audit_log_fmt) {
69543 + panic("Unable to allocate grsecurity audit log format buffer");
69544 + return;
69545 + }
69546 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69547 + if (!gr_alert_log_buf) {
69548 + panic("Unable to allocate grsecurity alert log buffer");
69549 + return;
69550 + }
69551 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69552 + if (!gr_audit_log_buf) {
69553 + panic("Unable to allocate grsecurity audit log buffer");
69554 + return;
69555 + }
69556 +
69557 + /* allocate memory for authentication structure */
69558 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69559 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69560 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69561 +
69562 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69563 + panic("Unable to allocate grsecurity authentication structure");
69564 + return;
69565 + }
69566 +
69567 +
69568 +#ifdef CONFIG_GRKERNSEC_IO
69569 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69570 + grsec_disable_privio = 1;
69571 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69572 + grsec_disable_privio = 1;
69573 +#else
69574 + grsec_disable_privio = 0;
69575 +#endif
69576 +#endif
69577 +
69578 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69579 + /* for backward compatibility, tpe_invert always defaults to on if
69580 + enabled in the kernel
69581 + */
69582 + grsec_enable_tpe_invert = 1;
69583 +#endif
69584 +
69585 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69586 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69587 + grsec_lock = 1;
69588 +#endif
69589 +
69590 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69591 + grsec_enable_log_rwxmaps = 1;
69592 +#endif
69593 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69594 + grsec_enable_group = 1;
69595 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69596 +#endif
69597 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69598 + grsec_enable_ptrace_readexec = 1;
69599 +#endif
69600 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69601 + grsec_enable_chdir = 1;
69602 +#endif
69603 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69604 + grsec_enable_harden_ptrace = 1;
69605 +#endif
69606 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69607 + grsec_enable_mount = 1;
69608 +#endif
69609 +#ifdef CONFIG_GRKERNSEC_LINK
69610 + grsec_enable_link = 1;
69611 +#endif
69612 +#ifdef CONFIG_GRKERNSEC_BRUTE
69613 + grsec_enable_brute = 1;
69614 +#endif
69615 +#ifdef CONFIG_GRKERNSEC_DMESG
69616 + grsec_enable_dmesg = 1;
69617 +#endif
69618 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69619 + grsec_enable_blackhole = 1;
69620 + grsec_lastack_retries = 4;
69621 +#endif
69622 +#ifdef CONFIG_GRKERNSEC_FIFO
69623 + grsec_enable_fifo = 1;
69624 +#endif
69625 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69626 + grsec_enable_execlog = 1;
69627 +#endif
69628 +#ifdef CONFIG_GRKERNSEC_SETXID
69629 + grsec_enable_setxid = 1;
69630 +#endif
69631 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69632 + grsec_enable_signal = 1;
69633 +#endif
69634 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69635 + grsec_enable_forkfail = 1;
69636 +#endif
69637 +#ifdef CONFIG_GRKERNSEC_TIME
69638 + grsec_enable_time = 1;
69639 +#endif
69640 +#ifdef CONFIG_GRKERNSEC_RESLOG
69641 + grsec_resource_logging = 1;
69642 +#endif
69643 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69644 + grsec_enable_chroot_findtask = 1;
69645 +#endif
69646 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69647 + grsec_enable_chroot_unix = 1;
69648 +#endif
69649 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69650 + grsec_enable_chroot_mount = 1;
69651 +#endif
69652 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69653 + grsec_enable_chroot_fchdir = 1;
69654 +#endif
69655 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69656 + grsec_enable_chroot_shmat = 1;
69657 +#endif
69658 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69659 + grsec_enable_audit_ptrace = 1;
69660 +#endif
69661 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69662 + grsec_enable_chroot_double = 1;
69663 +#endif
69664 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69665 + grsec_enable_chroot_pivot = 1;
69666 +#endif
69667 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69668 + grsec_enable_chroot_chdir = 1;
69669 +#endif
69670 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69671 + grsec_enable_chroot_chmod = 1;
69672 +#endif
69673 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69674 + grsec_enable_chroot_mknod = 1;
69675 +#endif
69676 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69677 + grsec_enable_chroot_nice = 1;
69678 +#endif
69679 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69680 + grsec_enable_chroot_execlog = 1;
69681 +#endif
69682 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69683 + grsec_enable_chroot_caps = 1;
69684 +#endif
69685 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69686 + grsec_enable_chroot_sysctl = 1;
69687 +#endif
69688 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69689 + grsec_enable_symlinkown = 1;
69690 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69691 +#endif
69692 +#ifdef CONFIG_GRKERNSEC_TPE
69693 + grsec_enable_tpe = 1;
69694 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69695 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69696 + grsec_enable_tpe_all = 1;
69697 +#endif
69698 +#endif
69699 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69700 + grsec_enable_socket_all = 1;
69701 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69702 +#endif
69703 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69704 + grsec_enable_socket_client = 1;
69705 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69706 +#endif
69707 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69708 + grsec_enable_socket_server = 1;
69709 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69710 +#endif
69711 +#endif
69712 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69713 + grsec_deny_new_usb = 1;
69714 +#endif
69715 +
69716 + return;
69717 +}
69718 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69719 new file mode 100644
69720 index 0000000..5e05e20
69721 --- /dev/null
69722 +++ b/grsecurity/grsec_link.c
69723 @@ -0,0 +1,58 @@
69724 +#include <linux/kernel.h>
69725 +#include <linux/sched.h>
69726 +#include <linux/fs.h>
69727 +#include <linux/file.h>
69728 +#include <linux/grinternal.h>
69729 +
69730 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69731 +{
69732 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69733 + const struct inode *link_inode = link->dentry->d_inode;
69734 +
69735 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69736 + /* ignore root-owned links, e.g. /proc/self */
69737 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69738 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69739 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69740 + return 1;
69741 + }
69742 +#endif
69743 + return 0;
69744 +}
69745 +
69746 +int
69747 +gr_handle_follow_link(const struct inode *parent,
69748 + const struct inode *inode,
69749 + const struct dentry *dentry, const struct vfsmount *mnt)
69750 +{
69751 +#ifdef CONFIG_GRKERNSEC_LINK
69752 + const struct cred *cred = current_cred();
69753 +
69754 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69755 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69756 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69757 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69758 + return -EACCES;
69759 + }
69760 +#endif
69761 + return 0;
69762 +}
69763 +
69764 +int
69765 +gr_handle_hardlink(const struct dentry *dentry,
69766 + const struct vfsmount *mnt,
69767 + struct inode *inode, const int mode, const struct filename *to)
69768 +{
69769 +#ifdef CONFIG_GRKERNSEC_LINK
69770 + const struct cred *cred = current_cred();
69771 +
69772 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69773 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69774 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69775 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69776 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69777 + return -EPERM;
69778 + }
69779 +#endif
69780 + return 0;
69781 +}
69782 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69783 new file mode 100644
69784 index 0000000..dbe0a6b
69785 --- /dev/null
69786 +++ b/grsecurity/grsec_log.c
69787 @@ -0,0 +1,341 @@
69788 +#include <linux/kernel.h>
69789 +#include <linux/sched.h>
69790 +#include <linux/file.h>
69791 +#include <linux/tty.h>
69792 +#include <linux/fs.h>
69793 +#include <linux/mm.h>
69794 +#include <linux/grinternal.h>
69795 +
69796 +#ifdef CONFIG_TREE_PREEMPT_RCU
69797 +#define DISABLE_PREEMPT() preempt_disable()
69798 +#define ENABLE_PREEMPT() preempt_enable()
69799 +#else
69800 +#define DISABLE_PREEMPT()
69801 +#define ENABLE_PREEMPT()
69802 +#endif
69803 +
69804 +#define BEGIN_LOCKS(x) \
69805 + DISABLE_PREEMPT(); \
69806 + rcu_read_lock(); \
69807 + read_lock(&tasklist_lock); \
69808 + read_lock(&grsec_exec_file_lock); \
69809 + if (x != GR_DO_AUDIT) \
69810 + spin_lock(&grsec_alert_lock); \
69811 + else \
69812 + spin_lock(&grsec_audit_lock)
69813 +
69814 +#define END_LOCKS(x) \
69815 + if (x != GR_DO_AUDIT) \
69816 + spin_unlock(&grsec_alert_lock); \
69817 + else \
69818 + spin_unlock(&grsec_audit_lock); \
69819 + read_unlock(&grsec_exec_file_lock); \
69820 + read_unlock(&tasklist_lock); \
69821 + rcu_read_unlock(); \
69822 + ENABLE_PREEMPT(); \
69823 + if (x == GR_DONT_AUDIT) \
69824 + gr_handle_alertkill(current)
69825 +
69826 +enum {
69827 + FLOODING,
69828 + NO_FLOODING
69829 +};
69830 +
69831 +extern char *gr_alert_log_fmt;
69832 +extern char *gr_audit_log_fmt;
69833 +extern char *gr_alert_log_buf;
69834 +extern char *gr_audit_log_buf;
69835 +
69836 +static int gr_log_start(int audit)
69837 +{
69838 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69839 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69840 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69841 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69842 + unsigned long curr_secs = get_seconds();
69843 +
69844 + if (audit == GR_DO_AUDIT)
69845 + goto set_fmt;
69846 +
69847 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69848 + grsec_alert_wtime = curr_secs;
69849 + grsec_alert_fyet = 0;
69850 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69851 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69852 + grsec_alert_fyet++;
69853 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69854 + grsec_alert_wtime = curr_secs;
69855 + grsec_alert_fyet++;
69856 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69857 + return FLOODING;
69858 + }
69859 + else return FLOODING;
69860 +
69861 +set_fmt:
69862 +#endif
69863 + memset(buf, 0, PAGE_SIZE);
69864 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69865 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69866 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69867 + } else if (current->signal->curr_ip) {
69868 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69869 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69870 + } else if (gr_acl_is_enabled()) {
69871 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69872 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69873 + } else {
69874 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69875 + strcpy(buf, fmt);
69876 + }
69877 +
69878 + return NO_FLOODING;
69879 +}
69880 +
69881 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69882 + __attribute__ ((format (printf, 2, 0)));
69883 +
69884 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69885 +{
69886 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69887 + unsigned int len = strlen(buf);
69888 +
69889 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69890 +
69891 + return;
69892 +}
69893 +
69894 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69895 + __attribute__ ((format (printf, 2, 3)));
69896 +
69897 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69898 +{
69899 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69900 + unsigned int len = strlen(buf);
69901 + va_list ap;
69902 +
69903 + va_start(ap, msg);
69904 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69905 + va_end(ap);
69906 +
69907 + return;
69908 +}
69909 +
69910 +static void gr_log_end(int audit, int append_default)
69911 +{
69912 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69913 + if (append_default) {
69914 + struct task_struct *task = current;
69915 + struct task_struct *parent = task->real_parent;
69916 + const struct cred *cred = __task_cred(task);
69917 + const struct cred *pcred = __task_cred(parent);
69918 + unsigned int len = strlen(buf);
69919 +
69920 + 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));
69921 + }
69922 +
69923 + printk("%s\n", buf);
69924 +
69925 + return;
69926 +}
69927 +
69928 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69929 +{
69930 + int logtype;
69931 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69932 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69933 + void *voidptr = NULL;
69934 + int num1 = 0, num2 = 0;
69935 + unsigned long ulong1 = 0, ulong2 = 0;
69936 + struct dentry *dentry = NULL;
69937 + struct vfsmount *mnt = NULL;
69938 + struct file *file = NULL;
69939 + struct task_struct *task = NULL;
69940 + struct vm_area_struct *vma = NULL;
69941 + const struct cred *cred, *pcred;
69942 + va_list ap;
69943 +
69944 + BEGIN_LOCKS(audit);
69945 + logtype = gr_log_start(audit);
69946 + if (logtype == FLOODING) {
69947 + END_LOCKS(audit);
69948 + return;
69949 + }
69950 + va_start(ap, argtypes);
69951 + switch (argtypes) {
69952 + case GR_TTYSNIFF:
69953 + task = va_arg(ap, struct task_struct *);
69954 + 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));
69955 + break;
69956 + case GR_SYSCTL_HIDDEN:
69957 + str1 = va_arg(ap, char *);
69958 + gr_log_middle_varargs(audit, msg, result, str1);
69959 + break;
69960 + case GR_RBAC:
69961 + dentry = va_arg(ap, struct dentry *);
69962 + mnt = va_arg(ap, struct vfsmount *);
69963 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
69964 + break;
69965 + case GR_RBAC_STR:
69966 + dentry = va_arg(ap, struct dentry *);
69967 + mnt = va_arg(ap, struct vfsmount *);
69968 + str1 = va_arg(ap, char *);
69969 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
69970 + break;
69971 + case GR_STR_RBAC:
69972 + str1 = va_arg(ap, char *);
69973 + dentry = va_arg(ap, struct dentry *);
69974 + mnt = va_arg(ap, struct vfsmount *);
69975 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
69976 + break;
69977 + case GR_RBAC_MODE2:
69978 + dentry = va_arg(ap, struct dentry *);
69979 + mnt = va_arg(ap, struct vfsmount *);
69980 + str1 = va_arg(ap, char *);
69981 + str2 = va_arg(ap, char *);
69982 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
69983 + break;
69984 + case GR_RBAC_MODE3:
69985 + dentry = va_arg(ap, struct dentry *);
69986 + mnt = va_arg(ap, struct vfsmount *);
69987 + str1 = va_arg(ap, char *);
69988 + str2 = va_arg(ap, char *);
69989 + str3 = va_arg(ap, char *);
69990 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
69991 + break;
69992 + case GR_FILENAME:
69993 + dentry = va_arg(ap, struct dentry *);
69994 + mnt = va_arg(ap, struct vfsmount *);
69995 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
69996 + break;
69997 + case GR_STR_FILENAME:
69998 + str1 = va_arg(ap, char *);
69999 + dentry = va_arg(ap, struct dentry *);
70000 + mnt = va_arg(ap, struct vfsmount *);
70001 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70002 + break;
70003 + case GR_FILENAME_STR:
70004 + dentry = va_arg(ap, struct dentry *);
70005 + mnt = va_arg(ap, struct vfsmount *);
70006 + str1 = va_arg(ap, char *);
70007 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70008 + break;
70009 + case GR_FILENAME_TWO_INT:
70010 + dentry = va_arg(ap, struct dentry *);
70011 + mnt = va_arg(ap, struct vfsmount *);
70012 + num1 = va_arg(ap, int);
70013 + num2 = va_arg(ap, int);
70014 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70015 + break;
70016 + case GR_FILENAME_TWO_INT_STR:
70017 + dentry = va_arg(ap, struct dentry *);
70018 + mnt = va_arg(ap, struct vfsmount *);
70019 + num1 = va_arg(ap, int);
70020 + num2 = va_arg(ap, int);
70021 + str1 = va_arg(ap, char *);
70022 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70023 + break;
70024 + case GR_TEXTREL:
70025 + file = va_arg(ap, struct file *);
70026 + ulong1 = va_arg(ap, unsigned long);
70027 + ulong2 = va_arg(ap, unsigned long);
70028 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70029 + break;
70030 + case GR_PTRACE:
70031 + task = va_arg(ap, struct task_struct *);
70032 + 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));
70033 + break;
70034 + case GR_RESOURCE:
70035 + task = va_arg(ap, struct task_struct *);
70036 + cred = __task_cred(task);
70037 + pcred = __task_cred(task->real_parent);
70038 + ulong1 = va_arg(ap, unsigned long);
70039 + str1 = va_arg(ap, char *);
70040 + ulong2 = va_arg(ap, unsigned long);
70041 + 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));
70042 + break;
70043 + case GR_CAP:
70044 + task = va_arg(ap, struct task_struct *);
70045 + cred = __task_cred(task);
70046 + pcred = __task_cred(task->real_parent);
70047 + str1 = va_arg(ap, char *);
70048 + 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));
70049 + break;
70050 + case GR_SIG:
70051 + str1 = va_arg(ap, char *);
70052 + voidptr = va_arg(ap, void *);
70053 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70054 + break;
70055 + case GR_SIG2:
70056 + task = va_arg(ap, struct task_struct *);
70057 + cred = __task_cred(task);
70058 + pcred = __task_cred(task->real_parent);
70059 + num1 = va_arg(ap, int);
70060 + 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));
70061 + break;
70062 + case GR_CRASH1:
70063 + task = va_arg(ap, struct task_struct *);
70064 + cred = __task_cred(task);
70065 + pcred = __task_cred(task->real_parent);
70066 + ulong1 = va_arg(ap, unsigned long);
70067 + 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);
70068 + break;
70069 + case GR_CRASH2:
70070 + task = va_arg(ap, struct task_struct *);
70071 + cred = __task_cred(task);
70072 + pcred = __task_cred(task->real_parent);
70073 + ulong1 = va_arg(ap, unsigned long);
70074 + 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);
70075 + break;
70076 + case GR_RWXMAP:
70077 + file = va_arg(ap, struct file *);
70078 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70079 + break;
70080 + case GR_RWXMAPVMA:
70081 + vma = va_arg(ap, struct vm_area_struct *);
70082 + if (vma->vm_file)
70083 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70084 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70085 + str1 = "<stack>";
70086 + else if (vma->vm_start <= current->mm->brk &&
70087 + vma->vm_end >= current->mm->start_brk)
70088 + str1 = "<heap>";
70089 + else
70090 + str1 = "<anonymous mapping>";
70091 + gr_log_middle_varargs(audit, msg, str1);
70092 + break;
70093 + case GR_PSACCT:
70094 + {
70095 + unsigned int wday, cday;
70096 + __u8 whr, chr;
70097 + __u8 wmin, cmin;
70098 + __u8 wsec, csec;
70099 + char cur_tty[64] = { 0 };
70100 + char parent_tty[64] = { 0 };
70101 +
70102 + task = va_arg(ap, struct task_struct *);
70103 + wday = va_arg(ap, unsigned int);
70104 + cday = va_arg(ap, unsigned int);
70105 + whr = va_arg(ap, int);
70106 + chr = va_arg(ap, int);
70107 + wmin = va_arg(ap, int);
70108 + cmin = va_arg(ap, int);
70109 + wsec = va_arg(ap, int);
70110 + csec = va_arg(ap, int);
70111 + ulong1 = va_arg(ap, unsigned long);
70112 + cred = __task_cred(task);
70113 + pcred = __task_cred(task->real_parent);
70114 +
70115 + 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));
70116 + }
70117 + break;
70118 + default:
70119 + gr_log_middle(audit, msg, ap);
70120 + }
70121 + va_end(ap);
70122 + // these don't need DEFAULTSECARGS printed on the end
70123 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70124 + gr_log_end(audit, 0);
70125 + else
70126 + gr_log_end(audit, 1);
70127 + END_LOCKS(audit);
70128 +}
70129 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70130 new file mode 100644
70131 index 0000000..f536303
70132 --- /dev/null
70133 +++ b/grsecurity/grsec_mem.c
70134 @@ -0,0 +1,40 @@
70135 +#include <linux/kernel.h>
70136 +#include <linux/sched.h>
70137 +#include <linux/mm.h>
70138 +#include <linux/mman.h>
70139 +#include <linux/grinternal.h>
70140 +
70141 +void
70142 +gr_handle_ioperm(void)
70143 +{
70144 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70145 + return;
70146 +}
70147 +
70148 +void
70149 +gr_handle_iopl(void)
70150 +{
70151 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70152 + return;
70153 +}
70154 +
70155 +void
70156 +gr_handle_mem_readwrite(u64 from, u64 to)
70157 +{
70158 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70159 + return;
70160 +}
70161 +
70162 +void
70163 +gr_handle_vm86(void)
70164 +{
70165 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70166 + return;
70167 +}
70168 +
70169 +void
70170 +gr_log_badprocpid(const char *entry)
70171 +{
70172 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70173 + return;
70174 +}
70175 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70176 new file mode 100644
70177 index 0000000..2131422
70178 --- /dev/null
70179 +++ b/grsecurity/grsec_mount.c
70180 @@ -0,0 +1,62 @@
70181 +#include <linux/kernel.h>
70182 +#include <linux/sched.h>
70183 +#include <linux/mount.h>
70184 +#include <linux/grsecurity.h>
70185 +#include <linux/grinternal.h>
70186 +
70187 +void
70188 +gr_log_remount(const char *devname, const int retval)
70189 +{
70190 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70191 + if (grsec_enable_mount && (retval >= 0))
70192 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70193 +#endif
70194 + return;
70195 +}
70196 +
70197 +void
70198 +gr_log_unmount(const char *devname, const int retval)
70199 +{
70200 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70201 + if (grsec_enable_mount && (retval >= 0))
70202 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70203 +#endif
70204 + return;
70205 +}
70206 +
70207 +void
70208 +gr_log_mount(const char *from, const char *to, const int retval)
70209 +{
70210 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70211 + if (grsec_enable_mount && (retval >= 0))
70212 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70213 +#endif
70214 + return;
70215 +}
70216 +
70217 +int
70218 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70219 +{
70220 +#ifdef CONFIG_GRKERNSEC_ROFS
70221 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70222 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70223 + return -EPERM;
70224 + } else
70225 + return 0;
70226 +#endif
70227 + return 0;
70228 +}
70229 +
70230 +int
70231 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70232 +{
70233 +#ifdef CONFIG_GRKERNSEC_ROFS
70234 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70235 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70236 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70237 + return -EPERM;
70238 + } else
70239 + return 0;
70240 +#endif
70241 + return 0;
70242 +}
70243 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70244 new file mode 100644
70245 index 0000000..6ee9d50
70246 --- /dev/null
70247 +++ b/grsecurity/grsec_pax.c
70248 @@ -0,0 +1,45 @@
70249 +#include <linux/kernel.h>
70250 +#include <linux/sched.h>
70251 +#include <linux/mm.h>
70252 +#include <linux/file.h>
70253 +#include <linux/grinternal.h>
70254 +#include <linux/grsecurity.h>
70255 +
70256 +void
70257 +gr_log_textrel(struct vm_area_struct * vma)
70258 +{
70259 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70260 + if (grsec_enable_log_rwxmaps)
70261 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70262 +#endif
70263 + return;
70264 +}
70265 +
70266 +void gr_log_ptgnustack(struct file *file)
70267 +{
70268 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70269 + if (grsec_enable_log_rwxmaps)
70270 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70271 +#endif
70272 + return;
70273 +}
70274 +
70275 +void
70276 +gr_log_rwxmmap(struct file *file)
70277 +{
70278 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70279 + if (grsec_enable_log_rwxmaps)
70280 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70281 +#endif
70282 + return;
70283 +}
70284 +
70285 +void
70286 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70287 +{
70288 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70289 + if (grsec_enable_log_rwxmaps)
70290 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70291 +#endif
70292 + return;
70293 +}
70294 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70295 new file mode 100644
70296 index 0000000..f7f29aa
70297 --- /dev/null
70298 +++ b/grsecurity/grsec_ptrace.c
70299 @@ -0,0 +1,30 @@
70300 +#include <linux/kernel.h>
70301 +#include <linux/sched.h>
70302 +#include <linux/grinternal.h>
70303 +#include <linux/security.h>
70304 +
70305 +void
70306 +gr_audit_ptrace(struct task_struct *task)
70307 +{
70308 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70309 + if (grsec_enable_audit_ptrace)
70310 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70311 +#endif
70312 + return;
70313 +}
70314 +
70315 +int
70316 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70317 +{
70318 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70319 + const struct dentry *dentry = file->f_path.dentry;
70320 + const struct vfsmount *mnt = file->f_path.mnt;
70321 +
70322 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70323 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70324 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70325 + return -EACCES;
70326 + }
70327 +#endif
70328 + return 0;
70329 +}
70330 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70331 new file mode 100644
70332 index 0000000..4e29cc7
70333 --- /dev/null
70334 +++ b/grsecurity/grsec_sig.c
70335 @@ -0,0 +1,246 @@
70336 +#include <linux/kernel.h>
70337 +#include <linux/sched.h>
70338 +#include <linux/fs.h>
70339 +#include <linux/delay.h>
70340 +#include <linux/grsecurity.h>
70341 +#include <linux/grinternal.h>
70342 +#include <linux/hardirq.h>
70343 +
70344 +char *signames[] = {
70345 + [SIGSEGV] = "Segmentation fault",
70346 + [SIGILL] = "Illegal instruction",
70347 + [SIGABRT] = "Abort",
70348 + [SIGBUS] = "Invalid alignment/Bus error"
70349 +};
70350 +
70351 +void
70352 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70353 +{
70354 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70355 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70356 + (sig == SIGABRT) || (sig == SIGBUS))) {
70357 + if (task_pid_nr(t) == task_pid_nr(current)) {
70358 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70359 + } else {
70360 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70361 + }
70362 + }
70363 +#endif
70364 + return;
70365 +}
70366 +
70367 +int
70368 +gr_handle_signal(const struct task_struct *p, const int sig)
70369 +{
70370 +#ifdef CONFIG_GRKERNSEC
70371 + /* ignore the 0 signal for protected task checks */
70372 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70373 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70374 + return -EPERM;
70375 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70376 + return -EPERM;
70377 + }
70378 +#endif
70379 + return 0;
70380 +}
70381 +
70382 +#ifdef CONFIG_GRKERNSEC
70383 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70384 +
70385 +int gr_fake_force_sig(int sig, struct task_struct *t)
70386 +{
70387 + unsigned long int flags;
70388 + int ret, blocked, ignored;
70389 + struct k_sigaction *action;
70390 +
70391 + spin_lock_irqsave(&t->sighand->siglock, flags);
70392 + action = &t->sighand->action[sig-1];
70393 + ignored = action->sa.sa_handler == SIG_IGN;
70394 + blocked = sigismember(&t->blocked, sig);
70395 + if (blocked || ignored) {
70396 + action->sa.sa_handler = SIG_DFL;
70397 + if (blocked) {
70398 + sigdelset(&t->blocked, sig);
70399 + recalc_sigpending_and_wake(t);
70400 + }
70401 + }
70402 + if (action->sa.sa_handler == SIG_DFL)
70403 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70404 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70405 +
70406 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70407 +
70408 + return ret;
70409 +}
70410 +#endif
70411 +
70412 +#ifdef CONFIG_GRKERNSEC_BRUTE
70413 +#define GR_USER_BAN_TIME (15 * 60)
70414 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70415 +
70416 +static int __get_dumpable(unsigned long mm_flags)
70417 +{
70418 + int ret;
70419 +
70420 + ret = mm_flags & MMF_DUMPABLE_MASK;
70421 + return (ret >= 2) ? 2 : ret;
70422 +}
70423 +#endif
70424 +
70425 +void gr_handle_brute_attach(unsigned long mm_flags)
70426 +{
70427 +#ifdef CONFIG_GRKERNSEC_BRUTE
70428 + struct task_struct *p = current;
70429 + kuid_t uid = GLOBAL_ROOT_UID;
70430 + int daemon = 0;
70431 +
70432 + if (!grsec_enable_brute)
70433 + return;
70434 +
70435 + rcu_read_lock();
70436 + read_lock(&tasklist_lock);
70437 + read_lock(&grsec_exec_file_lock);
70438 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70439 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70440 + p->real_parent->brute = 1;
70441 + daemon = 1;
70442 + } else {
70443 + const struct cred *cred = __task_cred(p), *cred2;
70444 + struct task_struct *tsk, *tsk2;
70445 +
70446 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70447 + struct user_struct *user;
70448 +
70449 + uid = cred->uid;
70450 +
70451 + /* this is put upon execution past expiration */
70452 + user = find_user(uid);
70453 + if (user == NULL)
70454 + goto unlock;
70455 + user->suid_banned = 1;
70456 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70457 + if (user->suid_ban_expires == ~0UL)
70458 + user->suid_ban_expires--;
70459 +
70460 + /* only kill other threads of the same binary, from the same user */
70461 + do_each_thread(tsk2, tsk) {
70462 + cred2 = __task_cred(tsk);
70463 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70464 + gr_fake_force_sig(SIGKILL, tsk);
70465 + } while_each_thread(tsk2, tsk);
70466 + }
70467 + }
70468 +unlock:
70469 + read_unlock(&grsec_exec_file_lock);
70470 + read_unlock(&tasklist_lock);
70471 + rcu_read_unlock();
70472 +
70473 + if (gr_is_global_nonroot(uid))
70474 + 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);
70475 + else if (daemon)
70476 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70477 +
70478 +#endif
70479 + return;
70480 +}
70481 +
70482 +void gr_handle_brute_check(void)
70483 +{
70484 +#ifdef CONFIG_GRKERNSEC_BRUTE
70485 + struct task_struct *p = current;
70486 +
70487 + if (unlikely(p->brute)) {
70488 + if (!grsec_enable_brute)
70489 + p->brute = 0;
70490 + else if (time_before(get_seconds(), p->brute_expires))
70491 + msleep(30 * 1000);
70492 + }
70493 +#endif
70494 + return;
70495 +}
70496 +
70497 +void gr_handle_kernel_exploit(void)
70498 +{
70499 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70500 + const struct cred *cred;
70501 + struct task_struct *tsk, *tsk2;
70502 + struct user_struct *user;
70503 + kuid_t uid;
70504 +
70505 + if (in_irq() || in_serving_softirq() || in_nmi())
70506 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70507 +
70508 + uid = current_uid();
70509 +
70510 + if (gr_is_global_root(uid))
70511 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70512 + else {
70513 + /* kill all the processes of this user, hold a reference
70514 + to their creds struct, and prevent them from creating
70515 + another process until system reset
70516 + */
70517 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70518 + GR_GLOBAL_UID(uid));
70519 + /* we intentionally leak this ref */
70520 + user = get_uid(current->cred->user);
70521 + if (user)
70522 + user->kernel_banned = 1;
70523 +
70524 + /* kill all processes of this user */
70525 + read_lock(&tasklist_lock);
70526 + do_each_thread(tsk2, tsk) {
70527 + cred = __task_cred(tsk);
70528 + if (uid_eq(cred->uid, uid))
70529 + gr_fake_force_sig(SIGKILL, tsk);
70530 + } while_each_thread(tsk2, tsk);
70531 + read_unlock(&tasklist_lock);
70532 + }
70533 +#endif
70534 +}
70535 +
70536 +#ifdef CONFIG_GRKERNSEC_BRUTE
70537 +static bool suid_ban_expired(struct user_struct *user)
70538 +{
70539 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70540 + user->suid_banned = 0;
70541 + user->suid_ban_expires = 0;
70542 + free_uid(user);
70543 + return true;
70544 + }
70545 +
70546 + return false;
70547 +}
70548 +#endif
70549 +
70550 +int gr_process_kernel_exec_ban(void)
70551 +{
70552 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70553 + if (unlikely(current->cred->user->kernel_banned))
70554 + return -EPERM;
70555 +#endif
70556 + return 0;
70557 +}
70558 +
70559 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70560 +{
70561 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70562 + if (unlikely(user->kernel_banned))
70563 + gr_fake_force_sig(SIGKILL, current);
70564 +#endif
70565 + return 0;
70566 +}
70567 +
70568 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70569 +{
70570 +#ifdef CONFIG_GRKERNSEC_BRUTE
70571 + struct user_struct *user = current->cred->user;
70572 + if (unlikely(user->suid_banned)) {
70573 + if (suid_ban_expired(user))
70574 + return 0;
70575 + /* disallow execution of suid binaries only */
70576 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70577 + return -EPERM;
70578 + }
70579 +#endif
70580 + return 0;
70581 +}
70582 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70583 new file mode 100644
70584 index 0000000..4030d57
70585 --- /dev/null
70586 +++ b/grsecurity/grsec_sock.c
70587 @@ -0,0 +1,244 @@
70588 +#include <linux/kernel.h>
70589 +#include <linux/module.h>
70590 +#include <linux/sched.h>
70591 +#include <linux/file.h>
70592 +#include <linux/net.h>
70593 +#include <linux/in.h>
70594 +#include <linux/ip.h>
70595 +#include <net/sock.h>
70596 +#include <net/inet_sock.h>
70597 +#include <linux/grsecurity.h>
70598 +#include <linux/grinternal.h>
70599 +#include <linux/gracl.h>
70600 +
70601 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70602 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70603 +
70604 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70605 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70606 +
70607 +#ifdef CONFIG_UNIX_MODULE
70608 +EXPORT_SYMBOL(gr_acl_handle_unix);
70609 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70610 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70611 +EXPORT_SYMBOL(gr_handle_create);
70612 +#endif
70613 +
70614 +#ifdef CONFIG_GRKERNSEC
70615 +#define gr_conn_table_size 32749
70616 +struct conn_table_entry {
70617 + struct conn_table_entry *next;
70618 + struct signal_struct *sig;
70619 +};
70620 +
70621 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70622 +DEFINE_SPINLOCK(gr_conn_table_lock);
70623 +
70624 +extern const char * gr_socktype_to_name(unsigned char type);
70625 +extern const char * gr_proto_to_name(unsigned char proto);
70626 +extern const char * gr_sockfamily_to_name(unsigned char family);
70627 +
70628 +static __inline__ int
70629 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70630 +{
70631 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70632 +}
70633 +
70634 +static __inline__ int
70635 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70636 + __u16 sport, __u16 dport)
70637 +{
70638 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70639 + sig->gr_sport == sport && sig->gr_dport == dport))
70640 + return 1;
70641 + else
70642 + return 0;
70643 +}
70644 +
70645 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70646 +{
70647 + struct conn_table_entry **match;
70648 + unsigned int index;
70649 +
70650 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70651 + sig->gr_sport, sig->gr_dport,
70652 + gr_conn_table_size);
70653 +
70654 + newent->sig = sig;
70655 +
70656 + match = &gr_conn_table[index];
70657 + newent->next = *match;
70658 + *match = newent;
70659 +
70660 + return;
70661 +}
70662 +
70663 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70664 +{
70665 + struct conn_table_entry *match, *last = NULL;
70666 + unsigned int index;
70667 +
70668 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70669 + sig->gr_sport, sig->gr_dport,
70670 + gr_conn_table_size);
70671 +
70672 + match = gr_conn_table[index];
70673 + while (match && !conn_match(match->sig,
70674 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70675 + sig->gr_dport)) {
70676 + last = match;
70677 + match = match->next;
70678 + }
70679 +
70680 + if (match) {
70681 + if (last)
70682 + last->next = match->next;
70683 + else
70684 + gr_conn_table[index] = NULL;
70685 + kfree(match);
70686 + }
70687 +
70688 + return;
70689 +}
70690 +
70691 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70692 + __u16 sport, __u16 dport)
70693 +{
70694 + struct conn_table_entry *match;
70695 + unsigned int index;
70696 +
70697 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70698 +
70699 + match = gr_conn_table[index];
70700 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70701 + match = match->next;
70702 +
70703 + if (match)
70704 + return match->sig;
70705 + else
70706 + return NULL;
70707 +}
70708 +
70709 +#endif
70710 +
70711 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70712 +{
70713 +#ifdef CONFIG_GRKERNSEC
70714 + struct signal_struct *sig = task->signal;
70715 + struct conn_table_entry *newent;
70716 +
70717 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70718 + if (newent == NULL)
70719 + return;
70720 + /* no bh lock needed since we are called with bh disabled */
70721 + spin_lock(&gr_conn_table_lock);
70722 + gr_del_task_from_ip_table_nolock(sig);
70723 + sig->gr_saddr = inet->inet_rcv_saddr;
70724 + sig->gr_daddr = inet->inet_daddr;
70725 + sig->gr_sport = inet->inet_sport;
70726 + sig->gr_dport = inet->inet_dport;
70727 + gr_add_to_task_ip_table_nolock(sig, newent);
70728 + spin_unlock(&gr_conn_table_lock);
70729 +#endif
70730 + return;
70731 +}
70732 +
70733 +void gr_del_task_from_ip_table(struct task_struct *task)
70734 +{
70735 +#ifdef CONFIG_GRKERNSEC
70736 + spin_lock_bh(&gr_conn_table_lock);
70737 + gr_del_task_from_ip_table_nolock(task->signal);
70738 + spin_unlock_bh(&gr_conn_table_lock);
70739 +#endif
70740 + return;
70741 +}
70742 +
70743 +void
70744 +gr_attach_curr_ip(const struct sock *sk)
70745 +{
70746 +#ifdef CONFIG_GRKERNSEC
70747 + struct signal_struct *p, *set;
70748 + const struct inet_sock *inet = inet_sk(sk);
70749 +
70750 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70751 + return;
70752 +
70753 + set = current->signal;
70754 +
70755 + spin_lock_bh(&gr_conn_table_lock);
70756 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70757 + inet->inet_dport, inet->inet_sport);
70758 + if (unlikely(p != NULL)) {
70759 + set->curr_ip = p->curr_ip;
70760 + set->used_accept = 1;
70761 + gr_del_task_from_ip_table_nolock(p);
70762 + spin_unlock_bh(&gr_conn_table_lock);
70763 + return;
70764 + }
70765 + spin_unlock_bh(&gr_conn_table_lock);
70766 +
70767 + set->curr_ip = inet->inet_daddr;
70768 + set->used_accept = 1;
70769 +#endif
70770 + return;
70771 +}
70772 +
70773 +int
70774 +gr_handle_sock_all(const int family, const int type, const int protocol)
70775 +{
70776 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70777 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70778 + (family != AF_UNIX)) {
70779 + if (family == AF_INET)
70780 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70781 + else
70782 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70783 + return -EACCES;
70784 + }
70785 +#endif
70786 + return 0;
70787 +}
70788 +
70789 +int
70790 +gr_handle_sock_server(const struct sockaddr *sck)
70791 +{
70792 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70793 + if (grsec_enable_socket_server &&
70794 + in_group_p(grsec_socket_server_gid) &&
70795 + sck && (sck->sa_family != AF_UNIX) &&
70796 + (sck->sa_family != AF_LOCAL)) {
70797 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70798 + return -EACCES;
70799 + }
70800 +#endif
70801 + return 0;
70802 +}
70803 +
70804 +int
70805 +gr_handle_sock_server_other(const struct sock *sck)
70806 +{
70807 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70808 + if (grsec_enable_socket_server &&
70809 + in_group_p(grsec_socket_server_gid) &&
70810 + sck && (sck->sk_family != AF_UNIX) &&
70811 + (sck->sk_family != AF_LOCAL)) {
70812 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70813 + return -EACCES;
70814 + }
70815 +#endif
70816 + return 0;
70817 +}
70818 +
70819 +int
70820 +gr_handle_sock_client(const struct sockaddr *sck)
70821 +{
70822 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70823 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70824 + sck && (sck->sa_family != AF_UNIX) &&
70825 + (sck->sa_family != AF_LOCAL)) {
70826 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70827 + return -EACCES;
70828 + }
70829 +#endif
70830 + return 0;
70831 +}
70832 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70833 new file mode 100644
70834 index 0000000..a147ae7
70835 --- /dev/null
70836 +++ b/grsecurity/grsec_sysctl.c
70837 @@ -0,0 +1,470 @@
70838 +#include <linux/kernel.h>
70839 +#include <linux/sched.h>
70840 +#include <linux/sysctl.h>
70841 +#include <linux/grsecurity.h>
70842 +#include <linux/grinternal.h>
70843 +
70844 +int
70845 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70846 +{
70847 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70848 + if (dirname == NULL || name == NULL)
70849 + return 0;
70850 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70851 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70852 + return -EACCES;
70853 + }
70854 +#endif
70855 + return 0;
70856 +}
70857 +
70858 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70859 +static int __maybe_unused __read_only one = 1;
70860 +#endif
70861 +
70862 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70863 + defined(CONFIG_GRKERNSEC_DENYUSB)
70864 +struct ctl_table grsecurity_table[] = {
70865 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70866 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70867 +#ifdef CONFIG_GRKERNSEC_IO
70868 + {
70869 + .procname = "disable_priv_io",
70870 + .data = &grsec_disable_privio,
70871 + .maxlen = sizeof(int),
70872 + .mode = 0600,
70873 + .proc_handler = &proc_dointvec,
70874 + },
70875 +#endif
70876 +#endif
70877 +#ifdef CONFIG_GRKERNSEC_LINK
70878 + {
70879 + .procname = "linking_restrictions",
70880 + .data = &grsec_enable_link,
70881 + .maxlen = sizeof(int),
70882 + .mode = 0600,
70883 + .proc_handler = &proc_dointvec,
70884 + },
70885 +#endif
70886 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70887 + {
70888 + .procname = "enforce_symlinksifowner",
70889 + .data = &grsec_enable_symlinkown,
70890 + .maxlen = sizeof(int),
70891 + .mode = 0600,
70892 + .proc_handler = &proc_dointvec,
70893 + },
70894 + {
70895 + .procname = "symlinkown_gid",
70896 + .data = &grsec_symlinkown_gid,
70897 + .maxlen = sizeof(int),
70898 + .mode = 0600,
70899 + .proc_handler = &proc_dointvec,
70900 + },
70901 +#endif
70902 +#ifdef CONFIG_GRKERNSEC_BRUTE
70903 + {
70904 + .procname = "deter_bruteforce",
70905 + .data = &grsec_enable_brute,
70906 + .maxlen = sizeof(int),
70907 + .mode = 0600,
70908 + .proc_handler = &proc_dointvec,
70909 + },
70910 +#endif
70911 +#ifdef CONFIG_GRKERNSEC_FIFO
70912 + {
70913 + .procname = "fifo_restrictions",
70914 + .data = &grsec_enable_fifo,
70915 + .maxlen = sizeof(int),
70916 + .mode = 0600,
70917 + .proc_handler = &proc_dointvec,
70918 + },
70919 +#endif
70920 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70921 + {
70922 + .procname = "ptrace_readexec",
70923 + .data = &grsec_enable_ptrace_readexec,
70924 + .maxlen = sizeof(int),
70925 + .mode = 0600,
70926 + .proc_handler = &proc_dointvec,
70927 + },
70928 +#endif
70929 +#ifdef CONFIG_GRKERNSEC_SETXID
70930 + {
70931 + .procname = "consistent_setxid",
70932 + .data = &grsec_enable_setxid,
70933 + .maxlen = sizeof(int),
70934 + .mode = 0600,
70935 + .proc_handler = &proc_dointvec,
70936 + },
70937 +#endif
70938 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70939 + {
70940 + .procname = "ip_blackhole",
70941 + .data = &grsec_enable_blackhole,
70942 + .maxlen = sizeof(int),
70943 + .mode = 0600,
70944 + .proc_handler = &proc_dointvec,
70945 + },
70946 + {
70947 + .procname = "lastack_retries",
70948 + .data = &grsec_lastack_retries,
70949 + .maxlen = sizeof(int),
70950 + .mode = 0600,
70951 + .proc_handler = &proc_dointvec,
70952 + },
70953 +#endif
70954 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70955 + {
70956 + .procname = "exec_logging",
70957 + .data = &grsec_enable_execlog,
70958 + .maxlen = sizeof(int),
70959 + .mode = 0600,
70960 + .proc_handler = &proc_dointvec,
70961 + },
70962 +#endif
70963 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70964 + {
70965 + .procname = "rwxmap_logging",
70966 + .data = &grsec_enable_log_rwxmaps,
70967 + .maxlen = sizeof(int),
70968 + .mode = 0600,
70969 + .proc_handler = &proc_dointvec,
70970 + },
70971 +#endif
70972 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70973 + {
70974 + .procname = "signal_logging",
70975 + .data = &grsec_enable_signal,
70976 + .maxlen = sizeof(int),
70977 + .mode = 0600,
70978 + .proc_handler = &proc_dointvec,
70979 + },
70980 +#endif
70981 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70982 + {
70983 + .procname = "forkfail_logging",
70984 + .data = &grsec_enable_forkfail,
70985 + .maxlen = sizeof(int),
70986 + .mode = 0600,
70987 + .proc_handler = &proc_dointvec,
70988 + },
70989 +#endif
70990 +#ifdef CONFIG_GRKERNSEC_TIME
70991 + {
70992 + .procname = "timechange_logging",
70993 + .data = &grsec_enable_time,
70994 + .maxlen = sizeof(int),
70995 + .mode = 0600,
70996 + .proc_handler = &proc_dointvec,
70997 + },
70998 +#endif
70999 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71000 + {
71001 + .procname = "chroot_deny_shmat",
71002 + .data = &grsec_enable_chroot_shmat,
71003 + .maxlen = sizeof(int),
71004 + .mode = 0600,
71005 + .proc_handler = &proc_dointvec,
71006 + },
71007 +#endif
71008 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71009 + {
71010 + .procname = "chroot_deny_unix",
71011 + .data = &grsec_enable_chroot_unix,
71012 + .maxlen = sizeof(int),
71013 + .mode = 0600,
71014 + .proc_handler = &proc_dointvec,
71015 + },
71016 +#endif
71017 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71018 + {
71019 + .procname = "chroot_deny_mount",
71020 + .data = &grsec_enable_chroot_mount,
71021 + .maxlen = sizeof(int),
71022 + .mode = 0600,
71023 + .proc_handler = &proc_dointvec,
71024 + },
71025 +#endif
71026 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71027 + {
71028 + .procname = "chroot_deny_fchdir",
71029 + .data = &grsec_enable_chroot_fchdir,
71030 + .maxlen = sizeof(int),
71031 + .mode = 0600,
71032 + .proc_handler = &proc_dointvec,
71033 + },
71034 +#endif
71035 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71036 + {
71037 + .procname = "chroot_deny_chroot",
71038 + .data = &grsec_enable_chroot_double,
71039 + .maxlen = sizeof(int),
71040 + .mode = 0600,
71041 + .proc_handler = &proc_dointvec,
71042 + },
71043 +#endif
71044 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71045 + {
71046 + .procname = "chroot_deny_pivot",
71047 + .data = &grsec_enable_chroot_pivot,
71048 + .maxlen = sizeof(int),
71049 + .mode = 0600,
71050 + .proc_handler = &proc_dointvec,
71051 + },
71052 +#endif
71053 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71054 + {
71055 + .procname = "chroot_enforce_chdir",
71056 + .data = &grsec_enable_chroot_chdir,
71057 + .maxlen = sizeof(int),
71058 + .mode = 0600,
71059 + .proc_handler = &proc_dointvec,
71060 + },
71061 +#endif
71062 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71063 + {
71064 + .procname = "chroot_deny_chmod",
71065 + .data = &grsec_enable_chroot_chmod,
71066 + .maxlen = sizeof(int),
71067 + .mode = 0600,
71068 + .proc_handler = &proc_dointvec,
71069 + },
71070 +#endif
71071 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71072 + {
71073 + .procname = "chroot_deny_mknod",
71074 + .data = &grsec_enable_chroot_mknod,
71075 + .maxlen = sizeof(int),
71076 + .mode = 0600,
71077 + .proc_handler = &proc_dointvec,
71078 + },
71079 +#endif
71080 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71081 + {
71082 + .procname = "chroot_restrict_nice",
71083 + .data = &grsec_enable_chroot_nice,
71084 + .maxlen = sizeof(int),
71085 + .mode = 0600,
71086 + .proc_handler = &proc_dointvec,
71087 + },
71088 +#endif
71089 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71090 + {
71091 + .procname = "chroot_execlog",
71092 + .data = &grsec_enable_chroot_execlog,
71093 + .maxlen = sizeof(int),
71094 + .mode = 0600,
71095 + .proc_handler = &proc_dointvec,
71096 + },
71097 +#endif
71098 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71099 + {
71100 + .procname = "chroot_caps",
71101 + .data = &grsec_enable_chroot_caps,
71102 + .maxlen = sizeof(int),
71103 + .mode = 0600,
71104 + .proc_handler = &proc_dointvec,
71105 + },
71106 +#endif
71107 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71108 + {
71109 + .procname = "chroot_deny_sysctl",
71110 + .data = &grsec_enable_chroot_sysctl,
71111 + .maxlen = sizeof(int),
71112 + .mode = 0600,
71113 + .proc_handler = &proc_dointvec,
71114 + },
71115 +#endif
71116 +#ifdef CONFIG_GRKERNSEC_TPE
71117 + {
71118 + .procname = "tpe",
71119 + .data = &grsec_enable_tpe,
71120 + .maxlen = sizeof(int),
71121 + .mode = 0600,
71122 + .proc_handler = &proc_dointvec,
71123 + },
71124 + {
71125 + .procname = "tpe_gid",
71126 + .data = &grsec_tpe_gid,
71127 + .maxlen = sizeof(int),
71128 + .mode = 0600,
71129 + .proc_handler = &proc_dointvec,
71130 + },
71131 +#endif
71132 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71133 + {
71134 + .procname = "tpe_invert",
71135 + .data = &grsec_enable_tpe_invert,
71136 + .maxlen = sizeof(int),
71137 + .mode = 0600,
71138 + .proc_handler = &proc_dointvec,
71139 + },
71140 +#endif
71141 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71142 + {
71143 + .procname = "tpe_restrict_all",
71144 + .data = &grsec_enable_tpe_all,
71145 + .maxlen = sizeof(int),
71146 + .mode = 0600,
71147 + .proc_handler = &proc_dointvec,
71148 + },
71149 +#endif
71150 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71151 + {
71152 + .procname = "socket_all",
71153 + .data = &grsec_enable_socket_all,
71154 + .maxlen = sizeof(int),
71155 + .mode = 0600,
71156 + .proc_handler = &proc_dointvec,
71157 + },
71158 + {
71159 + .procname = "socket_all_gid",
71160 + .data = &grsec_socket_all_gid,
71161 + .maxlen = sizeof(int),
71162 + .mode = 0600,
71163 + .proc_handler = &proc_dointvec,
71164 + },
71165 +#endif
71166 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71167 + {
71168 + .procname = "socket_client",
71169 + .data = &grsec_enable_socket_client,
71170 + .maxlen = sizeof(int),
71171 + .mode = 0600,
71172 + .proc_handler = &proc_dointvec,
71173 + },
71174 + {
71175 + .procname = "socket_client_gid",
71176 + .data = &grsec_socket_client_gid,
71177 + .maxlen = sizeof(int),
71178 + .mode = 0600,
71179 + .proc_handler = &proc_dointvec,
71180 + },
71181 +#endif
71182 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71183 + {
71184 + .procname = "socket_server",
71185 + .data = &grsec_enable_socket_server,
71186 + .maxlen = sizeof(int),
71187 + .mode = 0600,
71188 + .proc_handler = &proc_dointvec,
71189 + },
71190 + {
71191 + .procname = "socket_server_gid",
71192 + .data = &grsec_socket_server_gid,
71193 + .maxlen = sizeof(int),
71194 + .mode = 0600,
71195 + .proc_handler = &proc_dointvec,
71196 + },
71197 +#endif
71198 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71199 + {
71200 + .procname = "audit_group",
71201 + .data = &grsec_enable_group,
71202 + .maxlen = sizeof(int),
71203 + .mode = 0600,
71204 + .proc_handler = &proc_dointvec,
71205 + },
71206 + {
71207 + .procname = "audit_gid",
71208 + .data = &grsec_audit_gid,
71209 + .maxlen = sizeof(int),
71210 + .mode = 0600,
71211 + .proc_handler = &proc_dointvec,
71212 + },
71213 +#endif
71214 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71215 + {
71216 + .procname = "audit_chdir",
71217 + .data = &grsec_enable_chdir,
71218 + .maxlen = sizeof(int),
71219 + .mode = 0600,
71220 + .proc_handler = &proc_dointvec,
71221 + },
71222 +#endif
71223 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71224 + {
71225 + .procname = "audit_mount",
71226 + .data = &grsec_enable_mount,
71227 + .maxlen = sizeof(int),
71228 + .mode = 0600,
71229 + .proc_handler = &proc_dointvec,
71230 + },
71231 +#endif
71232 +#ifdef CONFIG_GRKERNSEC_DMESG
71233 + {
71234 + .procname = "dmesg",
71235 + .data = &grsec_enable_dmesg,
71236 + .maxlen = sizeof(int),
71237 + .mode = 0600,
71238 + .proc_handler = &proc_dointvec,
71239 + },
71240 +#endif
71241 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71242 + {
71243 + .procname = "chroot_findtask",
71244 + .data = &grsec_enable_chroot_findtask,
71245 + .maxlen = sizeof(int),
71246 + .mode = 0600,
71247 + .proc_handler = &proc_dointvec,
71248 + },
71249 +#endif
71250 +#ifdef CONFIG_GRKERNSEC_RESLOG
71251 + {
71252 + .procname = "resource_logging",
71253 + .data = &grsec_resource_logging,
71254 + .maxlen = sizeof(int),
71255 + .mode = 0600,
71256 + .proc_handler = &proc_dointvec,
71257 + },
71258 +#endif
71259 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71260 + {
71261 + .procname = "audit_ptrace",
71262 + .data = &grsec_enable_audit_ptrace,
71263 + .maxlen = sizeof(int),
71264 + .mode = 0600,
71265 + .proc_handler = &proc_dointvec,
71266 + },
71267 +#endif
71268 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71269 + {
71270 + .procname = "harden_ptrace",
71271 + .data = &grsec_enable_harden_ptrace,
71272 + .maxlen = sizeof(int),
71273 + .mode = 0600,
71274 + .proc_handler = &proc_dointvec,
71275 + },
71276 +#endif
71277 + {
71278 + .procname = "grsec_lock",
71279 + .data = &grsec_lock,
71280 + .maxlen = sizeof(int),
71281 + .mode = 0600,
71282 + .proc_handler = &proc_dointvec,
71283 + },
71284 +#endif
71285 +#ifdef CONFIG_GRKERNSEC_ROFS
71286 + {
71287 + .procname = "romount_protect",
71288 + .data = &grsec_enable_rofs,
71289 + .maxlen = sizeof(int),
71290 + .mode = 0600,
71291 + .proc_handler = &proc_dointvec_minmax,
71292 + .extra1 = &one,
71293 + .extra2 = &one,
71294 + },
71295 +#endif
71296 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71297 + {
71298 + .procname = "deny_new_usb",
71299 + .data = &grsec_deny_new_usb,
71300 + .maxlen = sizeof(int),
71301 + .mode = 0600,
71302 + .proc_handler = &proc_dointvec,
71303 + },
71304 +#endif
71305 + { }
71306 +};
71307 +#endif
71308 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71309 new file mode 100644
71310 index 0000000..0dc13c3
71311 --- /dev/null
71312 +++ b/grsecurity/grsec_time.c
71313 @@ -0,0 +1,16 @@
71314 +#include <linux/kernel.h>
71315 +#include <linux/sched.h>
71316 +#include <linux/grinternal.h>
71317 +#include <linux/module.h>
71318 +
71319 +void
71320 +gr_log_timechange(void)
71321 +{
71322 +#ifdef CONFIG_GRKERNSEC_TIME
71323 + if (grsec_enable_time)
71324 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71325 +#endif
71326 + return;
71327 +}
71328 +
71329 +EXPORT_SYMBOL(gr_log_timechange);
71330 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71331 new file mode 100644
71332 index 0000000..ee57dcf
71333 --- /dev/null
71334 +++ b/grsecurity/grsec_tpe.c
71335 @@ -0,0 +1,73 @@
71336 +#include <linux/kernel.h>
71337 +#include <linux/sched.h>
71338 +#include <linux/file.h>
71339 +#include <linux/fs.h>
71340 +#include <linux/grinternal.h>
71341 +
71342 +extern int gr_acl_tpe_check(void);
71343 +
71344 +int
71345 +gr_tpe_allow(const struct file *file)
71346 +{
71347 +#ifdef CONFIG_GRKERNSEC
71348 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71349 + const struct cred *cred = current_cred();
71350 + char *msg = NULL;
71351 + char *msg2 = NULL;
71352 +
71353 + // never restrict root
71354 + if (gr_is_global_root(cred->uid))
71355 + return 1;
71356 +
71357 + if (grsec_enable_tpe) {
71358 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71359 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71360 + msg = "not being in trusted group";
71361 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71362 + msg = "being in untrusted group";
71363 +#else
71364 + if (in_group_p(grsec_tpe_gid))
71365 + msg = "being in untrusted group";
71366 +#endif
71367 + }
71368 + if (!msg && gr_acl_tpe_check())
71369 + msg = "being in untrusted role";
71370 +
71371 + // not in any affected group/role
71372 + if (!msg)
71373 + goto next_check;
71374 +
71375 + if (gr_is_global_nonroot(inode->i_uid))
71376 + msg2 = "file in non-root-owned directory";
71377 + else if (inode->i_mode & S_IWOTH)
71378 + msg2 = "file in world-writable directory";
71379 + else if (inode->i_mode & S_IWGRP)
71380 + msg2 = "file in group-writable directory";
71381 +
71382 + if (msg && msg2) {
71383 + char fullmsg[70] = {0};
71384 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71385 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71386 + return 0;
71387 + }
71388 + msg = NULL;
71389 +next_check:
71390 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71391 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71392 + return 1;
71393 +
71394 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71395 + msg = "directory not owned by user";
71396 + else if (inode->i_mode & S_IWOTH)
71397 + msg = "file in world-writable directory";
71398 + else if (inode->i_mode & S_IWGRP)
71399 + msg = "file in group-writable directory";
71400 +
71401 + if (msg) {
71402 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71403 + return 0;
71404 + }
71405 +#endif
71406 +#endif
71407 + return 1;
71408 +}
71409 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71410 new file mode 100644
71411 index 0000000..ae02d8e
71412 --- /dev/null
71413 +++ b/grsecurity/grsec_usb.c
71414 @@ -0,0 +1,15 @@
71415 +#include <linux/kernel.h>
71416 +#include <linux/grinternal.h>
71417 +#include <linux/module.h>
71418 +
71419 +int gr_handle_new_usb(void)
71420 +{
71421 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71422 + if (grsec_deny_new_usb) {
71423 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71424 + return 1;
71425 + }
71426 +#endif
71427 + return 0;
71428 +}
71429 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71430 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71431 new file mode 100644
71432 index 0000000..9f7b1ac
71433 --- /dev/null
71434 +++ b/grsecurity/grsum.c
71435 @@ -0,0 +1,61 @@
71436 +#include <linux/err.h>
71437 +#include <linux/kernel.h>
71438 +#include <linux/sched.h>
71439 +#include <linux/mm.h>
71440 +#include <linux/scatterlist.h>
71441 +#include <linux/crypto.h>
71442 +#include <linux/gracl.h>
71443 +
71444 +
71445 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71446 +#error "crypto and sha256 must be built into the kernel"
71447 +#endif
71448 +
71449 +int
71450 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71451 +{
71452 + char *p;
71453 + struct crypto_hash *tfm;
71454 + struct hash_desc desc;
71455 + struct scatterlist sg;
71456 + unsigned char temp_sum[GR_SHA_LEN];
71457 + volatile int retval = 0;
71458 + volatile int dummy = 0;
71459 + unsigned int i;
71460 +
71461 + sg_init_table(&sg, 1);
71462 +
71463 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71464 + if (IS_ERR(tfm)) {
71465 + /* should never happen, since sha256 should be built in */
71466 + return 1;
71467 + }
71468 +
71469 + desc.tfm = tfm;
71470 + desc.flags = 0;
71471 +
71472 + crypto_hash_init(&desc);
71473 +
71474 + p = salt;
71475 + sg_set_buf(&sg, p, GR_SALT_LEN);
71476 + crypto_hash_update(&desc, &sg, sg.length);
71477 +
71478 + p = entry->pw;
71479 + sg_set_buf(&sg, p, strlen(p));
71480 +
71481 + crypto_hash_update(&desc, &sg, sg.length);
71482 +
71483 + crypto_hash_final(&desc, temp_sum);
71484 +
71485 + memset(entry->pw, 0, GR_PW_LEN);
71486 +
71487 + for (i = 0; i < GR_SHA_LEN; i++)
71488 + if (sum[i] != temp_sum[i])
71489 + retval = 1;
71490 + else
71491 + dummy = 1; // waste a cycle
71492 +
71493 + crypto_free_hash(tfm);
71494 +
71495 + return retval;
71496 +}
71497 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71498 index 77ff547..181834f 100644
71499 --- a/include/asm-generic/4level-fixup.h
71500 +++ b/include/asm-generic/4level-fixup.h
71501 @@ -13,8 +13,10 @@
71502 #define pmd_alloc(mm, pud, address) \
71503 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71504 NULL: pmd_offset(pud, address))
71505 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71506
71507 #define pud_alloc(mm, pgd, address) (pgd)
71508 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71509 #define pud_offset(pgd, start) (pgd)
71510 #define pud_none(pud) 0
71511 #define pud_bad(pud) 0
71512 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71513 index b7babf0..04ad282 100644
71514 --- a/include/asm-generic/atomic-long.h
71515 +++ b/include/asm-generic/atomic-long.h
71516 @@ -22,6 +22,12 @@
71517
71518 typedef atomic64_t atomic_long_t;
71519
71520 +#ifdef CONFIG_PAX_REFCOUNT
71521 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71522 +#else
71523 +typedef atomic64_t atomic_long_unchecked_t;
71524 +#endif
71525 +
71526 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71527
71528 static inline long atomic_long_read(atomic_long_t *l)
71529 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71530 return (long)atomic64_read(v);
71531 }
71532
71533 +#ifdef CONFIG_PAX_REFCOUNT
71534 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71535 +{
71536 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71537 +
71538 + return (long)atomic64_read_unchecked(v);
71539 +}
71540 +#endif
71541 +
71542 static inline void atomic_long_set(atomic_long_t *l, long i)
71543 {
71544 atomic64_t *v = (atomic64_t *)l;
71545 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71546 atomic64_set(v, i);
71547 }
71548
71549 +#ifdef CONFIG_PAX_REFCOUNT
71550 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71551 +{
71552 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71553 +
71554 + atomic64_set_unchecked(v, i);
71555 +}
71556 +#endif
71557 +
71558 static inline void atomic_long_inc(atomic_long_t *l)
71559 {
71560 atomic64_t *v = (atomic64_t *)l;
71561 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71562 atomic64_inc(v);
71563 }
71564
71565 +#ifdef CONFIG_PAX_REFCOUNT
71566 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71567 +{
71568 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71569 +
71570 + atomic64_inc_unchecked(v);
71571 +}
71572 +#endif
71573 +
71574 static inline void atomic_long_dec(atomic_long_t *l)
71575 {
71576 atomic64_t *v = (atomic64_t *)l;
71577 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71578 atomic64_dec(v);
71579 }
71580
71581 +#ifdef CONFIG_PAX_REFCOUNT
71582 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71583 +{
71584 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71585 +
71586 + atomic64_dec_unchecked(v);
71587 +}
71588 +#endif
71589 +
71590 static inline void atomic_long_add(long i, atomic_long_t *l)
71591 {
71592 atomic64_t *v = (atomic64_t *)l;
71593 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71594 atomic64_add(i, v);
71595 }
71596
71597 +#ifdef CONFIG_PAX_REFCOUNT
71598 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71599 +{
71600 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71601 +
71602 + atomic64_add_unchecked(i, v);
71603 +}
71604 +#endif
71605 +
71606 static inline void atomic_long_sub(long i, atomic_long_t *l)
71607 {
71608 atomic64_t *v = (atomic64_t *)l;
71609 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71610 atomic64_sub(i, v);
71611 }
71612
71613 +#ifdef CONFIG_PAX_REFCOUNT
71614 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71615 +{
71616 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71617 +
71618 + atomic64_sub_unchecked(i, v);
71619 +}
71620 +#endif
71621 +
71622 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71623 {
71624 atomic64_t *v = (atomic64_t *)l;
71625 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71626 return (long)atomic64_add_return(i, v);
71627 }
71628
71629 +#ifdef CONFIG_PAX_REFCOUNT
71630 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71631 +{
71632 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71633 +
71634 + return (long)atomic64_add_return_unchecked(i, v);
71635 +}
71636 +#endif
71637 +
71638 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71639 {
71640 atomic64_t *v = (atomic64_t *)l;
71641 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71642 return (long)atomic64_inc_return(v);
71643 }
71644
71645 +#ifdef CONFIG_PAX_REFCOUNT
71646 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71647 +{
71648 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71649 +
71650 + return (long)atomic64_inc_return_unchecked(v);
71651 +}
71652 +#endif
71653 +
71654 static inline long atomic_long_dec_return(atomic_long_t *l)
71655 {
71656 atomic64_t *v = (atomic64_t *)l;
71657 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71658
71659 typedef atomic_t atomic_long_t;
71660
71661 +#ifdef CONFIG_PAX_REFCOUNT
71662 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71663 +#else
71664 +typedef atomic_t atomic_long_unchecked_t;
71665 +#endif
71666 +
71667 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71668 static inline long atomic_long_read(atomic_long_t *l)
71669 {
71670 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71671 return (long)atomic_read(v);
71672 }
71673
71674 +#ifdef CONFIG_PAX_REFCOUNT
71675 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71676 +{
71677 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71678 +
71679 + return (long)atomic_read_unchecked(v);
71680 +}
71681 +#endif
71682 +
71683 static inline void atomic_long_set(atomic_long_t *l, long i)
71684 {
71685 atomic_t *v = (atomic_t *)l;
71686 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71687 atomic_set(v, i);
71688 }
71689
71690 +#ifdef CONFIG_PAX_REFCOUNT
71691 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71692 +{
71693 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71694 +
71695 + atomic_set_unchecked(v, i);
71696 +}
71697 +#endif
71698 +
71699 static inline void atomic_long_inc(atomic_long_t *l)
71700 {
71701 atomic_t *v = (atomic_t *)l;
71702 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71703 atomic_inc(v);
71704 }
71705
71706 +#ifdef CONFIG_PAX_REFCOUNT
71707 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71708 +{
71709 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71710 +
71711 + atomic_inc_unchecked(v);
71712 +}
71713 +#endif
71714 +
71715 static inline void atomic_long_dec(atomic_long_t *l)
71716 {
71717 atomic_t *v = (atomic_t *)l;
71718 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71719 atomic_dec(v);
71720 }
71721
71722 +#ifdef CONFIG_PAX_REFCOUNT
71723 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71724 +{
71725 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71726 +
71727 + atomic_dec_unchecked(v);
71728 +}
71729 +#endif
71730 +
71731 static inline void atomic_long_add(long i, atomic_long_t *l)
71732 {
71733 atomic_t *v = (atomic_t *)l;
71734 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71735 atomic_add(i, v);
71736 }
71737
71738 +#ifdef CONFIG_PAX_REFCOUNT
71739 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71740 +{
71741 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71742 +
71743 + atomic_add_unchecked(i, v);
71744 +}
71745 +#endif
71746 +
71747 static inline void atomic_long_sub(long i, atomic_long_t *l)
71748 {
71749 atomic_t *v = (atomic_t *)l;
71750 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71751 atomic_sub(i, v);
71752 }
71753
71754 +#ifdef CONFIG_PAX_REFCOUNT
71755 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71756 +{
71757 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71758 +
71759 + atomic_sub_unchecked(i, v);
71760 +}
71761 +#endif
71762 +
71763 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71764 {
71765 atomic_t *v = (atomic_t *)l;
71766 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71767 return (long)atomic_add_return(i, v);
71768 }
71769
71770 +#ifdef CONFIG_PAX_REFCOUNT
71771 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71772 +{
71773 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71774 +
71775 + return (long)atomic_add_return_unchecked(i, v);
71776 +}
71777 +
71778 +#endif
71779 +
71780 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71781 {
71782 atomic_t *v = (atomic_t *)l;
71783 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71784 return (long)atomic_inc_return(v);
71785 }
71786
71787 +#ifdef CONFIG_PAX_REFCOUNT
71788 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71789 +{
71790 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71791 +
71792 + return (long)atomic_inc_return_unchecked(v);
71793 +}
71794 +#endif
71795 +
71796 static inline long atomic_long_dec_return(atomic_long_t *l)
71797 {
71798 atomic_t *v = (atomic_t *)l;
71799 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71800
71801 #endif /* BITS_PER_LONG == 64 */
71802
71803 +#ifdef CONFIG_PAX_REFCOUNT
71804 +static inline void pax_refcount_needs_these_functions(void)
71805 +{
71806 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71807 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71808 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71809 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71810 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71811 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71812 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71813 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71814 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71815 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71816 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71817 +#ifdef CONFIG_X86
71818 + atomic_clear_mask_unchecked(0, NULL);
71819 + atomic_set_mask_unchecked(0, NULL);
71820 +#endif
71821 +
71822 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71823 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71824 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71825 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71826 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71827 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71828 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71829 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71830 +}
71831 +#else
71832 +#define atomic_read_unchecked(v) atomic_read(v)
71833 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71834 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71835 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71836 +#define atomic_inc_unchecked(v) atomic_inc(v)
71837 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71838 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71839 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71840 +#define atomic_dec_unchecked(v) atomic_dec(v)
71841 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71842 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71843 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71844 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71845 +
71846 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71847 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71848 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71849 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71850 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71851 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71852 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71853 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71854 +#endif
71855 +
71856 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71857 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71858 index 33bd2de..f31bff97 100644
71859 --- a/include/asm-generic/atomic.h
71860 +++ b/include/asm-generic/atomic.h
71861 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71862 * Atomically clears the bits set in @mask from @v
71863 */
71864 #ifndef atomic_clear_mask
71865 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71866 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71867 {
71868 unsigned long flags;
71869
71870 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71871 index b18ce4f..2ee2843 100644
71872 --- a/include/asm-generic/atomic64.h
71873 +++ b/include/asm-generic/atomic64.h
71874 @@ -16,6 +16,8 @@ typedef struct {
71875 long long counter;
71876 } atomic64_t;
71877
71878 +typedef atomic64_t atomic64_unchecked_t;
71879 +
71880 #define ATOMIC64_INIT(i) { (i) }
71881
71882 extern long long atomic64_read(const atomic64_t *v);
71883 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71884 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71885 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71886
71887 +#define atomic64_read_unchecked(v) atomic64_read(v)
71888 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71889 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71890 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71891 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71892 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71893 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71894 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71895 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71896 +
71897 #endif /* _ASM_GENERIC_ATOMIC64_H */
71898 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71899 index 1bfcfe5..e04c5c9 100644
71900 --- a/include/asm-generic/cache.h
71901 +++ b/include/asm-generic/cache.h
71902 @@ -6,7 +6,7 @@
71903 * cache lines need to provide their own cache.h.
71904 */
71905
71906 -#define L1_CACHE_SHIFT 5
71907 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71908 +#define L1_CACHE_SHIFT 5UL
71909 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71910
71911 #endif /* __ASM_GENERIC_CACHE_H */
71912 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71913 index 0d68a1e..b74a761 100644
71914 --- a/include/asm-generic/emergency-restart.h
71915 +++ b/include/asm-generic/emergency-restart.h
71916 @@ -1,7 +1,7 @@
71917 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71918 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71919
71920 -static inline void machine_emergency_restart(void)
71921 +static inline __noreturn void machine_emergency_restart(void)
71922 {
71923 machine_restart(NULL);
71924 }
71925 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
71926 index 90f99c7..00ce236 100644
71927 --- a/include/asm-generic/kmap_types.h
71928 +++ b/include/asm-generic/kmap_types.h
71929 @@ -2,9 +2,9 @@
71930 #define _ASM_GENERIC_KMAP_TYPES_H
71931
71932 #ifdef __WITH_KM_FENCE
71933 -# define KM_TYPE_NR 41
71934 +# define KM_TYPE_NR 42
71935 #else
71936 -# define KM_TYPE_NR 20
71937 +# define KM_TYPE_NR 21
71938 #endif
71939
71940 #endif
71941 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
71942 index 9ceb03b..62b0b8f 100644
71943 --- a/include/asm-generic/local.h
71944 +++ b/include/asm-generic/local.h
71945 @@ -23,24 +23,37 @@ typedef struct
71946 atomic_long_t a;
71947 } local_t;
71948
71949 +typedef struct {
71950 + atomic_long_unchecked_t a;
71951 +} local_unchecked_t;
71952 +
71953 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
71954
71955 #define local_read(l) atomic_long_read(&(l)->a)
71956 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
71957 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
71958 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
71959 #define local_inc(l) atomic_long_inc(&(l)->a)
71960 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
71961 #define local_dec(l) atomic_long_dec(&(l)->a)
71962 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
71963 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
71964 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
71965 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
71966 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
71967
71968 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
71969 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
71970 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
71971 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
71972 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
71973 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
71974 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
71975 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
71976 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
71977
71978 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71979 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71980 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
71981 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
71982 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
71983 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
71984 index 725612b..9cc513a 100644
71985 --- a/include/asm-generic/pgtable-nopmd.h
71986 +++ b/include/asm-generic/pgtable-nopmd.h
71987 @@ -1,14 +1,19 @@
71988 #ifndef _PGTABLE_NOPMD_H
71989 #define _PGTABLE_NOPMD_H
71990
71991 -#ifndef __ASSEMBLY__
71992 -
71993 #include <asm-generic/pgtable-nopud.h>
71994
71995 -struct mm_struct;
71996 -
71997 #define __PAGETABLE_PMD_FOLDED
71998
71999 +#define PMD_SHIFT PUD_SHIFT
72000 +#define PTRS_PER_PMD 1
72001 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72002 +#define PMD_MASK (~(PMD_SIZE-1))
72003 +
72004 +#ifndef __ASSEMBLY__
72005 +
72006 +struct mm_struct;
72007 +
72008 /*
72009 * Having the pmd type consist of a pud gets the size right, and allows
72010 * us to conceptually access the pud entry that this pmd is folded into
72011 @@ -16,11 +21,6 @@ struct mm_struct;
72012 */
72013 typedef struct { pud_t pud; } pmd_t;
72014
72015 -#define PMD_SHIFT PUD_SHIFT
72016 -#define PTRS_PER_PMD 1
72017 -#define PMD_SIZE (1UL << PMD_SHIFT)
72018 -#define PMD_MASK (~(PMD_SIZE-1))
72019 -
72020 /*
72021 * The "pud_xxx()" functions here are trivial for a folded two-level
72022 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72023 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72024 index 810431d..0ec4804f 100644
72025 --- a/include/asm-generic/pgtable-nopud.h
72026 +++ b/include/asm-generic/pgtable-nopud.h
72027 @@ -1,10 +1,15 @@
72028 #ifndef _PGTABLE_NOPUD_H
72029 #define _PGTABLE_NOPUD_H
72030
72031 -#ifndef __ASSEMBLY__
72032 -
72033 #define __PAGETABLE_PUD_FOLDED
72034
72035 +#define PUD_SHIFT PGDIR_SHIFT
72036 +#define PTRS_PER_PUD 1
72037 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72038 +#define PUD_MASK (~(PUD_SIZE-1))
72039 +
72040 +#ifndef __ASSEMBLY__
72041 +
72042 /*
72043 * Having the pud type consist of a pgd gets the size right, and allows
72044 * us to conceptually access the pgd entry that this pud is folded into
72045 @@ -12,11 +17,6 @@
72046 */
72047 typedef struct { pgd_t pgd; } pud_t;
72048
72049 -#define PUD_SHIFT PGDIR_SHIFT
72050 -#define PTRS_PER_PUD 1
72051 -#define PUD_SIZE (1UL << PUD_SHIFT)
72052 -#define PUD_MASK (~(PUD_SIZE-1))
72053 -
72054 /*
72055 * The "pgd_xxx()" functions here are trivial for a folded two-level
72056 * setup: the pud is never bad, and a pud always exists (as it's folded
72057 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72058 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72059
72060 #define pgd_populate(mm, pgd, pud) do { } while (0)
72061 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72062 /*
72063 * (puds are folded into pgds so this doesn't get actually called,
72064 * but the define is needed for a generic inline function.)
72065 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72066 index 0807ddf..cd67747 100644
72067 --- a/include/asm-generic/pgtable.h
72068 +++ b/include/asm-generic/pgtable.h
72069 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72070 }
72071 #endif /* CONFIG_NUMA_BALANCING */
72072
72073 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72074 +#ifdef CONFIG_PAX_KERNEXEC
72075 +#error KERNEXEC requires pax_open_kernel
72076 +#else
72077 +static inline unsigned long pax_open_kernel(void) { return 0; }
72078 +#endif
72079 +#endif
72080 +
72081 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72082 +#ifdef CONFIG_PAX_KERNEXEC
72083 +#error KERNEXEC requires pax_close_kernel
72084 +#else
72085 +static inline unsigned long pax_close_kernel(void) { return 0; }
72086 +#endif
72087 +#endif
72088 +
72089 #endif /* CONFIG_MMU */
72090
72091 #endif /* !__ASSEMBLY__ */
72092 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72093 index dc1269c..48a4f51 100644
72094 --- a/include/asm-generic/uaccess.h
72095 +++ b/include/asm-generic/uaccess.h
72096 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72097 return __clear_user(to, n);
72098 }
72099
72100 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72101 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72102 +#error UDEREF requires pax_open_userland
72103 +#else
72104 +static inline unsigned long pax_open_userland(void) { return 0; }
72105 +#endif
72106 +#endif
72107 +
72108 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72109 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72110 +#error UDEREF requires pax_close_userland
72111 +#else
72112 +static inline unsigned long pax_close_userland(void) { return 0; }
72113 +#endif
72114 +#endif
72115 +
72116 #endif /* __ASM_GENERIC_UACCESS_H */
72117 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72118 index 69732d2..cbe16d9 100644
72119 --- a/include/asm-generic/vmlinux.lds.h
72120 +++ b/include/asm-generic/vmlinux.lds.h
72121 @@ -227,6 +227,7 @@
72122 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72123 VMLINUX_SYMBOL(__start_rodata) = .; \
72124 *(.rodata) *(.rodata.*) \
72125 + *(.data..read_only) \
72126 *(__vermagic) /* Kernel version magic */ \
72127 . = ALIGN(8); \
72128 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72129 @@ -710,17 +711,18 @@
72130 * section in the linker script will go there too. @phdr should have
72131 * a leading colon.
72132 *
72133 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72134 + * Note that this macros defines per_cpu_load as an absolute symbol.
72135 * If there is no need to put the percpu section at a predetermined
72136 * address, use PERCPU_SECTION.
72137 */
72138 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72139 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72140 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72141 + per_cpu_load = .; \
72142 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72143 - LOAD_OFFSET) { \
72144 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72145 PERCPU_INPUT(cacheline) \
72146 } phdr \
72147 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72148 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72149
72150 /**
72151 * PERCPU_SECTION - define output section for percpu area, simple version
72152 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72153 index 418d270..bfd2794 100644
72154 --- a/include/crypto/algapi.h
72155 +++ b/include/crypto/algapi.h
72156 @@ -34,7 +34,7 @@ struct crypto_type {
72157 unsigned int maskclear;
72158 unsigned int maskset;
72159 unsigned int tfmsize;
72160 -};
72161 +} __do_const;
72162
72163 struct crypto_instance {
72164 struct crypto_alg alg;
72165 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72166 index 12083dc..39740ec 100644
72167 --- a/include/drm/drmP.h
72168 +++ b/include/drm/drmP.h
72169 @@ -69,6 +69,7 @@
72170 #include <linux/workqueue.h>
72171 #include <linux/poll.h>
72172 #include <asm/pgalloc.h>
72173 +#include <asm/local.h>
72174 #include <drm/drm.h>
72175 #include <drm/drm_sarea.h>
72176
72177 @@ -293,10 +294,12 @@ do { \
72178 * \param cmd command.
72179 * \param arg argument.
72180 */
72181 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72182 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72183 + struct drm_file *file_priv);
72184 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72185 struct drm_file *file_priv);
72186
72187 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72188 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72189 unsigned long arg);
72190
72191 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72192 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72193 struct drm_ioctl_desc {
72194 unsigned int cmd;
72195 int flags;
72196 - drm_ioctl_t *func;
72197 + drm_ioctl_t func;
72198 unsigned int cmd_drv;
72199 const char *name;
72200 -};
72201 +} __do_const;
72202
72203 /**
72204 * Creates a driver or general drm_ioctl_desc array entry for the given
72205 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72206 int (*show)(struct seq_file*, void*); /** show callback */
72207 u32 driver_features; /**< Required driver features for this entry */
72208 void *data;
72209 -};
72210 +} __do_const;
72211
72212 /**
72213 * debugfs node structure. This structure represents a debugfs file.
72214 @@ -1088,7 +1091,7 @@ struct drm_device {
72215
72216 /** \name Usage Counters */
72217 /*@{ */
72218 - int open_count; /**< Outstanding files open */
72219 + local_t open_count; /**< Outstanding files open */
72220 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72221 atomic_t vma_count; /**< Outstanding vma areas open */
72222 int buf_use; /**< Buffers in use -- cannot alloc */
72223 @@ -1099,7 +1102,7 @@ struct drm_device {
72224 /*@{ */
72225 unsigned long counters;
72226 enum drm_stat_type types[15];
72227 - atomic_t counts[15];
72228 + atomic_unchecked_t counts[15];
72229 /*@} */
72230
72231 struct list_head filelist;
72232 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72233 index f43d556..94d9343 100644
72234 --- a/include/drm/drm_crtc_helper.h
72235 +++ b/include/drm/drm_crtc_helper.h
72236 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72237 struct drm_connector *connector);
72238 /* disable encoder when not in use - more explicit than dpms off */
72239 void (*disable)(struct drm_encoder *encoder);
72240 -};
72241 +} __no_const;
72242
72243 /**
72244 * drm_connector_helper_funcs - helper operations for connectors
72245 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72246 index 72dcbe8..8db58d7 100644
72247 --- a/include/drm/ttm/ttm_memory.h
72248 +++ b/include/drm/ttm/ttm_memory.h
72249 @@ -48,7 +48,7 @@
72250
72251 struct ttm_mem_shrink {
72252 int (*do_shrink) (struct ttm_mem_shrink *);
72253 -};
72254 +} __no_const;
72255
72256 /**
72257 * struct ttm_mem_global - Global memory accounting structure.
72258 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72259 index 4b840e8..155d235 100644
72260 --- a/include/keys/asymmetric-subtype.h
72261 +++ b/include/keys/asymmetric-subtype.h
72262 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72263 /* Verify the signature on a key of this subtype (optional) */
72264 int (*verify_signature)(const struct key *key,
72265 const struct public_key_signature *sig);
72266 -};
72267 +} __do_const;
72268
72269 /**
72270 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72271 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72272 index c1da539..1dcec55 100644
72273 --- a/include/linux/atmdev.h
72274 +++ b/include/linux/atmdev.h
72275 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72276 #endif
72277
72278 struct k_atm_aal_stats {
72279 -#define __HANDLE_ITEM(i) atomic_t i
72280 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72281 __AAL_STAT_ITEMS
72282 #undef __HANDLE_ITEM
72283 };
72284 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72285 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72286 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72287 struct module *owner;
72288 -};
72289 +} __do_const ;
72290
72291 struct atmphy_ops {
72292 int (*start)(struct atm_dev *dev);
72293 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72294 index 70cf138..0418ee2 100644
72295 --- a/include/linux/binfmts.h
72296 +++ b/include/linux/binfmts.h
72297 @@ -73,8 +73,10 @@ struct linux_binfmt {
72298 int (*load_binary)(struct linux_binprm *);
72299 int (*load_shlib)(struct file *);
72300 int (*core_dump)(struct coredump_params *cprm);
72301 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72302 + void (*handle_mmap)(struct file *);
72303 unsigned long min_coredump; /* minimal dump size */
72304 -};
72305 +} __do_const;
72306
72307 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72308
72309 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72310 index 2fdb4a4..54aad7e 100644
72311 --- a/include/linux/blkdev.h
72312 +++ b/include/linux/blkdev.h
72313 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72314 /* this callback is with swap_lock and sometimes page table lock held */
72315 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72316 struct module *owner;
72317 -};
72318 +} __do_const;
72319
72320 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72321 unsigned long);
72322 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72323 index 7c2e030..b72475d 100644
72324 --- a/include/linux/blktrace_api.h
72325 +++ b/include/linux/blktrace_api.h
72326 @@ -23,7 +23,7 @@ struct blk_trace {
72327 struct dentry *dir;
72328 struct dentry *dropped_file;
72329 struct dentry *msg_file;
72330 - atomic_t dropped;
72331 + atomic_unchecked_t dropped;
72332 };
72333
72334 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72335 diff --git a/include/linux/cache.h b/include/linux/cache.h
72336 index 4c57065..40346da 100644
72337 --- a/include/linux/cache.h
72338 +++ b/include/linux/cache.h
72339 @@ -16,6 +16,14 @@
72340 #define __read_mostly
72341 #endif
72342
72343 +#ifndef __read_only
72344 +#ifdef CONFIG_PAX_KERNEXEC
72345 +#error KERNEXEC requires __read_only
72346 +#else
72347 +#define __read_only __read_mostly
72348 +#endif
72349 +#endif
72350 +
72351 #ifndef ____cacheline_aligned
72352 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72353 #endif
72354 diff --git a/include/linux/capability.h b/include/linux/capability.h
72355 index d9a4f7f4..19f77d6 100644
72356 --- a/include/linux/capability.h
72357 +++ b/include/linux/capability.h
72358 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72359 extern bool nsown_capable(int cap);
72360 extern bool inode_capable(const struct inode *inode, int cap);
72361 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72362 +extern bool capable_nolog(int cap);
72363 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72364 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72365
72366 /* audit system wants to get cap info from files as well */
72367 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72368
72369 +extern int is_privileged_binary(const struct dentry *dentry);
72370 +
72371 #endif /* !_LINUX_CAPABILITY_H */
72372 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72373 index 8609d57..86e4d79 100644
72374 --- a/include/linux/cdrom.h
72375 +++ b/include/linux/cdrom.h
72376 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72377
72378 /* driver specifications */
72379 const int capability; /* capability flags */
72380 - int n_minors; /* number of active minor devices */
72381 /* handle uniform packets for scsi type devices (scsi,atapi) */
72382 int (*generic_packet) (struct cdrom_device_info *,
72383 struct packet_command *);
72384 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72385 index 4ce9056..86caac6 100644
72386 --- a/include/linux/cleancache.h
72387 +++ b/include/linux/cleancache.h
72388 @@ -31,7 +31,7 @@ struct cleancache_ops {
72389 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72390 void (*invalidate_inode)(int, struct cleancache_filekey);
72391 void (*invalidate_fs)(int);
72392 -};
72393 +} __no_const;
72394
72395 extern struct cleancache_ops *
72396 cleancache_register_ops(struct cleancache_ops *ops);
72397 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72398 index 1ec14a7..d0654a2 100644
72399 --- a/include/linux/clk-provider.h
72400 +++ b/include/linux/clk-provider.h
72401 @@ -132,6 +132,7 @@ struct clk_ops {
72402 unsigned long);
72403 void (*init)(struct clk_hw *hw);
72404 };
72405 +typedef struct clk_ops __no_const clk_ops_no_const;
72406
72407 /**
72408 * struct clk_init_data - holds init data that's common to all clocks and is
72409 diff --git a/include/linux/compat.h b/include/linux/compat.h
72410 index ec1aee4..1077986 100644
72411 --- a/include/linux/compat.h
72412 +++ b/include/linux/compat.h
72413 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72414 compat_size_t __user *len_ptr);
72415
72416 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72417 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72418 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72419 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72420 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72421 compat_ssize_t msgsz, int msgflg);
72422 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72423 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72424 compat_ulong_t addr, compat_ulong_t data);
72425 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72426 - compat_long_t addr, compat_long_t data);
72427 + compat_ulong_t addr, compat_ulong_t data);
72428
72429 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72430 /*
72431 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72432 index 842de22..7f3a41f 100644
72433 --- a/include/linux/compiler-gcc4.h
72434 +++ b/include/linux/compiler-gcc4.h
72435 @@ -39,9 +39,29 @@
72436 # define __compiletime_warning(message) __attribute__((warning(message)))
72437 # define __compiletime_error(message) __attribute__((error(message)))
72438 #endif /* __CHECKER__ */
72439 +
72440 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72441 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72442 +#define __bos0(ptr) __bos((ptr), 0)
72443 +#define __bos1(ptr) __bos((ptr), 1)
72444 #endif /* GCC_VERSION >= 40300 */
72445
72446 #if GCC_VERSION >= 40500
72447 +
72448 +#ifdef CONSTIFY_PLUGIN
72449 +#define __no_const __attribute__((no_const))
72450 +#define __do_const __attribute__((do_const))
72451 +#endif
72452 +
72453 +#ifdef SIZE_OVERFLOW_PLUGIN
72454 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72455 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72456 +#endif
72457 +
72458 +#ifdef LATENT_ENTROPY_PLUGIN
72459 +#define __latent_entropy __attribute__((latent_entropy))
72460 +#endif
72461 +
72462 /*
72463 * Mark a position in code as unreachable. This can be used to
72464 * suppress control flow warnings after asm blocks that transfer
72465 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72466 index 92669cd..1771a15 100644
72467 --- a/include/linux/compiler.h
72468 +++ b/include/linux/compiler.h
72469 @@ -5,11 +5,14 @@
72470
72471 #ifdef __CHECKER__
72472 # define __user __attribute__((noderef, address_space(1)))
72473 +# define __force_user __force __user
72474 # define __kernel __attribute__((address_space(0)))
72475 +# define __force_kernel __force __kernel
72476 # define __safe __attribute__((safe))
72477 # define __force __attribute__((force))
72478 # define __nocast __attribute__((nocast))
72479 # define __iomem __attribute__((noderef, address_space(2)))
72480 +# define __force_iomem __force __iomem
72481 # define __must_hold(x) __attribute__((context(x,1,1)))
72482 # define __acquires(x) __attribute__((context(x,0,1)))
72483 # define __releases(x) __attribute__((context(x,1,0)))
72484 @@ -17,20 +20,37 @@
72485 # define __release(x) __context__(x,-1)
72486 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72487 # define __percpu __attribute__((noderef, address_space(3)))
72488 +# define __force_percpu __force __percpu
72489 #ifdef CONFIG_SPARSE_RCU_POINTER
72490 # define __rcu __attribute__((noderef, address_space(4)))
72491 +# define __force_rcu __force __rcu
72492 #else
72493 # define __rcu
72494 +# define __force_rcu
72495 #endif
72496 extern void __chk_user_ptr(const volatile void __user *);
72497 extern void __chk_io_ptr(const volatile void __iomem *);
72498 #else
72499 -# define __user
72500 -# define __kernel
72501 +# ifdef CHECKER_PLUGIN
72502 +//# define __user
72503 +//# define __force_user
72504 +//# define __kernel
72505 +//# define __force_kernel
72506 +# else
72507 +# ifdef STRUCTLEAK_PLUGIN
72508 +# define __user __attribute__((user))
72509 +# else
72510 +# define __user
72511 +# endif
72512 +# define __force_user
72513 +# define __kernel
72514 +# define __force_kernel
72515 +# endif
72516 # define __safe
72517 # define __force
72518 # define __nocast
72519 # define __iomem
72520 +# define __force_iomem
72521 # define __chk_user_ptr(x) (void)0
72522 # define __chk_io_ptr(x) (void)0
72523 # define __builtin_warning(x, y...) (1)
72524 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72525 # define __release(x) (void)0
72526 # define __cond_lock(x,c) (c)
72527 # define __percpu
72528 +# define __force_percpu
72529 # define __rcu
72530 +# define __force_rcu
72531 #endif
72532
72533 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72534 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72535 # define __attribute_const__ /* unimplemented */
72536 #endif
72537
72538 +#ifndef __no_const
72539 +# define __no_const
72540 +#endif
72541 +
72542 +#ifndef __do_const
72543 +# define __do_const
72544 +#endif
72545 +
72546 +#ifndef __size_overflow
72547 +# define __size_overflow(...)
72548 +#endif
72549 +
72550 +#ifndef __intentional_overflow
72551 +# define __intentional_overflow(...)
72552 +#endif
72553 +
72554 +#ifndef __latent_entropy
72555 +# define __latent_entropy
72556 +#endif
72557 +
72558 /*
72559 * Tell gcc if a function is cold. The compiler will assume any path
72560 * directly leading to the call is unlikely.
72561 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72562 #define __cold
72563 #endif
72564
72565 +#ifndef __alloc_size
72566 +#define __alloc_size(...)
72567 +#endif
72568 +
72569 +#ifndef __bos
72570 +#define __bos(ptr, arg)
72571 +#endif
72572 +
72573 +#ifndef __bos0
72574 +#define __bos0(ptr)
72575 +#endif
72576 +
72577 +#ifndef __bos1
72578 +#define __bos1(ptr)
72579 +#endif
72580 +
72581 /* Simple shorthand for a section definition */
72582 #ifndef __section
72583 # define __section(S) __attribute__ ((__section__(#S)))
72584 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72585 * use is to mediate communication between process-level code and irq/NMI
72586 * handlers, all running on the same CPU.
72587 */
72588 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72589 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72590 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72591
72592 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72593 #ifdef CONFIG_KPROBES
72594 diff --git a/include/linux/completion.h b/include/linux/completion.h
72595 index 3cd574d..adce5fa 100644
72596 --- a/include/linux/completion.h
72597 +++ b/include/linux/completion.h
72598 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72599 extern void wait_for_completion(struct completion *);
72600 extern void wait_for_completion_io(struct completion *);
72601 extern int wait_for_completion_interruptible(struct completion *x);
72602 -extern int wait_for_completion_killable(struct completion *x);
72603 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72604 extern unsigned long wait_for_completion_timeout(struct completion *x,
72605 unsigned long timeout);
72606 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72607 unsigned long timeout);
72608 extern long wait_for_completion_interruptible_timeout(
72609 - struct completion *x, unsigned long timeout);
72610 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72611 extern long wait_for_completion_killable_timeout(
72612 - struct completion *x, unsigned long timeout);
72613 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72614 extern bool try_wait_for_completion(struct completion *x);
72615 extern bool completion_done(struct completion *x);
72616
72617 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72618 index 34025df..d94bbbc 100644
72619 --- a/include/linux/configfs.h
72620 +++ b/include/linux/configfs.h
72621 @@ -125,7 +125,7 @@ struct configfs_attribute {
72622 const char *ca_name;
72623 struct module *ca_owner;
72624 umode_t ca_mode;
72625 -};
72626 +} __do_const;
72627
72628 /*
72629 * Users often need to create attribute structures for their configurable
72630 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72631 index 90d5a15..950cb80 100644
72632 --- a/include/linux/cpufreq.h
72633 +++ b/include/linux/cpufreq.h
72634 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72635 int (*suspend) (struct cpufreq_policy *policy);
72636 int (*resume) (struct cpufreq_policy *policy);
72637 struct freq_attr **attr;
72638 -};
72639 +} __do_const;
72640
72641 /* flags */
72642
72643 @@ -325,6 +325,7 @@ struct global_attr {
72644 ssize_t (*store)(struct kobject *a, struct attribute *b,
72645 const char *c, size_t count);
72646 };
72647 +typedef struct global_attr __no_const global_attr_no_const;
72648
72649 #define define_one_global_ro(_name) \
72650 static struct global_attr _name = \
72651 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72652 index 0bc4b74..973b368 100644
72653 --- a/include/linux/cpuidle.h
72654 +++ b/include/linux/cpuidle.h
72655 @@ -52,7 +52,8 @@ struct cpuidle_state {
72656 int index);
72657
72658 int (*enter_dead) (struct cpuidle_device *dev, int index);
72659 -};
72660 +} __do_const;
72661 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72662
72663 /* Idle State Flags */
72664 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72665 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72666 void (*reflect) (struct cpuidle_device *dev, int index);
72667
72668 struct module *owner;
72669 -};
72670 +} __do_const;
72671
72672 #ifdef CONFIG_CPU_IDLE
72673
72674 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72675 index d08e4d2..95fad61 100644
72676 --- a/include/linux/cpumask.h
72677 +++ b/include/linux/cpumask.h
72678 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72679 }
72680
72681 /* Valid inputs for n are -1 and 0. */
72682 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72683 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72684 {
72685 return n+1;
72686 }
72687
72688 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72689 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72690 {
72691 return n+1;
72692 }
72693
72694 -static inline unsigned int cpumask_next_and(int n,
72695 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72696 const struct cpumask *srcp,
72697 const struct cpumask *andp)
72698 {
72699 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72700 *
72701 * Returns >= nr_cpu_ids if no further cpus set.
72702 */
72703 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72704 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72705 {
72706 /* -1 is a legal arg here. */
72707 if (n != -1)
72708 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72709 *
72710 * Returns >= nr_cpu_ids if no further cpus unset.
72711 */
72712 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72713 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72714 {
72715 /* -1 is a legal arg here. */
72716 if (n != -1)
72717 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72718 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72719 }
72720
72721 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72722 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72723 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72724
72725 /**
72726 diff --git a/include/linux/cred.h b/include/linux/cred.h
72727 index 04421e8..6bce4ef 100644
72728 --- a/include/linux/cred.h
72729 +++ b/include/linux/cred.h
72730 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72731 static inline void validate_process_creds(void)
72732 {
72733 }
72734 +static inline void validate_task_creds(struct task_struct *task)
72735 +{
72736 +}
72737 #endif
72738
72739 /**
72740 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72741 index b92eadf..b4ecdc1 100644
72742 --- a/include/linux/crypto.h
72743 +++ b/include/linux/crypto.h
72744 @@ -373,7 +373,7 @@ struct cipher_tfm {
72745 const u8 *key, unsigned int keylen);
72746 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72747 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72748 -};
72749 +} __no_const;
72750
72751 struct hash_tfm {
72752 int (*init)(struct hash_desc *desc);
72753 @@ -394,13 +394,13 @@ struct compress_tfm {
72754 int (*cot_decompress)(struct crypto_tfm *tfm,
72755 const u8 *src, unsigned int slen,
72756 u8 *dst, unsigned int *dlen);
72757 -};
72758 +} __no_const;
72759
72760 struct rng_tfm {
72761 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72762 unsigned int dlen);
72763 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72764 -};
72765 +} __no_const;
72766
72767 #define crt_ablkcipher crt_u.ablkcipher
72768 #define crt_aead crt_u.aead
72769 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72770 index 653589e..4ef254a 100644
72771 --- a/include/linux/ctype.h
72772 +++ b/include/linux/ctype.h
72773 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72774 * Fast implementation of tolower() for internal usage. Do not use in your
72775 * code.
72776 */
72777 -static inline char _tolower(const char c)
72778 +static inline unsigned char _tolower(const unsigned char c)
72779 {
72780 return c | 0x20;
72781 }
72782 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72783 index 7925bf0..d5143d2 100644
72784 --- a/include/linux/decompress/mm.h
72785 +++ b/include/linux/decompress/mm.h
72786 @@ -77,7 +77,7 @@ static void free(void *where)
72787 * warnings when not needed (indeed large_malloc / large_free are not
72788 * needed by inflate */
72789
72790 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72791 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72792 #define free(a) kfree(a)
72793
72794 #define large_malloc(a) vmalloc(a)
72795 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72796 index 5f1ab92..39c35ae 100644
72797 --- a/include/linux/devfreq.h
72798 +++ b/include/linux/devfreq.h
72799 @@ -114,7 +114,7 @@ struct devfreq_governor {
72800 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72801 int (*event_handler)(struct devfreq *devfreq,
72802 unsigned int event, void *data);
72803 -};
72804 +} __do_const;
72805
72806 /**
72807 * struct devfreq - Device devfreq structure
72808 diff --git a/include/linux/device.h b/include/linux/device.h
72809 index 22b546a..a573dc9 100644
72810 --- a/include/linux/device.h
72811 +++ b/include/linux/device.h
72812 @@ -305,7 +305,7 @@ struct subsys_interface {
72813 struct list_head node;
72814 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72815 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72816 -};
72817 +} __do_const;
72818
72819 int subsys_interface_register(struct subsys_interface *sif);
72820 void subsys_interface_unregister(struct subsys_interface *sif);
72821 @@ -493,7 +493,7 @@ struct device_type {
72822 void (*release)(struct device *dev);
72823
72824 const struct dev_pm_ops *pm;
72825 -};
72826 +} __do_const;
72827
72828 /* interface for exporting device attributes */
72829 struct device_attribute {
72830 @@ -503,11 +503,12 @@ struct device_attribute {
72831 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72832 const char *buf, size_t count);
72833 };
72834 +typedef struct device_attribute __no_const device_attribute_no_const;
72835
72836 struct dev_ext_attribute {
72837 struct device_attribute attr;
72838 void *var;
72839 -};
72840 +} __do_const;
72841
72842 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72843 char *buf);
72844 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72845 index 94af418..b1ca7a2 100644
72846 --- a/include/linux/dma-mapping.h
72847 +++ b/include/linux/dma-mapping.h
72848 @@ -54,7 +54,7 @@ struct dma_map_ops {
72849 u64 (*get_required_mask)(struct device *dev);
72850 #endif
72851 int is_phys;
72852 -};
72853 +} __do_const;
72854
72855 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72856
72857 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72858 index cb286b1..923d066 100644
72859 --- a/include/linux/dmaengine.h
72860 +++ b/include/linux/dmaengine.h
72861 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72862 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72863 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72864
72865 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72866 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72867 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72868 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72869 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72870 struct dma_pinned_list *pinned_list, struct page *page,
72871 unsigned int offset, size_t len);
72872
72873 diff --git a/include/linux/efi.h b/include/linux/efi.h
72874 index 5f8f176..62a0556 100644
72875 --- a/include/linux/efi.h
72876 +++ b/include/linux/efi.h
72877 @@ -745,6 +745,7 @@ struct efivar_operations {
72878 efi_set_variable_t *set_variable;
72879 efi_query_variable_store_t *query_variable_store;
72880 };
72881 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72882
72883 struct efivars {
72884 /*
72885 diff --git a/include/linux/elf.h b/include/linux/elf.h
72886 index 40a3c0e..4c45a38 100644
72887 --- a/include/linux/elf.h
72888 +++ b/include/linux/elf.h
72889 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72890 #define elf_note elf32_note
72891 #define elf_addr_t Elf32_Off
72892 #define Elf_Half Elf32_Half
72893 +#define elf_dyn Elf32_Dyn
72894
72895 #else
72896
72897 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72898 #define elf_note elf64_note
72899 #define elf_addr_t Elf64_Off
72900 #define Elf_Half Elf64_Half
72901 +#define elf_dyn Elf64_Dyn
72902
72903 #endif
72904
72905 diff --git a/include/linux/err.h b/include/linux/err.h
72906 index 221fcfb..f29e5e2 100644
72907 --- a/include/linux/err.h
72908 +++ b/include/linux/err.h
72909 @@ -19,12 +19,12 @@
72910
72911 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72912
72913 -static inline void * __must_check ERR_PTR(long error)
72914 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72915 {
72916 return (void *) error;
72917 }
72918
72919 -static inline long __must_check PTR_ERR(__force const void *ptr)
72920 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72921 {
72922 return (long) ptr;
72923 }
72924 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72925 index fcb51c8..bdafcf6 100644
72926 --- a/include/linux/extcon.h
72927 +++ b/include/linux/extcon.h
72928 @@ -134,7 +134,7 @@ struct extcon_dev {
72929 /* /sys/class/extcon/.../mutually_exclusive/... */
72930 struct attribute_group attr_g_muex;
72931 struct attribute **attrs_muex;
72932 - struct device_attribute *d_attrs_muex;
72933 + device_attribute_no_const *d_attrs_muex;
72934 };
72935
72936 /**
72937 diff --git a/include/linux/fb.h b/include/linux/fb.h
72938 index ffac70a..ca3e711 100644
72939 --- a/include/linux/fb.h
72940 +++ b/include/linux/fb.h
72941 @@ -304,7 +304,7 @@ struct fb_ops {
72942 /* called at KDB enter and leave time to prepare the console */
72943 int (*fb_debug_enter)(struct fb_info *info);
72944 int (*fb_debug_leave)(struct fb_info *info);
72945 -};
72946 +} __do_const;
72947
72948 #ifdef CONFIG_FB_TILEBLITTING
72949 #define FB_TILE_CURSOR_NONE 0
72950 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
72951 index 085197b..0fa6f0b 100644
72952 --- a/include/linux/fdtable.h
72953 +++ b/include/linux/fdtable.h
72954 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
72955 void put_files_struct(struct files_struct *fs);
72956 void reset_files_struct(struct files_struct *);
72957 int unshare_files(struct files_struct **);
72958 -struct files_struct *dup_fd(struct files_struct *, int *);
72959 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
72960 void do_close_on_exec(struct files_struct *);
72961 int iterate_fd(struct files_struct *, unsigned,
72962 int (*)(const void *, struct file *, unsigned),
72963 diff --git a/include/linux/filter.h b/include/linux/filter.h
72964 index a6ac848..a104a76 100644
72965 --- a/include/linux/filter.h
72966 +++ b/include/linux/filter.h
72967 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
72968
72969 struct sk_buff;
72970 struct sock;
72971 +struct bpf_jit_work;
72972
72973 struct sk_filter
72974 {
72975 @@ -27,6 +28,9 @@ struct sk_filter
72976 unsigned int len; /* Number of filter blocks */
72977 unsigned int (*bpf_func)(const struct sk_buff *skb,
72978 const struct sock_filter *filter);
72979 +#ifdef CONFIG_BPF_JIT
72980 + struct bpf_jit_work *work;
72981 +#endif
72982 struct rcu_head rcu;
72983 struct sock_filter insns[0];
72984 };
72985 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
72986 index 8293262..2b3b8bd 100644
72987 --- a/include/linux/frontswap.h
72988 +++ b/include/linux/frontswap.h
72989 @@ -11,7 +11,7 @@ struct frontswap_ops {
72990 int (*load)(unsigned, pgoff_t, struct page *);
72991 void (*invalidate_page)(unsigned, pgoff_t);
72992 void (*invalidate_area)(unsigned);
72993 -};
72994 +} __no_const;
72995
72996 extern bool frontswap_enabled;
72997 extern struct frontswap_ops *
72998 diff --git a/include/linux/fs.h b/include/linux/fs.h
72999 index 9818747..788bfbd 100644
73000 --- a/include/linux/fs.h
73001 +++ b/include/linux/fs.h
73002 @@ -1554,7 +1554,8 @@ struct file_operations {
73003 long (*fallocate)(struct file *file, int mode, loff_t offset,
73004 loff_t len);
73005 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73006 -};
73007 +} __do_const;
73008 +typedef struct file_operations __no_const file_operations_no_const;
73009
73010 struct inode_operations {
73011 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73012 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73013 return !IS_DEADDIR(inode);
73014 }
73015
73016 +static inline bool is_sidechannel_device(const struct inode *inode)
73017 +{
73018 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73019 + umode_t mode = inode->i_mode;
73020 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73021 +#else
73022 + return false;
73023 +#endif
73024 +}
73025 +
73026 #endif /* _LINUX_FS_H */
73027 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73028 index 2b93a9a..855d94a 100644
73029 --- a/include/linux/fs_struct.h
73030 +++ b/include/linux/fs_struct.h
73031 @@ -6,7 +6,7 @@
73032 #include <linux/seqlock.h>
73033
73034 struct fs_struct {
73035 - int users;
73036 + atomic_t users;
73037 spinlock_t lock;
73038 seqcount_t seq;
73039 int umask;
73040 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73041 index a9ff9a3..1ba1788 100644
73042 --- a/include/linux/fscache-cache.h
73043 +++ b/include/linux/fscache-cache.h
73044 @@ -113,7 +113,7 @@ struct fscache_operation {
73045 fscache_operation_release_t release;
73046 };
73047
73048 -extern atomic_t fscache_op_debug_id;
73049 +extern atomic_unchecked_t fscache_op_debug_id;
73050 extern void fscache_op_work_func(struct work_struct *work);
73051
73052 extern void fscache_enqueue_operation(struct fscache_operation *);
73053 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73054 INIT_WORK(&op->work, fscache_op_work_func);
73055 atomic_set(&op->usage, 1);
73056 op->state = FSCACHE_OP_ST_INITIALISED;
73057 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73058 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73059 op->processor = processor;
73060 op->release = release;
73061 INIT_LIST_HEAD(&op->pend_link);
73062 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73063 index 7a08623..4c07b0f 100644
73064 --- a/include/linux/fscache.h
73065 +++ b/include/linux/fscache.h
73066 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73067 * - this is mandatory for any object that may have data
73068 */
73069 void (*now_uncached)(void *cookie_netfs_data);
73070 -};
73071 +} __do_const;
73072
73073 /*
73074 * fscache cached network filesystem type
73075 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73076 index 1c804b0..1432c2b 100644
73077 --- a/include/linux/fsnotify.h
73078 +++ b/include/linux/fsnotify.h
73079 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73080 struct inode *inode = file_inode(file);
73081 __u32 mask = FS_ACCESS;
73082
73083 + if (is_sidechannel_device(inode))
73084 + return;
73085 +
73086 if (S_ISDIR(inode->i_mode))
73087 mask |= FS_ISDIR;
73088
73089 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73090 struct inode *inode = file_inode(file);
73091 __u32 mask = FS_MODIFY;
73092
73093 + if (is_sidechannel_device(inode))
73094 + return;
73095 +
73096 if (S_ISDIR(inode->i_mode))
73097 mask |= FS_ISDIR;
73098
73099 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73100 */
73101 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73102 {
73103 - return kstrdup(name, GFP_KERNEL);
73104 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73105 }
73106
73107 /*
73108 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73109 index 9f3c275..8bdff5d 100644
73110 --- a/include/linux/genhd.h
73111 +++ b/include/linux/genhd.h
73112 @@ -194,7 +194,7 @@ struct gendisk {
73113 struct kobject *slave_dir;
73114
73115 struct timer_rand_state *random;
73116 - atomic_t sync_io; /* RAID */
73117 + atomic_unchecked_t sync_io; /* RAID */
73118 struct disk_events *ev;
73119 #ifdef CONFIG_BLK_DEV_INTEGRITY
73120 struct blk_integrity *integrity;
73121 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73122 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73123
73124 /* drivers/char/random.c */
73125 -extern void add_disk_randomness(struct gendisk *disk);
73126 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73127 extern void rand_initialize_disk(struct gendisk *disk);
73128
73129 static inline sector_t get_start_sect(struct block_device *bdev)
73130 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73131 index 023bc34..b02b46a 100644
73132 --- a/include/linux/genl_magic_func.h
73133 +++ b/include/linux/genl_magic_func.h
73134 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73135 },
73136
73137 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73138 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73139 +static struct genl_ops ZZZ_genl_ops[] = {
73140 #include GENL_MAGIC_INCLUDE_FILE
73141 };
73142
73143 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73144 index 9b4dd49..61fd41d 100644
73145 --- a/include/linux/gfp.h
73146 +++ b/include/linux/gfp.h
73147 @@ -35,6 +35,13 @@ struct vm_area_struct;
73148 #define ___GFP_NO_KSWAPD 0x400000u
73149 #define ___GFP_OTHER_NODE 0x800000u
73150 #define ___GFP_WRITE 0x1000000u
73151 +
73152 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73153 +#define ___GFP_USERCOPY 0x2000000u
73154 +#else
73155 +#define ___GFP_USERCOPY 0
73156 +#endif
73157 +
73158 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73159
73160 /*
73161 @@ -92,6 +99,7 @@ struct vm_area_struct;
73162 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73163 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73164 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73165 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73166
73167 /*
73168 * This may seem redundant, but it's a way of annotating false positives vs.
73169 @@ -99,7 +107,7 @@ struct vm_area_struct;
73170 */
73171 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73172
73173 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73174 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73175 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73176
73177 /* This equals 0, but use constants in case they ever change */
73178 @@ -153,6 +161,8 @@ struct vm_area_struct;
73179 /* 4GB DMA on some platforms */
73180 #define GFP_DMA32 __GFP_DMA32
73181
73182 +#define GFP_USERCOPY __GFP_USERCOPY
73183 +
73184 /* Convert GFP flags to their corresponding migrate type */
73185 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73186 {
73187 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73188 new file mode 100644
73189 index 0000000..ebe6d72
73190 --- /dev/null
73191 +++ b/include/linux/gracl.h
73192 @@ -0,0 +1,319 @@
73193 +#ifndef GR_ACL_H
73194 +#define GR_ACL_H
73195 +
73196 +#include <linux/grdefs.h>
73197 +#include <linux/resource.h>
73198 +#include <linux/capability.h>
73199 +#include <linux/dcache.h>
73200 +#include <asm/resource.h>
73201 +
73202 +/* Major status information */
73203 +
73204 +#define GR_VERSION "grsecurity 2.9.1"
73205 +#define GRSECURITY_VERSION 0x2901
73206 +
73207 +enum {
73208 + GR_SHUTDOWN = 0,
73209 + GR_ENABLE = 1,
73210 + GR_SPROLE = 2,
73211 + GR_RELOAD = 3,
73212 + GR_SEGVMOD = 4,
73213 + GR_STATUS = 5,
73214 + GR_UNSPROLE = 6,
73215 + GR_PASSSET = 7,
73216 + GR_SPROLEPAM = 8,
73217 +};
73218 +
73219 +/* Password setup definitions
73220 + * kernel/grhash.c */
73221 +enum {
73222 + GR_PW_LEN = 128,
73223 + GR_SALT_LEN = 16,
73224 + GR_SHA_LEN = 32,
73225 +};
73226 +
73227 +enum {
73228 + GR_SPROLE_LEN = 64,
73229 +};
73230 +
73231 +enum {
73232 + GR_NO_GLOB = 0,
73233 + GR_REG_GLOB,
73234 + GR_CREATE_GLOB
73235 +};
73236 +
73237 +#define GR_NLIMITS 32
73238 +
73239 +/* Begin Data Structures */
73240 +
73241 +struct sprole_pw {
73242 + unsigned char *rolename;
73243 + unsigned char salt[GR_SALT_LEN];
73244 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73245 +};
73246 +
73247 +struct name_entry {
73248 + __u32 key;
73249 + ino_t inode;
73250 + dev_t device;
73251 + char *name;
73252 + __u16 len;
73253 + __u8 deleted;
73254 + struct name_entry *prev;
73255 + struct name_entry *next;
73256 +};
73257 +
73258 +struct inodev_entry {
73259 + struct name_entry *nentry;
73260 + struct inodev_entry *prev;
73261 + struct inodev_entry *next;
73262 +};
73263 +
73264 +struct acl_role_db {
73265 + struct acl_role_label **r_hash;
73266 + __u32 r_size;
73267 +};
73268 +
73269 +struct inodev_db {
73270 + struct inodev_entry **i_hash;
73271 + __u32 i_size;
73272 +};
73273 +
73274 +struct name_db {
73275 + struct name_entry **n_hash;
73276 + __u32 n_size;
73277 +};
73278 +
73279 +struct crash_uid {
73280 + uid_t uid;
73281 + unsigned long expires;
73282 +};
73283 +
73284 +struct gr_hash_struct {
73285 + void **table;
73286 + void **nametable;
73287 + void *first;
73288 + __u32 table_size;
73289 + __u32 used_size;
73290 + int type;
73291 +};
73292 +
73293 +/* Userspace Grsecurity ACL data structures */
73294 +
73295 +struct acl_subject_label {
73296 + char *filename;
73297 + ino_t inode;
73298 + dev_t device;
73299 + __u32 mode;
73300 + kernel_cap_t cap_mask;
73301 + kernel_cap_t cap_lower;
73302 + kernel_cap_t cap_invert_audit;
73303 +
73304 + struct rlimit res[GR_NLIMITS];
73305 + __u32 resmask;
73306 +
73307 + __u8 user_trans_type;
73308 + __u8 group_trans_type;
73309 + uid_t *user_transitions;
73310 + gid_t *group_transitions;
73311 + __u16 user_trans_num;
73312 + __u16 group_trans_num;
73313 +
73314 + __u32 sock_families[2];
73315 + __u32 ip_proto[8];
73316 + __u32 ip_type;
73317 + struct acl_ip_label **ips;
73318 + __u32 ip_num;
73319 + __u32 inaddr_any_override;
73320 +
73321 + __u32 crashes;
73322 + unsigned long expires;
73323 +
73324 + struct acl_subject_label *parent_subject;
73325 + struct gr_hash_struct *hash;
73326 + struct acl_subject_label *prev;
73327 + struct acl_subject_label *next;
73328 +
73329 + struct acl_object_label **obj_hash;
73330 + __u32 obj_hash_size;
73331 + __u16 pax_flags;
73332 +};
73333 +
73334 +struct role_allowed_ip {
73335 + __u32 addr;
73336 + __u32 netmask;
73337 +
73338 + struct role_allowed_ip *prev;
73339 + struct role_allowed_ip *next;
73340 +};
73341 +
73342 +struct role_transition {
73343 + char *rolename;
73344 +
73345 + struct role_transition *prev;
73346 + struct role_transition *next;
73347 +};
73348 +
73349 +struct acl_role_label {
73350 + char *rolename;
73351 + uid_t uidgid;
73352 + __u16 roletype;
73353 +
73354 + __u16 auth_attempts;
73355 + unsigned long expires;
73356 +
73357 + struct acl_subject_label *root_label;
73358 + struct gr_hash_struct *hash;
73359 +
73360 + struct acl_role_label *prev;
73361 + struct acl_role_label *next;
73362 +
73363 + struct role_transition *transitions;
73364 + struct role_allowed_ip *allowed_ips;
73365 + uid_t *domain_children;
73366 + __u16 domain_child_num;
73367 +
73368 + umode_t umask;
73369 +
73370 + struct acl_subject_label **subj_hash;
73371 + __u32 subj_hash_size;
73372 +};
73373 +
73374 +struct user_acl_role_db {
73375 + struct acl_role_label **r_table;
73376 + __u32 num_pointers; /* Number of allocations to track */
73377 + __u32 num_roles; /* Number of roles */
73378 + __u32 num_domain_children; /* Number of domain children */
73379 + __u32 num_subjects; /* Number of subjects */
73380 + __u32 num_objects; /* Number of objects */
73381 +};
73382 +
73383 +struct acl_object_label {
73384 + char *filename;
73385 + ino_t inode;
73386 + dev_t device;
73387 + __u32 mode;
73388 +
73389 + struct acl_subject_label *nested;
73390 + struct acl_object_label *globbed;
73391 +
73392 + /* next two structures not used */
73393 +
73394 + struct acl_object_label *prev;
73395 + struct acl_object_label *next;
73396 +};
73397 +
73398 +struct acl_ip_label {
73399 + char *iface;
73400 + __u32 addr;
73401 + __u32 netmask;
73402 + __u16 low, high;
73403 + __u8 mode;
73404 + __u32 type;
73405 + __u32 proto[8];
73406 +
73407 + /* next two structures not used */
73408 +
73409 + struct acl_ip_label *prev;
73410 + struct acl_ip_label *next;
73411 +};
73412 +
73413 +struct gr_arg {
73414 + struct user_acl_role_db role_db;
73415 + unsigned char pw[GR_PW_LEN];
73416 + unsigned char salt[GR_SALT_LEN];
73417 + unsigned char sum[GR_SHA_LEN];
73418 + unsigned char sp_role[GR_SPROLE_LEN];
73419 + struct sprole_pw *sprole_pws;
73420 + dev_t segv_device;
73421 + ino_t segv_inode;
73422 + uid_t segv_uid;
73423 + __u16 num_sprole_pws;
73424 + __u16 mode;
73425 +};
73426 +
73427 +struct gr_arg_wrapper {
73428 + struct gr_arg *arg;
73429 + __u32 version;
73430 + __u32 size;
73431 +};
73432 +
73433 +struct subject_map {
73434 + struct acl_subject_label *user;
73435 + struct acl_subject_label *kernel;
73436 + struct subject_map *prev;
73437 + struct subject_map *next;
73438 +};
73439 +
73440 +struct acl_subj_map_db {
73441 + struct subject_map **s_hash;
73442 + __u32 s_size;
73443 +};
73444 +
73445 +/* End Data Structures Section */
73446 +
73447 +/* Hash functions generated by empirical testing by Brad Spengler
73448 + Makes good use of the low bits of the inode. Generally 0-1 times
73449 + in loop for successful match. 0-3 for unsuccessful match.
73450 + Shift/add algorithm with modulus of table size and an XOR*/
73451 +
73452 +static __inline__ unsigned int
73453 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73454 +{
73455 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73456 +}
73457 +
73458 + static __inline__ unsigned int
73459 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73460 +{
73461 + return ((const unsigned long)userp % sz);
73462 +}
73463 +
73464 +static __inline__ unsigned int
73465 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73466 +{
73467 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73468 +}
73469 +
73470 +static __inline__ unsigned int
73471 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73472 +{
73473 + return full_name_hash((const unsigned char *)name, len) % sz;
73474 +}
73475 +
73476 +#define FOR_EACH_ROLE_START(role) \
73477 + role = role_list; \
73478 + while (role) {
73479 +
73480 +#define FOR_EACH_ROLE_END(role) \
73481 + role = role->prev; \
73482 + }
73483 +
73484 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73485 + subj = NULL; \
73486 + iter = 0; \
73487 + while (iter < role->subj_hash_size) { \
73488 + if (subj == NULL) \
73489 + subj = role->subj_hash[iter]; \
73490 + if (subj == NULL) { \
73491 + iter++; \
73492 + continue; \
73493 + }
73494 +
73495 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73496 + subj = subj->next; \
73497 + if (subj == NULL) \
73498 + iter++; \
73499 + }
73500 +
73501 +
73502 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73503 + subj = role->hash->first; \
73504 + while (subj != NULL) {
73505 +
73506 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73507 + subj = subj->next; \
73508 + }
73509 +
73510 +#endif
73511 +
73512 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73513 new file mode 100644
73514 index 0000000..33ebd1f
73515 --- /dev/null
73516 +++ b/include/linux/gracl_compat.h
73517 @@ -0,0 +1,156 @@
73518 +#ifndef GR_ACL_COMPAT_H
73519 +#define GR_ACL_COMPAT_H
73520 +
73521 +#include <linux/resource.h>
73522 +#include <asm/resource.h>
73523 +
73524 +struct sprole_pw_compat {
73525 + compat_uptr_t rolename;
73526 + unsigned char salt[GR_SALT_LEN];
73527 + unsigned char sum[GR_SHA_LEN];
73528 +};
73529 +
73530 +struct gr_hash_struct_compat {
73531 + compat_uptr_t table;
73532 + compat_uptr_t nametable;
73533 + compat_uptr_t first;
73534 + __u32 table_size;
73535 + __u32 used_size;
73536 + int type;
73537 +};
73538 +
73539 +struct acl_subject_label_compat {
73540 + compat_uptr_t filename;
73541 + compat_ino_t inode;
73542 + __u32 device;
73543 + __u32 mode;
73544 + kernel_cap_t cap_mask;
73545 + kernel_cap_t cap_lower;
73546 + kernel_cap_t cap_invert_audit;
73547 +
73548 + struct compat_rlimit res[GR_NLIMITS];
73549 + __u32 resmask;
73550 +
73551 + __u8 user_trans_type;
73552 + __u8 group_trans_type;
73553 + compat_uptr_t user_transitions;
73554 + compat_uptr_t group_transitions;
73555 + __u16 user_trans_num;
73556 + __u16 group_trans_num;
73557 +
73558 + __u32 sock_families[2];
73559 + __u32 ip_proto[8];
73560 + __u32 ip_type;
73561 + compat_uptr_t ips;
73562 + __u32 ip_num;
73563 + __u32 inaddr_any_override;
73564 +
73565 + __u32 crashes;
73566 + compat_ulong_t expires;
73567 +
73568 + compat_uptr_t parent_subject;
73569 + compat_uptr_t hash;
73570 + compat_uptr_t prev;
73571 + compat_uptr_t next;
73572 +
73573 + compat_uptr_t obj_hash;
73574 + __u32 obj_hash_size;
73575 + __u16 pax_flags;
73576 +};
73577 +
73578 +struct role_allowed_ip_compat {
73579 + __u32 addr;
73580 + __u32 netmask;
73581 +
73582 + compat_uptr_t prev;
73583 + compat_uptr_t next;
73584 +};
73585 +
73586 +struct role_transition_compat {
73587 + compat_uptr_t rolename;
73588 +
73589 + compat_uptr_t prev;
73590 + compat_uptr_t next;
73591 +};
73592 +
73593 +struct acl_role_label_compat {
73594 + compat_uptr_t rolename;
73595 + uid_t uidgid;
73596 + __u16 roletype;
73597 +
73598 + __u16 auth_attempts;
73599 + compat_ulong_t expires;
73600 +
73601 + compat_uptr_t root_label;
73602 + compat_uptr_t hash;
73603 +
73604 + compat_uptr_t prev;
73605 + compat_uptr_t next;
73606 +
73607 + compat_uptr_t transitions;
73608 + compat_uptr_t allowed_ips;
73609 + compat_uptr_t domain_children;
73610 + __u16 domain_child_num;
73611 +
73612 + umode_t umask;
73613 +
73614 + compat_uptr_t subj_hash;
73615 + __u32 subj_hash_size;
73616 +};
73617 +
73618 +struct user_acl_role_db_compat {
73619 + compat_uptr_t r_table;
73620 + __u32 num_pointers;
73621 + __u32 num_roles;
73622 + __u32 num_domain_children;
73623 + __u32 num_subjects;
73624 + __u32 num_objects;
73625 +};
73626 +
73627 +struct acl_object_label_compat {
73628 + compat_uptr_t filename;
73629 + compat_ino_t inode;
73630 + __u32 device;
73631 + __u32 mode;
73632 +
73633 + compat_uptr_t nested;
73634 + compat_uptr_t globbed;
73635 +
73636 + compat_uptr_t prev;
73637 + compat_uptr_t next;
73638 +};
73639 +
73640 +struct acl_ip_label_compat {
73641 + compat_uptr_t iface;
73642 + __u32 addr;
73643 + __u32 netmask;
73644 + __u16 low, high;
73645 + __u8 mode;
73646 + __u32 type;
73647 + __u32 proto[8];
73648 +
73649 + compat_uptr_t prev;
73650 + compat_uptr_t next;
73651 +};
73652 +
73653 +struct gr_arg_compat {
73654 + struct user_acl_role_db_compat role_db;
73655 + unsigned char pw[GR_PW_LEN];
73656 + unsigned char salt[GR_SALT_LEN];
73657 + unsigned char sum[GR_SHA_LEN];
73658 + unsigned char sp_role[GR_SPROLE_LEN];
73659 + compat_uptr_t sprole_pws;
73660 + __u32 segv_device;
73661 + compat_ino_t segv_inode;
73662 + uid_t segv_uid;
73663 + __u16 num_sprole_pws;
73664 + __u16 mode;
73665 +};
73666 +
73667 +struct gr_arg_wrapper_compat {
73668 + compat_uptr_t arg;
73669 + __u32 version;
73670 + __u32 size;
73671 +};
73672 +
73673 +#endif
73674 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73675 new file mode 100644
73676 index 0000000..323ecf2
73677 --- /dev/null
73678 +++ b/include/linux/gralloc.h
73679 @@ -0,0 +1,9 @@
73680 +#ifndef __GRALLOC_H
73681 +#define __GRALLOC_H
73682 +
73683 +void acl_free_all(void);
73684 +int acl_alloc_stack_init(unsigned long size);
73685 +void *acl_alloc(unsigned long len);
73686 +void *acl_alloc_num(unsigned long num, unsigned long len);
73687 +
73688 +#endif
73689 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73690 new file mode 100644
73691 index 0000000..be66033
73692 --- /dev/null
73693 +++ b/include/linux/grdefs.h
73694 @@ -0,0 +1,140 @@
73695 +#ifndef GRDEFS_H
73696 +#define GRDEFS_H
73697 +
73698 +/* Begin grsecurity status declarations */
73699 +
73700 +enum {
73701 + GR_READY = 0x01,
73702 + GR_STATUS_INIT = 0x00 // disabled state
73703 +};
73704 +
73705 +/* Begin ACL declarations */
73706 +
73707 +/* Role flags */
73708 +
73709 +enum {
73710 + GR_ROLE_USER = 0x0001,
73711 + GR_ROLE_GROUP = 0x0002,
73712 + GR_ROLE_DEFAULT = 0x0004,
73713 + GR_ROLE_SPECIAL = 0x0008,
73714 + GR_ROLE_AUTH = 0x0010,
73715 + GR_ROLE_NOPW = 0x0020,
73716 + GR_ROLE_GOD = 0x0040,
73717 + GR_ROLE_LEARN = 0x0080,
73718 + GR_ROLE_TPE = 0x0100,
73719 + GR_ROLE_DOMAIN = 0x0200,
73720 + GR_ROLE_PAM = 0x0400,
73721 + GR_ROLE_PERSIST = 0x0800
73722 +};
73723 +
73724 +/* ACL Subject and Object mode flags */
73725 +enum {
73726 + GR_DELETED = 0x80000000
73727 +};
73728 +
73729 +/* ACL Object-only mode flags */
73730 +enum {
73731 + GR_READ = 0x00000001,
73732 + GR_APPEND = 0x00000002,
73733 + GR_WRITE = 0x00000004,
73734 + GR_EXEC = 0x00000008,
73735 + GR_FIND = 0x00000010,
73736 + GR_INHERIT = 0x00000020,
73737 + GR_SETID = 0x00000040,
73738 + GR_CREATE = 0x00000080,
73739 + GR_DELETE = 0x00000100,
73740 + GR_LINK = 0x00000200,
73741 + GR_AUDIT_READ = 0x00000400,
73742 + GR_AUDIT_APPEND = 0x00000800,
73743 + GR_AUDIT_WRITE = 0x00001000,
73744 + GR_AUDIT_EXEC = 0x00002000,
73745 + GR_AUDIT_FIND = 0x00004000,
73746 + GR_AUDIT_INHERIT= 0x00008000,
73747 + GR_AUDIT_SETID = 0x00010000,
73748 + GR_AUDIT_CREATE = 0x00020000,
73749 + GR_AUDIT_DELETE = 0x00040000,
73750 + GR_AUDIT_LINK = 0x00080000,
73751 + GR_PTRACERD = 0x00100000,
73752 + GR_NOPTRACE = 0x00200000,
73753 + GR_SUPPRESS = 0x00400000,
73754 + GR_NOLEARN = 0x00800000,
73755 + GR_INIT_TRANSFER= 0x01000000
73756 +};
73757 +
73758 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73759 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73760 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73761 +
73762 +/* ACL subject-only mode flags */
73763 +enum {
73764 + GR_KILL = 0x00000001,
73765 + GR_VIEW = 0x00000002,
73766 + GR_PROTECTED = 0x00000004,
73767 + GR_LEARN = 0x00000008,
73768 + GR_OVERRIDE = 0x00000010,
73769 + /* just a placeholder, this mode is only used in userspace */
73770 + GR_DUMMY = 0x00000020,
73771 + GR_PROTSHM = 0x00000040,
73772 + GR_KILLPROC = 0x00000080,
73773 + GR_KILLIPPROC = 0x00000100,
73774 + /* just a placeholder, this mode is only used in userspace */
73775 + GR_NOTROJAN = 0x00000200,
73776 + GR_PROTPROCFD = 0x00000400,
73777 + GR_PROCACCT = 0x00000800,
73778 + GR_RELAXPTRACE = 0x00001000,
73779 + //GR_NESTED = 0x00002000,
73780 + GR_INHERITLEARN = 0x00004000,
73781 + GR_PROCFIND = 0x00008000,
73782 + GR_POVERRIDE = 0x00010000,
73783 + GR_KERNELAUTH = 0x00020000,
73784 + GR_ATSECURE = 0x00040000,
73785 + GR_SHMEXEC = 0x00080000
73786 +};
73787 +
73788 +enum {
73789 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73790 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73791 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73792 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73793 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73794 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73795 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73796 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73797 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73798 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73799 +};
73800 +
73801 +enum {
73802 + GR_ID_USER = 0x01,
73803 + GR_ID_GROUP = 0x02,
73804 +};
73805 +
73806 +enum {
73807 + GR_ID_ALLOW = 0x01,
73808 + GR_ID_DENY = 0x02,
73809 +};
73810 +
73811 +#define GR_CRASH_RES 31
73812 +#define GR_UIDTABLE_MAX 500
73813 +
73814 +/* begin resource learning section */
73815 +enum {
73816 + GR_RLIM_CPU_BUMP = 60,
73817 + GR_RLIM_FSIZE_BUMP = 50000,
73818 + GR_RLIM_DATA_BUMP = 10000,
73819 + GR_RLIM_STACK_BUMP = 1000,
73820 + GR_RLIM_CORE_BUMP = 10000,
73821 + GR_RLIM_RSS_BUMP = 500000,
73822 + GR_RLIM_NPROC_BUMP = 1,
73823 + GR_RLIM_NOFILE_BUMP = 5,
73824 + GR_RLIM_MEMLOCK_BUMP = 50000,
73825 + GR_RLIM_AS_BUMP = 500000,
73826 + GR_RLIM_LOCKS_BUMP = 2,
73827 + GR_RLIM_SIGPENDING_BUMP = 5,
73828 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73829 + GR_RLIM_NICE_BUMP = 1,
73830 + GR_RLIM_RTPRIO_BUMP = 1,
73831 + GR_RLIM_RTTIME_BUMP = 1000000
73832 +};
73833 +
73834 +#endif
73835 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73836 new file mode 100644
73837 index 0000000..e337683
73838 --- /dev/null
73839 +++ b/include/linux/grinternal.h
73840 @@ -0,0 +1,229 @@
73841 +#ifndef __GRINTERNAL_H
73842 +#define __GRINTERNAL_H
73843 +
73844 +#ifdef CONFIG_GRKERNSEC
73845 +
73846 +#include <linux/fs.h>
73847 +#include <linux/mnt_namespace.h>
73848 +#include <linux/nsproxy.h>
73849 +#include <linux/gracl.h>
73850 +#include <linux/grdefs.h>
73851 +#include <linux/grmsg.h>
73852 +
73853 +void gr_add_learn_entry(const char *fmt, ...)
73854 + __attribute__ ((format (printf, 1, 2)));
73855 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73856 + const struct vfsmount *mnt);
73857 +__u32 gr_check_create(const struct dentry *new_dentry,
73858 + const struct dentry *parent,
73859 + const struct vfsmount *mnt, const __u32 mode);
73860 +int gr_check_protected_task(const struct task_struct *task);
73861 +__u32 to_gr_audit(const __u32 reqmode);
73862 +int gr_set_acls(const int type);
73863 +int gr_apply_subject_to_task(struct task_struct *task);
73864 +int gr_acl_is_enabled(void);
73865 +char gr_roletype_to_char(void);
73866 +
73867 +void gr_handle_alertkill(struct task_struct *task);
73868 +char *gr_to_filename(const struct dentry *dentry,
73869 + const struct vfsmount *mnt);
73870 +char *gr_to_filename1(const struct dentry *dentry,
73871 + const struct vfsmount *mnt);
73872 +char *gr_to_filename2(const struct dentry *dentry,
73873 + const struct vfsmount *mnt);
73874 +char *gr_to_filename3(const struct dentry *dentry,
73875 + const struct vfsmount *mnt);
73876 +
73877 +extern int grsec_enable_ptrace_readexec;
73878 +extern int grsec_enable_harden_ptrace;
73879 +extern int grsec_enable_link;
73880 +extern int grsec_enable_fifo;
73881 +extern int grsec_enable_execve;
73882 +extern int grsec_enable_shm;
73883 +extern int grsec_enable_execlog;
73884 +extern int grsec_enable_signal;
73885 +extern int grsec_enable_audit_ptrace;
73886 +extern int grsec_enable_forkfail;
73887 +extern int grsec_enable_time;
73888 +extern int grsec_enable_rofs;
73889 +extern int grsec_deny_new_usb;
73890 +extern int grsec_enable_chroot_shmat;
73891 +extern int grsec_enable_chroot_mount;
73892 +extern int grsec_enable_chroot_double;
73893 +extern int grsec_enable_chroot_pivot;
73894 +extern int grsec_enable_chroot_chdir;
73895 +extern int grsec_enable_chroot_chmod;
73896 +extern int grsec_enable_chroot_mknod;
73897 +extern int grsec_enable_chroot_fchdir;
73898 +extern int grsec_enable_chroot_nice;
73899 +extern int grsec_enable_chroot_execlog;
73900 +extern int grsec_enable_chroot_caps;
73901 +extern int grsec_enable_chroot_sysctl;
73902 +extern int grsec_enable_chroot_unix;
73903 +extern int grsec_enable_symlinkown;
73904 +extern kgid_t grsec_symlinkown_gid;
73905 +extern int grsec_enable_tpe;
73906 +extern kgid_t grsec_tpe_gid;
73907 +extern int grsec_enable_tpe_all;
73908 +extern int grsec_enable_tpe_invert;
73909 +extern int grsec_enable_socket_all;
73910 +extern kgid_t grsec_socket_all_gid;
73911 +extern int grsec_enable_socket_client;
73912 +extern kgid_t grsec_socket_client_gid;
73913 +extern int grsec_enable_socket_server;
73914 +extern kgid_t grsec_socket_server_gid;
73915 +extern kgid_t grsec_audit_gid;
73916 +extern int grsec_enable_group;
73917 +extern int grsec_enable_log_rwxmaps;
73918 +extern int grsec_enable_mount;
73919 +extern int grsec_enable_chdir;
73920 +extern int grsec_resource_logging;
73921 +extern int grsec_enable_blackhole;
73922 +extern int grsec_lastack_retries;
73923 +extern int grsec_enable_brute;
73924 +extern int grsec_lock;
73925 +
73926 +extern spinlock_t grsec_alert_lock;
73927 +extern unsigned long grsec_alert_wtime;
73928 +extern unsigned long grsec_alert_fyet;
73929 +
73930 +extern spinlock_t grsec_audit_lock;
73931 +
73932 +extern rwlock_t grsec_exec_file_lock;
73933 +
73934 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73935 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73936 + (tsk)->exec_file->f_path.mnt) : "/")
73937 +
73938 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73939 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73940 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73941 +
73942 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73943 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73944 + (tsk)->exec_file->f_path.mnt) : "/")
73945 +
73946 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
73947 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
73948 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73949 +
73950 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
73951 +
73952 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
73953 +
73954 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
73955 +{
73956 + if (file1 && file2) {
73957 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
73958 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
73959 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
73960 + return true;
73961 + }
73962 +
73963 + return false;
73964 +}
73965 +
73966 +#define GR_CHROOT_CAPS {{ \
73967 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
73968 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
73969 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
73970 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
73971 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
73972 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
73973 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
73974 +
73975 +#define security_learn(normal_msg,args...) \
73976 +({ \
73977 + read_lock(&grsec_exec_file_lock); \
73978 + gr_add_learn_entry(normal_msg "\n", ## args); \
73979 + read_unlock(&grsec_exec_file_lock); \
73980 +})
73981 +
73982 +enum {
73983 + GR_DO_AUDIT,
73984 + GR_DONT_AUDIT,
73985 + /* used for non-audit messages that we shouldn't kill the task on */
73986 + GR_DONT_AUDIT_GOOD
73987 +};
73988 +
73989 +enum {
73990 + GR_TTYSNIFF,
73991 + GR_RBAC,
73992 + GR_RBAC_STR,
73993 + GR_STR_RBAC,
73994 + GR_RBAC_MODE2,
73995 + GR_RBAC_MODE3,
73996 + GR_FILENAME,
73997 + GR_SYSCTL_HIDDEN,
73998 + GR_NOARGS,
73999 + GR_ONE_INT,
74000 + GR_ONE_INT_TWO_STR,
74001 + GR_ONE_STR,
74002 + GR_STR_INT,
74003 + GR_TWO_STR_INT,
74004 + GR_TWO_INT,
74005 + GR_TWO_U64,
74006 + GR_THREE_INT,
74007 + GR_FIVE_INT_TWO_STR,
74008 + GR_TWO_STR,
74009 + GR_THREE_STR,
74010 + GR_FOUR_STR,
74011 + GR_STR_FILENAME,
74012 + GR_FILENAME_STR,
74013 + GR_FILENAME_TWO_INT,
74014 + GR_FILENAME_TWO_INT_STR,
74015 + GR_TEXTREL,
74016 + GR_PTRACE,
74017 + GR_RESOURCE,
74018 + GR_CAP,
74019 + GR_SIG,
74020 + GR_SIG2,
74021 + GR_CRASH1,
74022 + GR_CRASH2,
74023 + GR_PSACCT,
74024 + GR_RWXMAP,
74025 + GR_RWXMAPVMA
74026 +};
74027 +
74028 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74029 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74030 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74031 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74032 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74033 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74034 +#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)
74035 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74036 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74037 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74038 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74039 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74040 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74041 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74042 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74043 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74044 +#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)
74045 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74046 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74047 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74048 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74049 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74050 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74051 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74052 +#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)
74053 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74054 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74055 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74056 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74057 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74058 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74059 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74060 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74061 +#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)
74062 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74063 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74064 +
74065 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74066 +
74067 +#endif
74068 +
74069 +#endif
74070 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74071 new file mode 100644
74072 index 0000000..a4396b5
74073 --- /dev/null
74074 +++ b/include/linux/grmsg.h
74075 @@ -0,0 +1,113 @@
74076 +#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"
74077 +#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"
74078 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74079 +#define GR_STOPMOD_MSG "denied modification of module state by "
74080 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74081 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74082 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74083 +#define GR_IOPL_MSG "denied use of iopl() by "
74084 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74085 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74086 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74087 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74088 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74089 +#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"
74090 +#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"
74091 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74092 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74093 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74094 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74095 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74096 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74097 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74098 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74099 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74100 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74101 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74102 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74103 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74104 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74105 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74106 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74107 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74108 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74109 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74110 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74111 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74112 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74113 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74114 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74115 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74116 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74117 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74118 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74119 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74120 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74121 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74122 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74123 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74124 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74125 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74126 +#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"
74127 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74128 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74129 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74130 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74131 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74132 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74133 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74134 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74135 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74136 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74137 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74138 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74139 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74140 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74141 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74142 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74143 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74144 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74145 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74146 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74147 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74148 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74149 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74150 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74151 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74152 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74153 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74154 +#define GR_TIME_MSG "time set by "
74155 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74156 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74157 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74158 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74159 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74160 +#define GR_BIND_MSG "denied bind() by "
74161 +#define GR_CONNECT_MSG "denied connect() by "
74162 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74163 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74164 +#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"
74165 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74166 +#define GR_CAP_ACL_MSG "use of %s denied for "
74167 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74168 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74169 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74170 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74171 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74172 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74173 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74174 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74175 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74176 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74177 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74178 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74179 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74180 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74181 +#define GR_VM86_MSG "denied use of vm86 by "
74182 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74183 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74184 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74185 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74186 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74187 +#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 "
74188 +#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 "
74189 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74190 new file mode 100644
74191 index 0000000..d6f5a21
74192 --- /dev/null
74193 +++ b/include/linux/grsecurity.h
74194 @@ -0,0 +1,244 @@
74195 +#ifndef GR_SECURITY_H
74196 +#define GR_SECURITY_H
74197 +#include <linux/fs.h>
74198 +#include <linux/fs_struct.h>
74199 +#include <linux/binfmts.h>
74200 +#include <linux/gracl.h>
74201 +
74202 +/* notify of brain-dead configs */
74203 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74204 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74205 +#endif
74206 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74207 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74208 +#endif
74209 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74210 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74211 +#endif
74212 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74213 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74214 +#endif
74215 +
74216 +int gr_handle_new_usb(void);
74217 +
74218 +void gr_handle_brute_attach(unsigned long mm_flags);
74219 +void gr_handle_brute_check(void);
74220 +void gr_handle_kernel_exploit(void);
74221 +
74222 +char gr_roletype_to_char(void);
74223 +
74224 +int gr_acl_enable_at_secure(void);
74225 +
74226 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74227 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74228 +
74229 +void gr_del_task_from_ip_table(struct task_struct *p);
74230 +
74231 +int gr_pid_is_chrooted(struct task_struct *p);
74232 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74233 +int gr_handle_chroot_nice(void);
74234 +int gr_handle_chroot_sysctl(const int op);
74235 +int gr_handle_chroot_setpriority(struct task_struct *p,
74236 + const int niceval);
74237 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74238 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74239 + const struct vfsmount *mnt);
74240 +void gr_handle_chroot_chdir(const struct path *path);
74241 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74242 + const struct vfsmount *mnt, const int mode);
74243 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74244 + const struct vfsmount *mnt, const int mode);
74245 +int gr_handle_chroot_mount(const struct dentry *dentry,
74246 + const struct vfsmount *mnt,
74247 + const char *dev_name);
74248 +int gr_handle_chroot_pivot(void);
74249 +int gr_handle_chroot_unix(const pid_t pid);
74250 +
74251 +int gr_handle_rawio(const struct inode *inode);
74252 +
74253 +void gr_handle_ioperm(void);
74254 +void gr_handle_iopl(void);
74255 +
74256 +umode_t gr_acl_umask(void);
74257 +
74258 +int gr_tpe_allow(const struct file *file);
74259 +
74260 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74261 +void gr_clear_chroot_entries(struct task_struct *task);
74262 +
74263 +void gr_log_forkfail(const int retval);
74264 +void gr_log_timechange(void);
74265 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74266 +void gr_log_chdir(const struct dentry *dentry,
74267 + const struct vfsmount *mnt);
74268 +void gr_log_chroot_exec(const struct dentry *dentry,
74269 + const struct vfsmount *mnt);
74270 +void gr_log_remount(const char *devname, const int retval);
74271 +void gr_log_unmount(const char *devname, const int retval);
74272 +void gr_log_mount(const char *from, const char *to, const int retval);
74273 +void gr_log_textrel(struct vm_area_struct *vma);
74274 +void gr_log_ptgnustack(struct file *file);
74275 +void gr_log_rwxmmap(struct file *file);
74276 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74277 +
74278 +int gr_handle_follow_link(const struct inode *parent,
74279 + const struct inode *inode,
74280 + const struct dentry *dentry,
74281 + const struct vfsmount *mnt);
74282 +int gr_handle_fifo(const struct dentry *dentry,
74283 + const struct vfsmount *mnt,
74284 + const struct dentry *dir, const int flag,
74285 + const int acc_mode);
74286 +int gr_handle_hardlink(const struct dentry *dentry,
74287 + const struct vfsmount *mnt,
74288 + struct inode *inode,
74289 + const int mode, const struct filename *to);
74290 +
74291 +int gr_is_capable(const int cap);
74292 +int gr_is_capable_nolog(const int cap);
74293 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74294 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74295 +
74296 +void gr_copy_label(struct task_struct *tsk);
74297 +void gr_handle_crash(struct task_struct *task, const int sig);
74298 +int gr_handle_signal(const struct task_struct *p, const int sig);
74299 +int gr_check_crash_uid(const kuid_t uid);
74300 +int gr_check_protected_task(const struct task_struct *task);
74301 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74302 +int gr_acl_handle_mmap(const struct file *file,
74303 + const unsigned long prot);
74304 +int gr_acl_handle_mprotect(const struct file *file,
74305 + const unsigned long prot);
74306 +int gr_check_hidden_task(const struct task_struct *tsk);
74307 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74308 + const struct vfsmount *mnt);
74309 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74310 + const struct vfsmount *mnt);
74311 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74312 + const struct vfsmount *mnt, const int fmode);
74313 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74314 + const struct vfsmount *mnt, umode_t *mode);
74315 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74316 + const struct vfsmount *mnt);
74317 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74318 + const struct vfsmount *mnt);
74319 +int gr_handle_ptrace(struct task_struct *task, const long request);
74320 +int gr_handle_proc_ptrace(struct task_struct *task);
74321 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74322 + const struct vfsmount *mnt);
74323 +int gr_check_crash_exec(const struct file *filp);
74324 +int gr_acl_is_enabled(void);
74325 +void gr_set_kernel_label(struct task_struct *task);
74326 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74327 + const kgid_t gid);
74328 +int gr_set_proc_label(const struct dentry *dentry,
74329 + const struct vfsmount *mnt,
74330 + const int unsafe_flags);
74331 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74332 + const struct vfsmount *mnt);
74333 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74334 + const struct vfsmount *mnt, int acc_mode);
74335 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74336 + const struct dentry *p_dentry,
74337 + const struct vfsmount *p_mnt,
74338 + int open_flags, int acc_mode, const int imode);
74339 +void gr_handle_create(const struct dentry *dentry,
74340 + const struct vfsmount *mnt);
74341 +void gr_handle_proc_create(const struct dentry *dentry,
74342 + const struct inode *inode);
74343 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74344 + const struct dentry *parent_dentry,
74345 + const struct vfsmount *parent_mnt,
74346 + const int mode);
74347 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74348 + const struct dentry *parent_dentry,
74349 + const struct vfsmount *parent_mnt);
74350 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74351 + const struct vfsmount *mnt);
74352 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74353 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74354 + const struct vfsmount *mnt);
74355 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74356 + const struct dentry *parent_dentry,
74357 + const struct vfsmount *parent_mnt,
74358 + const struct filename *from);
74359 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74360 + const struct dentry *parent_dentry,
74361 + const struct vfsmount *parent_mnt,
74362 + const struct dentry *old_dentry,
74363 + const struct vfsmount *old_mnt, const struct filename *to);
74364 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74365 +int gr_acl_handle_rename(struct dentry *new_dentry,
74366 + struct dentry *parent_dentry,
74367 + const struct vfsmount *parent_mnt,
74368 + struct dentry *old_dentry,
74369 + struct inode *old_parent_inode,
74370 + struct vfsmount *old_mnt, const struct filename *newname);
74371 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74372 + struct dentry *old_dentry,
74373 + struct dentry *new_dentry,
74374 + struct vfsmount *mnt, const __u8 replace);
74375 +__u32 gr_check_link(const struct dentry *new_dentry,
74376 + const struct dentry *parent_dentry,
74377 + const struct vfsmount *parent_mnt,
74378 + const struct dentry *old_dentry,
74379 + const struct vfsmount *old_mnt);
74380 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74381 + const unsigned int namelen, const ino_t ino);
74382 +
74383 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74384 + const struct vfsmount *mnt);
74385 +void gr_acl_handle_exit(void);
74386 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74387 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74388 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74389 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74390 +void gr_audit_ptrace(struct task_struct *task);
74391 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74392 +void gr_put_exec_file(struct task_struct *task);
74393 +
74394 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74395 +
74396 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74397 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74398 + const unsigned long wanted, const int gt);
74399 +#else
74400 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74401 + const unsigned long wanted, const int gt)
74402 +{
74403 +}
74404 +#endif
74405 +
74406 +#ifdef CONFIG_GRKERNSEC_RESLOG
74407 +extern void gr_log_resource(const struct task_struct *task, const int res,
74408 + const unsigned long wanted, const int gt);
74409 +#else
74410 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74411 + const unsigned long wanted, const int gt)
74412 +{
74413 +}
74414 +#endif
74415 +
74416 +#ifdef CONFIG_GRKERNSEC
74417 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74418 +void gr_handle_vm86(void);
74419 +void gr_handle_mem_readwrite(u64 from, u64 to);
74420 +
74421 +void gr_log_badprocpid(const char *entry);
74422 +
74423 +extern int grsec_enable_dmesg;
74424 +extern int grsec_disable_privio;
74425 +
74426 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74427 +extern kgid_t grsec_proc_gid;
74428 +#endif
74429 +
74430 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74431 +extern int grsec_enable_chroot_findtask;
74432 +#endif
74433 +#ifdef CONFIG_GRKERNSEC_SETXID
74434 +extern int grsec_enable_setxid;
74435 +#endif
74436 +#endif
74437 +
74438 +#endif
74439 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74440 new file mode 100644
74441 index 0000000..e7ffaaf
74442 --- /dev/null
74443 +++ b/include/linux/grsock.h
74444 @@ -0,0 +1,19 @@
74445 +#ifndef __GRSOCK_H
74446 +#define __GRSOCK_H
74447 +
74448 +extern void gr_attach_curr_ip(const struct sock *sk);
74449 +extern int gr_handle_sock_all(const int family, const int type,
74450 + const int protocol);
74451 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74452 +extern int gr_handle_sock_server_other(const struct sock *sck);
74453 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74454 +extern int gr_search_connect(struct socket * sock,
74455 + struct sockaddr_in * addr);
74456 +extern int gr_search_bind(struct socket * sock,
74457 + struct sockaddr_in * addr);
74458 +extern int gr_search_listen(struct socket * sock);
74459 +extern int gr_search_accept(struct socket * sock);
74460 +extern int gr_search_socket(const int domain, const int type,
74461 + const int protocol);
74462 +
74463 +#endif
74464 diff --git a/include/linux/hid.h b/include/linux/hid.h
74465 index ff545cc..76e41d8 100644
74466 --- a/include/linux/hid.h
74467 +++ b/include/linux/hid.h
74468 @@ -749,6 +749,10 @@ void hid_output_report(struct hid_report *report, __u8 *data);
74469 struct hid_device *hid_allocate_device(void);
74470 struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
74471 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
74472 +struct hid_report *hid_validate_report(struct hid_device *hid,
74473 + unsigned int type, unsigned int id,
74474 + unsigned int fields,
74475 + unsigned int report_counts);
74476 int hid_open_report(struct hid_device *device);
74477 int hid_check_keys_pressed(struct hid_device *hid);
74478 int hid_connect(struct hid_device *hid, unsigned int connect_mask);
74479 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74480 index 7fb31da..08b5114 100644
74481 --- a/include/linux/highmem.h
74482 +++ b/include/linux/highmem.h
74483 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74484 kunmap_atomic(kaddr);
74485 }
74486
74487 +static inline void sanitize_highpage(struct page *page)
74488 +{
74489 + void *kaddr;
74490 + unsigned long flags;
74491 +
74492 + local_irq_save(flags);
74493 + kaddr = kmap_atomic(page);
74494 + clear_page(kaddr);
74495 + kunmap_atomic(kaddr);
74496 + local_irq_restore(flags);
74497 +}
74498 +
74499 static inline void zero_user_segments(struct page *page,
74500 unsigned start1, unsigned end1,
74501 unsigned start2, unsigned end2)
74502 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74503 index 1c7b89a..7f52502 100644
74504 --- a/include/linux/hwmon-sysfs.h
74505 +++ b/include/linux/hwmon-sysfs.h
74506 @@ -25,7 +25,8 @@
74507 struct sensor_device_attribute{
74508 struct device_attribute dev_attr;
74509 int index;
74510 -};
74511 +} __do_const;
74512 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74513 #define to_sensor_dev_attr(_dev_attr) \
74514 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74515
74516 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74517 struct device_attribute dev_attr;
74518 u8 index;
74519 u8 nr;
74520 -};
74521 +} __do_const;
74522 #define to_sensor_dev_attr_2(_dev_attr) \
74523 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74524
74525 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74526 index e988fa9..ff9f17e 100644
74527 --- a/include/linux/i2c.h
74528 +++ b/include/linux/i2c.h
74529 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74530 /* To determine what the adapter supports */
74531 u32 (*functionality) (struct i2c_adapter *);
74532 };
74533 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74534
74535 /**
74536 * struct i2c_bus_recovery_info - I2C bus recovery information
74537 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74538 index d23c3c2..eb63c81 100644
74539 --- a/include/linux/i2o.h
74540 +++ b/include/linux/i2o.h
74541 @@ -565,7 +565,7 @@ struct i2o_controller {
74542 struct i2o_device *exec; /* Executive */
74543 #if BITS_PER_LONG == 64
74544 spinlock_t context_list_lock; /* lock for context_list */
74545 - atomic_t context_list_counter; /* needed for unique contexts */
74546 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74547 struct list_head context_list; /* list of context id's
74548 and pointers */
74549 #endif
74550 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74551 index aff7ad8..3942bbd 100644
74552 --- a/include/linux/if_pppox.h
74553 +++ b/include/linux/if_pppox.h
74554 @@ -76,7 +76,7 @@ struct pppox_proto {
74555 int (*ioctl)(struct socket *sock, unsigned int cmd,
74556 unsigned long arg);
74557 struct module *owner;
74558 -};
74559 +} __do_const;
74560
74561 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74562 extern void unregister_pppox_proto(int proto_num);
74563 diff --git a/include/linux/init.h b/include/linux/init.h
74564 index e73f2b7..cc996e0 100644
74565 --- a/include/linux/init.h
74566 +++ b/include/linux/init.h
74567 @@ -39,9 +39,17 @@
74568 * Also note, that this data cannot be "const".
74569 */
74570
74571 +#define add_init_latent_entropy __latent_entropy
74572 +
74573 +#ifdef CONFIG_MEMORY_HOTPLUG
74574 +#define add_meminit_latent_entropy
74575 +#else
74576 +#define add_meminit_latent_entropy __latent_entropy
74577 +#endif
74578 +
74579 /* These are for everybody (although not all archs will actually
74580 discard it in modules) */
74581 -#define __init __section(.init.text) __cold notrace
74582 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74583 #define __initdata __section(.init.data)
74584 #define __initconst __constsection(.init.rodata)
74585 #define __exitdata __section(.exit.data)
74586 @@ -102,7 +110,7 @@
74587 #define __cpuexitconst
74588
74589 /* Used for MEMORY_HOTPLUG */
74590 -#define __meminit __section(.meminit.text) __cold notrace
74591 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74592 #define __meminitdata __section(.meminit.data)
74593 #define __meminitconst __constsection(.meminit.rodata)
74594 #define __memexit __section(.memexit.text) __exitused __cold notrace
74595 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74596 index 5cd0f09..c9f67cc 100644
74597 --- a/include/linux/init_task.h
74598 +++ b/include/linux/init_task.h
74599 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74600
74601 #define INIT_TASK_COMM "swapper"
74602
74603 +#ifdef CONFIG_X86
74604 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74605 +#else
74606 +#define INIT_TASK_THREAD_INFO
74607 +#endif
74608 +
74609 /*
74610 * INIT_TASK is used to set up the first task table, touch at
74611 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74612 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74613 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74614 .comm = INIT_TASK_COMM, \
74615 .thread = INIT_THREAD, \
74616 + INIT_TASK_THREAD_INFO \
74617 .fs = &init_fs, \
74618 .files = &init_files, \
74619 .signal = &init_signals, \
74620 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74621 index 5fa5afe..ac55b25 100644
74622 --- a/include/linux/interrupt.h
74623 +++ b/include/linux/interrupt.h
74624 @@ -430,7 +430,7 @@ enum
74625 /* map softirq index to softirq name. update 'softirq_to_name' in
74626 * kernel/softirq.c when adding a new softirq.
74627 */
74628 -extern char *softirq_to_name[NR_SOFTIRQS];
74629 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74630
74631 /* softirq mask and active fields moved to irq_cpustat_t in
74632 * asm/hardirq.h to get better cache usage. KAO
74633 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74634
74635 struct softirq_action
74636 {
74637 - void (*action)(struct softirq_action *);
74638 -};
74639 + void (*action)(void);
74640 +} __no_const;
74641
74642 asmlinkage void do_softirq(void);
74643 asmlinkage void __do_softirq(void);
74644 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74645 +extern void open_softirq(int nr, void (*action)(void));
74646 extern void softirq_init(void);
74647 extern void __raise_softirq_irqoff(unsigned int nr);
74648
74649 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74650 index 3aeb730..2177f39 100644
74651 --- a/include/linux/iommu.h
74652 +++ b/include/linux/iommu.h
74653 @@ -113,7 +113,7 @@ struct iommu_ops {
74654 u32 (*domain_get_windows)(struct iommu_domain *domain);
74655
74656 unsigned long pgsize_bitmap;
74657 -};
74658 +} __do_const;
74659
74660 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74661 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74662 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74663 index 89b7c24..382af74 100644
74664 --- a/include/linux/ioport.h
74665 +++ b/include/linux/ioport.h
74666 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74667 int adjust_resource(struct resource *res, resource_size_t start,
74668 resource_size_t size);
74669 resource_size_t resource_alignment(struct resource *res);
74670 -static inline resource_size_t resource_size(const struct resource *res)
74671 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74672 {
74673 return res->end - res->start + 1;
74674 }
74675 diff --git a/include/linux/irq.h b/include/linux/irq.h
74676 index f04d3ba..bcf2cfb 100644
74677 --- a/include/linux/irq.h
74678 +++ b/include/linux/irq.h
74679 @@ -333,7 +333,8 @@ struct irq_chip {
74680 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74681
74682 unsigned long flags;
74683 -};
74684 +} __do_const;
74685 +typedef struct irq_chip __no_const irq_chip_no_const;
74686
74687 /*
74688 * irq_chip specific flags
74689 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74690 index 3e203eb..3fe68d0 100644
74691 --- a/include/linux/irqchip/arm-gic.h
74692 +++ b/include/linux/irqchip/arm-gic.h
74693 @@ -59,9 +59,11 @@
74694
74695 #ifndef __ASSEMBLY__
74696
74697 +#include <linux/irq.h>
74698 +
74699 struct device_node;
74700
74701 -extern struct irq_chip gic_arch_extn;
74702 +extern irq_chip_no_const gic_arch_extn;
74703
74704 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74705 u32 offset, struct device_node *);
74706 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74707 index 6883e19..e854fcb 100644
74708 --- a/include/linux/kallsyms.h
74709 +++ b/include/linux/kallsyms.h
74710 @@ -15,7 +15,8 @@
74711
74712 struct module;
74713
74714 -#ifdef CONFIG_KALLSYMS
74715 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74716 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74717 /* Lookup the address for a symbol. Returns 0 if not found. */
74718 unsigned long kallsyms_lookup_name(const char *name);
74719
74720 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74721 /* Stupid that this does nothing, but I didn't create this mess. */
74722 #define __print_symbol(fmt, addr)
74723 #endif /*CONFIG_KALLSYMS*/
74724 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74725 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74726 +extern unsigned long kallsyms_lookup_name(const char *name);
74727 +extern void __print_symbol(const char *fmt, unsigned long address);
74728 +extern int sprint_backtrace(char *buffer, unsigned long address);
74729 +extern int sprint_symbol(char *buffer, unsigned long address);
74730 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74731 +const char *kallsyms_lookup(unsigned long addr,
74732 + unsigned long *symbolsize,
74733 + unsigned long *offset,
74734 + char **modname, char *namebuf);
74735 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74736 + unsigned long *symbolsize,
74737 + unsigned long *offset);
74738 +#endif
74739
74740 /* This macro allows us to keep printk typechecking */
74741 static __printf(1, 2)
74742 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74743 index 518a53a..5e28358 100644
74744 --- a/include/linux/key-type.h
74745 +++ b/include/linux/key-type.h
74746 @@ -125,7 +125,7 @@ struct key_type {
74747 /* internal fields */
74748 struct list_head link; /* link in types list */
74749 struct lock_class_key lock_class; /* key->sem lock class */
74750 -};
74751 +} __do_const;
74752
74753 extern struct key_type key_type_keyring;
74754
74755 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74756 index c6e091b..a940adf 100644
74757 --- a/include/linux/kgdb.h
74758 +++ b/include/linux/kgdb.h
74759 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74760 extern int kgdb_io_module_registered;
74761
74762 extern atomic_t kgdb_setting_breakpoint;
74763 -extern atomic_t kgdb_cpu_doing_single_step;
74764 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74765
74766 extern struct task_struct *kgdb_usethread;
74767 extern struct task_struct *kgdb_contthread;
74768 @@ -254,7 +254,7 @@ struct kgdb_arch {
74769 void (*correct_hw_break)(void);
74770
74771 void (*enable_nmi)(bool on);
74772 -};
74773 +} __do_const;
74774
74775 /**
74776 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74777 @@ -279,7 +279,7 @@ struct kgdb_io {
74778 void (*pre_exception) (void);
74779 void (*post_exception) (void);
74780 int is_console;
74781 -};
74782 +} __do_const;
74783
74784 extern struct kgdb_arch arch_kgdb_ops;
74785
74786 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74787 index 0555cc6..b16a7a4 100644
74788 --- a/include/linux/kmod.h
74789 +++ b/include/linux/kmod.h
74790 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74791 * usually useless though. */
74792 extern __printf(2, 3)
74793 int __request_module(bool wait, const char *name, ...);
74794 +extern __printf(3, 4)
74795 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74796 #define request_module(mod...) __request_module(true, mod)
74797 #define request_module_nowait(mod...) __request_module(false, mod)
74798 #define try_then_request_module(x, mod...) \
74799 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74800 index 939b112..ed6ed51 100644
74801 --- a/include/linux/kobject.h
74802 +++ b/include/linux/kobject.h
74803 @@ -111,7 +111,7 @@ struct kobj_type {
74804 struct attribute **default_attrs;
74805 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74806 const void *(*namespace)(struct kobject *kobj);
74807 -};
74808 +} __do_const;
74809
74810 struct kobj_uevent_env {
74811 char *envp[UEVENT_NUM_ENVP];
74812 @@ -134,6 +134,7 @@ struct kobj_attribute {
74813 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74814 const char *buf, size_t count);
74815 };
74816 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74817
74818 extern const struct sysfs_ops kobj_sysfs_ops;
74819
74820 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74821 index f66b065..c2c29b4 100644
74822 --- a/include/linux/kobject_ns.h
74823 +++ b/include/linux/kobject_ns.h
74824 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74825 const void *(*netlink_ns)(struct sock *sk);
74826 const void *(*initial_ns)(void);
74827 void (*drop_ns)(void *);
74828 -};
74829 +} __do_const;
74830
74831 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74832 int kobj_ns_type_registered(enum kobj_ns_type type);
74833 diff --git a/include/linux/kref.h b/include/linux/kref.h
74834 index 484604d..0f6c5b6 100644
74835 --- a/include/linux/kref.h
74836 +++ b/include/linux/kref.h
74837 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74838 static inline int kref_sub(struct kref *kref, unsigned int count,
74839 void (*release)(struct kref *kref))
74840 {
74841 - WARN_ON(release == NULL);
74842 + BUG_ON(release == NULL);
74843
74844 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74845 release(kref);
74846 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74847 index a63d83e..77fd685 100644
74848 --- a/include/linux/kvm_host.h
74849 +++ b/include/linux/kvm_host.h
74850 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74851 {
74852 }
74853 #endif
74854 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74855 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74856 struct module *module);
74857 void kvm_exit(void);
74858
74859 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74860 struct kvm_guest_debug *dbg);
74861 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74862
74863 -int kvm_arch_init(void *opaque);
74864 +int kvm_arch_init(const void *opaque);
74865 void kvm_arch_exit(void);
74866
74867 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74868 diff --git a/include/linux/libata.h b/include/linux/libata.h
74869 index 4ea55bb..dcd2601 100644
74870 --- a/include/linux/libata.h
74871 +++ b/include/linux/libata.h
74872 @@ -924,7 +924,7 @@ struct ata_port_operations {
74873 * fields must be pointers.
74874 */
74875 const struct ata_port_operations *inherits;
74876 -};
74877 +} __do_const;
74878
74879 struct ata_port_info {
74880 unsigned long flags;
74881 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74882 index d3e8ad2..a949f68 100644
74883 --- a/include/linux/linkage.h
74884 +++ b/include/linux/linkage.h
74885 @@ -31,6 +31,7 @@
74886 #endif
74887
74888 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74889 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74890 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74891
74892 /*
74893 diff --git a/include/linux/list.h b/include/linux/list.h
74894 index f4d8a2f..38e6e46 100644
74895 --- a/include/linux/list.h
74896 +++ b/include/linux/list.h
74897 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74898 extern void list_del(struct list_head *entry);
74899 #endif
74900
74901 +extern void __pax_list_add(struct list_head *new,
74902 + struct list_head *prev,
74903 + struct list_head *next);
74904 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74905 +{
74906 + __pax_list_add(new, head, head->next);
74907 +}
74908 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74909 +{
74910 + __pax_list_add(new, head->prev, head);
74911 +}
74912 +extern void pax_list_del(struct list_head *entry);
74913 +
74914 /**
74915 * list_replace - replace old entry by new one
74916 * @old : the element to be replaced
74917 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74918 INIT_LIST_HEAD(entry);
74919 }
74920
74921 +extern void pax_list_del_init(struct list_head *entry);
74922 +
74923 /**
74924 * list_move - delete from one list and add as another's head
74925 * @list: the entry to move
74926 diff --git a/include/linux/math64.h b/include/linux/math64.h
74927 index 2913b86..8dcbb1e 100644
74928 --- a/include/linux/math64.h
74929 +++ b/include/linux/math64.h
74930 @@ -15,7 +15,7 @@
74931 * This is commonly provided by 32bit archs to provide an optimized 64bit
74932 * divide.
74933 */
74934 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74935 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74936 {
74937 *remainder = dividend % divisor;
74938 return dividend / divisor;
74939 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74940 /**
74941 * div64_u64 - unsigned 64bit divide with 64bit divisor
74942 */
74943 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74944 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74945 {
74946 return dividend / divisor;
74947 }
74948 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74949 #define div64_ul(x, y) div_u64((x), (y))
74950
74951 #ifndef div_u64_rem
74952 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74953 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74954 {
74955 *remainder = do_div(dividend, divisor);
74956 return dividend;
74957 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
74958 * divide.
74959 */
74960 #ifndef div_u64
74961 -static inline u64 div_u64(u64 dividend, u32 divisor)
74962 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
74963 {
74964 u32 remainder;
74965 return div_u64_rem(dividend, divisor, &remainder);
74966 diff --git a/include/linux/mm.h b/include/linux/mm.h
74967 index f022460..6ecf4f9 100644
74968 --- a/include/linux/mm.h
74969 +++ b/include/linux/mm.h
74970 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
74971 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
74972 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
74973 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
74974 +
74975 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
74976 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
74977 +#endif
74978 +
74979 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
74980
74981 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
74982 @@ -208,8 +213,8 @@ struct vm_operations_struct {
74983 /* called by access_process_vm when get_user_pages() fails, typically
74984 * for use by special VMAs that can switch between memory and hardware
74985 */
74986 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
74987 - void *buf, int len, int write);
74988 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
74989 + void *buf, size_t len, int write);
74990 #ifdef CONFIG_NUMA
74991 /*
74992 * set_policy() op must add a reference to any non-NULL @new mempolicy
74993 @@ -239,6 +244,7 @@ struct vm_operations_struct {
74994 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
74995 unsigned long size, pgoff_t pgoff);
74996 };
74997 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
74998
74999 struct mmu_gather;
75000 struct inode;
75001 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75002 unsigned long *pfn);
75003 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75004 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75005 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75006 - void *buf, int len, int write);
75007 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75008 + void *buf, size_t len, int write);
75009
75010 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75011 loff_t const holebegin, loff_t const holelen)
75012 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75013 }
75014 #endif
75015
75016 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75017 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75018 - void *buf, int len, int write);
75019 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75020 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75021 + void *buf, size_t len, int write);
75022
75023 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75024 unsigned long start, unsigned long nr_pages,
75025 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75026 int set_page_dirty_lock(struct page *page);
75027 int clear_page_dirty_for_io(struct page *page);
75028
75029 -/* Is the vma a continuation of the stack vma above it? */
75030 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75031 -{
75032 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75033 -}
75034 -
75035 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75036 - unsigned long addr)
75037 -{
75038 - return (vma->vm_flags & VM_GROWSDOWN) &&
75039 - (vma->vm_start == addr) &&
75040 - !vma_growsdown(vma->vm_prev, addr);
75041 -}
75042 -
75043 -/* Is the vma a continuation of the stack vma below it? */
75044 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75045 -{
75046 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75047 -}
75048 -
75049 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75050 - unsigned long addr)
75051 -{
75052 - return (vma->vm_flags & VM_GROWSUP) &&
75053 - (vma->vm_end == addr) &&
75054 - !vma_growsup(vma->vm_next, addr);
75055 -}
75056 -
75057 extern pid_t
75058 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75059
75060 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75061 }
75062 #endif
75063
75064 +#ifdef CONFIG_MMU
75065 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75066 +#else
75067 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75068 +{
75069 + return __pgprot(0);
75070 +}
75071 +#endif
75072 +
75073 int vma_wants_writenotify(struct vm_area_struct *vma);
75074
75075 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75076 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75077 {
75078 return 0;
75079 }
75080 +
75081 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75082 + unsigned long address)
75083 +{
75084 + return 0;
75085 +}
75086 #else
75087 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75088 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75089 #endif
75090
75091 #ifdef __PAGETABLE_PMD_FOLDED
75092 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75093 {
75094 return 0;
75095 }
75096 +
75097 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75098 + unsigned long address)
75099 +{
75100 + return 0;
75101 +}
75102 #else
75103 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75104 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75105 #endif
75106
75107 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75108 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75109 NULL: pud_offset(pgd, address);
75110 }
75111
75112 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75113 +{
75114 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75115 + NULL: pud_offset(pgd, address);
75116 +}
75117 +
75118 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75119 {
75120 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75121 NULL: pmd_offset(pud, address);
75122 }
75123 +
75124 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75125 +{
75126 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75127 + NULL: pmd_offset(pud, address);
75128 +}
75129 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75130
75131 #if USE_SPLIT_PTLOCKS
75132 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75133 unsigned long len, unsigned long prot, unsigned long flags,
75134 unsigned long pgoff, unsigned long *populate);
75135 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75136 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75137
75138 #ifdef CONFIG_MMU
75139 extern int __mm_populate(unsigned long addr, unsigned long len,
75140 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75141 unsigned long high_limit;
75142 unsigned long align_mask;
75143 unsigned long align_offset;
75144 + unsigned long threadstack_offset;
75145 };
75146
75147 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75148 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75149 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75150 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75151
75152 /*
75153 * Search for an unmapped address range.
75154 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75155 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75156 */
75157 static inline unsigned long
75158 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75159 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75160 {
75161 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75162 return unmapped_area(info);
75163 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75164 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75165 struct vm_area_struct **pprev);
75166
75167 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75168 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75169 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75170 +
75171 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75172 NULL if none. Assume start_addr < end_addr. */
75173 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75174 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75175 return vma;
75176 }
75177
75178 -#ifdef CONFIG_MMU
75179 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75180 -#else
75181 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75182 -{
75183 - return __pgprot(0);
75184 -}
75185 -#endif
75186 -
75187 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75188 unsigned long change_prot_numa(struct vm_area_struct *vma,
75189 unsigned long start, unsigned long end);
75190 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75191 static inline void vm_stat_account(struct mm_struct *mm,
75192 unsigned long flags, struct file *file, long pages)
75193 {
75194 +
75195 +#ifdef CONFIG_PAX_RANDMMAP
75196 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75197 +#endif
75198 +
75199 mm->total_vm += pages;
75200 }
75201 #endif /* CONFIG_PROC_FS */
75202 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75203 extern int sysctl_memory_failure_early_kill;
75204 extern int sysctl_memory_failure_recovery;
75205 extern void shake_page(struct page *p, int access);
75206 -extern atomic_long_t num_poisoned_pages;
75207 +extern atomic_long_unchecked_t num_poisoned_pages;
75208 extern int soft_offline_page(struct page *page, int flags);
75209
75210 extern void dump_page(struct page *page);
75211 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75212 static inline void setup_nr_node_ids(void) {}
75213 #endif
75214
75215 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75216 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75217 +#else
75218 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75219 +#endif
75220 +
75221 #endif /* __KERNEL__ */
75222 #endif /* _LINUX_MM_H */
75223 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75224 index faf4b7c..1e70c6e 100644
75225 --- a/include/linux/mm_types.h
75226 +++ b/include/linux/mm_types.h
75227 @@ -289,6 +289,8 @@ struct vm_area_struct {
75228 #ifdef CONFIG_NUMA
75229 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75230 #endif
75231 +
75232 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75233 };
75234
75235 struct core_thread {
75236 @@ -435,6 +437,24 @@ struct mm_struct {
75237 int first_nid;
75238 #endif
75239 struct uprobes_state uprobes_state;
75240 +
75241 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75242 + unsigned long pax_flags;
75243 +#endif
75244 +
75245 +#ifdef CONFIG_PAX_DLRESOLVE
75246 + unsigned long call_dl_resolve;
75247 +#endif
75248 +
75249 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75250 + unsigned long call_syscall;
75251 +#endif
75252 +
75253 +#ifdef CONFIG_PAX_ASLR
75254 + unsigned long delta_mmap; /* randomized offset */
75255 + unsigned long delta_stack; /* randomized offset */
75256 +#endif
75257 +
75258 };
75259
75260 /* first nid will either be a valid NID or one of these values */
75261 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75262 index c5d5278..f0b68c8 100644
75263 --- a/include/linux/mmiotrace.h
75264 +++ b/include/linux/mmiotrace.h
75265 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75266 /* Called from ioremap.c */
75267 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75268 void __iomem *addr);
75269 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75270 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75271
75272 /* For anyone to insert markers. Remember trailing newline. */
75273 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75274 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75275 {
75276 }
75277
75278 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75279 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75280 {
75281 }
75282
75283 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75284 index af4a3b7..9ad8889 100644
75285 --- a/include/linux/mmzone.h
75286 +++ b/include/linux/mmzone.h
75287 @@ -396,7 +396,7 @@ struct zone {
75288 unsigned long flags; /* zone flags, see below */
75289
75290 /* Zone statistics */
75291 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75292 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75293
75294 /*
75295 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75296 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75297 index 45e9214..a7227d6 100644
75298 --- a/include/linux/mod_devicetable.h
75299 +++ b/include/linux/mod_devicetable.h
75300 @@ -13,7 +13,7 @@
75301 typedef unsigned long kernel_ulong_t;
75302 #endif
75303
75304 -#define PCI_ANY_ID (~0)
75305 +#define PCI_ANY_ID ((__u16)~0)
75306
75307 struct pci_device_id {
75308 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75309 @@ -139,7 +139,7 @@ struct usb_device_id {
75310 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75311 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75312
75313 -#define HID_ANY_ID (~0)
75314 +#define HID_ANY_ID (~0U)
75315 #define HID_BUS_ANY 0xffff
75316 #define HID_GROUP_ANY 0x0000
75317
75318 @@ -467,7 +467,7 @@ struct dmi_system_id {
75319 const char *ident;
75320 struct dmi_strmatch matches[4];
75321 void *driver_data;
75322 -};
75323 +} __do_const;
75324 /*
75325 * struct dmi_device_id appears during expansion of
75326 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75327 diff --git a/include/linux/module.h b/include/linux/module.h
75328 index 46f1ea0..a34ca37 100644
75329 --- a/include/linux/module.h
75330 +++ b/include/linux/module.h
75331 @@ -17,9 +17,11 @@
75332 #include <linux/moduleparam.h>
75333 #include <linux/tracepoint.h>
75334 #include <linux/export.h>
75335 +#include <linux/fs.h>
75336
75337 #include <linux/percpu.h>
75338 #include <asm/module.h>
75339 +#include <asm/pgtable.h>
75340
75341 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75342 #define MODULE_SIG_STRING "~Module signature appended~\n"
75343 @@ -54,12 +56,13 @@ struct module_attribute {
75344 int (*test)(struct module *);
75345 void (*free)(struct module *);
75346 };
75347 +typedef struct module_attribute __no_const module_attribute_no_const;
75348
75349 struct module_version_attribute {
75350 struct module_attribute mattr;
75351 const char *module_name;
75352 const char *version;
75353 -} __attribute__ ((__aligned__(sizeof(void *))));
75354 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75355
75356 extern ssize_t __modver_version_show(struct module_attribute *,
75357 struct module_kobject *, char *);
75358 @@ -232,7 +235,7 @@ struct module
75359
75360 /* Sysfs stuff. */
75361 struct module_kobject mkobj;
75362 - struct module_attribute *modinfo_attrs;
75363 + module_attribute_no_const *modinfo_attrs;
75364 const char *version;
75365 const char *srcversion;
75366 struct kobject *holders_dir;
75367 @@ -281,19 +284,16 @@ struct module
75368 int (*init)(void);
75369
75370 /* If this is non-NULL, vfree after init() returns */
75371 - void *module_init;
75372 + void *module_init_rx, *module_init_rw;
75373
75374 /* Here is the actual code + data, vfree'd on unload. */
75375 - void *module_core;
75376 + void *module_core_rx, *module_core_rw;
75377
75378 /* Here are the sizes of the init and core sections */
75379 - unsigned int init_size, core_size;
75380 + unsigned int init_size_rw, core_size_rw;
75381
75382 /* The size of the executable code in each section. */
75383 - unsigned int init_text_size, core_text_size;
75384 -
75385 - /* Size of RO sections of the module (text+rodata) */
75386 - unsigned int init_ro_size, core_ro_size;
75387 + unsigned int init_size_rx, core_size_rx;
75388
75389 /* Arch-specific module values */
75390 struct mod_arch_specific arch;
75391 @@ -349,6 +349,10 @@ struct module
75392 #ifdef CONFIG_EVENT_TRACING
75393 struct ftrace_event_call **trace_events;
75394 unsigned int num_trace_events;
75395 + struct file_operations trace_id;
75396 + struct file_operations trace_enable;
75397 + struct file_operations trace_format;
75398 + struct file_operations trace_filter;
75399 #endif
75400 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75401 unsigned int num_ftrace_callsites;
75402 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75403 bool is_module_percpu_address(unsigned long addr);
75404 bool is_module_text_address(unsigned long addr);
75405
75406 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75407 +{
75408 +
75409 +#ifdef CONFIG_PAX_KERNEXEC
75410 + if (ktla_ktva(addr) >= (unsigned long)start &&
75411 + ktla_ktva(addr) < (unsigned long)start + size)
75412 + return 1;
75413 +#endif
75414 +
75415 + return ((void *)addr >= start && (void *)addr < start + size);
75416 +}
75417 +
75418 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75419 +{
75420 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75421 +}
75422 +
75423 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75424 +{
75425 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75426 +}
75427 +
75428 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75429 +{
75430 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75431 +}
75432 +
75433 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75434 +{
75435 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75436 +}
75437 +
75438 static inline int within_module_core(unsigned long addr, const struct module *mod)
75439 {
75440 - return (unsigned long)mod->module_core <= addr &&
75441 - addr < (unsigned long)mod->module_core + mod->core_size;
75442 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75443 }
75444
75445 static inline int within_module_init(unsigned long addr, const struct module *mod)
75446 {
75447 - return (unsigned long)mod->module_init <= addr &&
75448 - addr < (unsigned long)mod->module_init + mod->init_size;
75449 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75450 }
75451
75452 /* Search for module by name: must hold module_mutex. */
75453 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75454 index 560ca53..ef621ef 100644
75455 --- a/include/linux/moduleloader.h
75456 +++ b/include/linux/moduleloader.h
75457 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75458 sections. Returns NULL on failure. */
75459 void *module_alloc(unsigned long size);
75460
75461 +#ifdef CONFIG_PAX_KERNEXEC
75462 +void *module_alloc_exec(unsigned long size);
75463 +#else
75464 +#define module_alloc_exec(x) module_alloc(x)
75465 +#endif
75466 +
75467 /* Free memory returned from module_alloc. */
75468 void module_free(struct module *mod, void *module_region);
75469
75470 +#ifdef CONFIG_PAX_KERNEXEC
75471 +void module_free_exec(struct module *mod, void *module_region);
75472 +#else
75473 +#define module_free_exec(x, y) module_free((x), (y))
75474 +#endif
75475 +
75476 /*
75477 * Apply the given relocation to the (simplified) ELF. Return -error
75478 * or 0.
75479 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75480 unsigned int relsec,
75481 struct module *me)
75482 {
75483 +#ifdef CONFIG_MODULES
75484 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75485 +#endif
75486 return -ENOEXEC;
75487 }
75488 #endif
75489 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75490 unsigned int relsec,
75491 struct module *me)
75492 {
75493 +#ifdef CONFIG_MODULES
75494 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75495 +#endif
75496 return -ENOEXEC;
75497 }
75498 #endif
75499 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75500 index 27d9da3..5d94aa3 100644
75501 --- a/include/linux/moduleparam.h
75502 +++ b/include/linux/moduleparam.h
75503 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75504 * @len is usually just sizeof(string).
75505 */
75506 #define module_param_string(name, string, len, perm) \
75507 - static const struct kparam_string __param_string_##name \
75508 + static const struct kparam_string __param_string_##name __used \
75509 = { len, string }; \
75510 __module_param_call(MODULE_PARAM_PREFIX, name, \
75511 &param_ops_string, \
75512 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75513 */
75514 #define module_param_array_named(name, array, type, nump, perm) \
75515 param_check_##type(name, &(array)[0]); \
75516 - static const struct kparam_array __param_arr_##name \
75517 + static const struct kparam_array __param_arr_##name __used \
75518 = { .max = ARRAY_SIZE(array), .num = nump, \
75519 .ops = &param_ops_##type, \
75520 .elemsize = sizeof(array[0]), .elem = array }; \
75521 diff --git a/include/linux/namei.h b/include/linux/namei.h
75522 index 5a5ff57..5ae5070 100644
75523 --- a/include/linux/namei.h
75524 +++ b/include/linux/namei.h
75525 @@ -19,7 +19,7 @@ struct nameidata {
75526 unsigned seq;
75527 int last_type;
75528 unsigned depth;
75529 - char *saved_names[MAX_NESTED_LINKS + 1];
75530 + const char *saved_names[MAX_NESTED_LINKS + 1];
75531 };
75532
75533 /*
75534 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75535
75536 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75537
75538 -static inline void nd_set_link(struct nameidata *nd, char *path)
75539 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75540 {
75541 nd->saved_names[nd->depth] = path;
75542 }
75543
75544 -static inline char *nd_get_link(struct nameidata *nd)
75545 +static inline const char *nd_get_link(const struct nameidata *nd)
75546 {
75547 return nd->saved_names[nd->depth];
75548 }
75549 diff --git a/include/linux/net.h b/include/linux/net.h
75550 index 4f27575..fc8a65f 100644
75551 --- a/include/linux/net.h
75552 +++ b/include/linux/net.h
75553 @@ -183,7 +183,7 @@ struct net_proto_family {
75554 int (*create)(struct net *net, struct socket *sock,
75555 int protocol, int kern);
75556 struct module *owner;
75557 -};
75558 +} __do_const;
75559
75560 struct iovec;
75561 struct kvec;
75562 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75563 index 9a41568..203d903 100644
75564 --- a/include/linux/netdevice.h
75565 +++ b/include/linux/netdevice.h
75566 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75567 int (*ndo_change_carrier)(struct net_device *dev,
75568 bool new_carrier);
75569 };
75570 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75571
75572 /*
75573 * The DEVICE structure.
75574 @@ -1131,7 +1132,7 @@ struct net_device {
75575 int iflink;
75576
75577 struct net_device_stats stats;
75578 - atomic_long_t rx_dropped; /* dropped packets by core network
75579 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75580 * Do not use this in drivers.
75581 */
75582
75583 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75584 index de70f7b..2675e91 100644
75585 --- a/include/linux/netfilter.h
75586 +++ b/include/linux/netfilter.h
75587 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75588 #endif
75589 /* Use the module struct to lock set/get code in place */
75590 struct module *owner;
75591 -};
75592 +} __do_const;
75593
75594 /* Function to register/unregister hook points. */
75595 int nf_register_hook(struct nf_hook_ops *reg);
75596 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75597 index d80e275..c3510b8 100644
75598 --- a/include/linux/netfilter/ipset/ip_set.h
75599 +++ b/include/linux/netfilter/ipset/ip_set.h
75600 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75601 /* Return true if "b" set is the same as "a"
75602 * according to the create set parameters */
75603 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75604 -};
75605 +} __do_const;
75606
75607 /* The core set type structure */
75608 struct ip_set_type {
75609 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75610 index cadb740..d7c37c0 100644
75611 --- a/include/linux/netfilter/nfnetlink.h
75612 +++ b/include/linux/netfilter/nfnetlink.h
75613 @@ -16,7 +16,7 @@ struct nfnl_callback {
75614 const struct nlattr * const cda[]);
75615 const struct nla_policy *policy; /* netlink attribute policy */
75616 const u_int16_t attr_count; /* number of nlattr's */
75617 -};
75618 +} __do_const;
75619
75620 struct nfnetlink_subsystem {
75621 const char *name;
75622 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75623 new file mode 100644
75624 index 0000000..33f4af8
75625 --- /dev/null
75626 +++ b/include/linux/netfilter/xt_gradm.h
75627 @@ -0,0 +1,9 @@
75628 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75629 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75630 +
75631 +struct xt_gradm_mtinfo {
75632 + __u16 flags;
75633 + __u16 invflags;
75634 +};
75635 +
75636 +#endif
75637 diff --git a/include/linux/nls.h b/include/linux/nls.h
75638 index 5dc635f..35f5e11 100644
75639 --- a/include/linux/nls.h
75640 +++ b/include/linux/nls.h
75641 @@ -31,7 +31,7 @@ struct nls_table {
75642 const unsigned char *charset2upper;
75643 struct module *owner;
75644 struct nls_table *next;
75645 -};
75646 +} __do_const;
75647
75648 /* this value hold the maximum octet of charset */
75649 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75650 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75651 index d14a4c3..a078786 100644
75652 --- a/include/linux/notifier.h
75653 +++ b/include/linux/notifier.h
75654 @@ -54,7 +54,8 @@ struct notifier_block {
75655 notifier_fn_t notifier_call;
75656 struct notifier_block __rcu *next;
75657 int priority;
75658 -};
75659 +} __do_const;
75660 +typedef struct notifier_block __no_const notifier_block_no_const;
75661
75662 struct atomic_notifier_head {
75663 spinlock_t lock;
75664 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75665 index a4c5624..79d6d88 100644
75666 --- a/include/linux/oprofile.h
75667 +++ b/include/linux/oprofile.h
75668 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75669 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75670 char const * name, ulong * val);
75671
75672 -/** Create a file for read-only access to an atomic_t. */
75673 +/** Create a file for read-only access to an atomic_unchecked_t. */
75674 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75675 - char const * name, atomic_t * val);
75676 + char const * name, atomic_unchecked_t * val);
75677
75678 /** create a directory */
75679 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75680 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75681 index 8db71dc..a76bf2c 100644
75682 --- a/include/linux/pci_hotplug.h
75683 +++ b/include/linux/pci_hotplug.h
75684 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75685 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75686 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75687 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75688 -};
75689 +} __do_const;
75690 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75691
75692 /**
75693 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75694 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75695 index c43f6ea..2d4416f 100644
75696 --- a/include/linux/perf_event.h
75697 +++ b/include/linux/perf_event.h
75698 @@ -328,8 +328,8 @@ struct perf_event {
75699
75700 enum perf_event_active_state state;
75701 unsigned int attach_state;
75702 - local64_t count;
75703 - atomic64_t child_count;
75704 + local64_t count; /* PaX: fix it one day */
75705 + atomic64_unchecked_t child_count;
75706
75707 /*
75708 * These are the total time in nanoseconds that the event
75709 @@ -380,8 +380,8 @@ struct perf_event {
75710 * These accumulate total time (in nanoseconds) that children
75711 * events have been enabled and running, respectively.
75712 */
75713 - atomic64_t child_total_time_enabled;
75714 - atomic64_t child_total_time_running;
75715 + atomic64_unchecked_t child_total_time_enabled;
75716 + atomic64_unchecked_t child_total_time_running;
75717
75718 /*
75719 * Protect attach/detach and child_list:
75720 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75721 entry->ip[entry->nr++] = ip;
75722 }
75723
75724 -extern int sysctl_perf_event_paranoid;
75725 +extern int sysctl_perf_event_legitimately_concerned;
75726 extern int sysctl_perf_event_mlock;
75727 extern int sysctl_perf_event_sample_rate;
75728 extern int sysctl_perf_cpu_time_max_percent;
75729 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75730 loff_t *ppos);
75731
75732
75733 +static inline bool perf_paranoid_any(void)
75734 +{
75735 + return sysctl_perf_event_legitimately_concerned > 2;
75736 +}
75737 +
75738 static inline bool perf_paranoid_tracepoint_raw(void)
75739 {
75740 - return sysctl_perf_event_paranoid > -1;
75741 + return sysctl_perf_event_legitimately_concerned > -1;
75742 }
75743
75744 static inline bool perf_paranoid_cpu(void)
75745 {
75746 - return sysctl_perf_event_paranoid > 0;
75747 + return sysctl_perf_event_legitimately_concerned > 0;
75748 }
75749
75750 static inline bool perf_paranoid_kernel(void)
75751 {
75752 - return sysctl_perf_event_paranoid > 1;
75753 + return sysctl_perf_event_legitimately_concerned > 1;
75754 }
75755
75756 extern void perf_event_init(void);
75757 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75758 struct device_attribute attr;
75759 u64 id;
75760 const char *event_str;
75761 -};
75762 +} __do_const;
75763
75764 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75765 static struct perf_pmu_events_attr _var = { \
75766 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75767 index b8809fe..ae4ccd0 100644
75768 --- a/include/linux/pipe_fs_i.h
75769 +++ b/include/linux/pipe_fs_i.h
75770 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75771 struct mutex mutex;
75772 wait_queue_head_t wait;
75773 unsigned int nrbufs, curbuf, buffers;
75774 - unsigned int readers;
75775 - unsigned int writers;
75776 - unsigned int files;
75777 - unsigned int waiting_writers;
75778 + atomic_t readers;
75779 + atomic_t writers;
75780 + atomic_t files;
75781 + atomic_t waiting_writers;
75782 unsigned int r_counter;
75783 unsigned int w_counter;
75784 struct page *tmp_page;
75785 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75786 index 5f28cae..3d23723 100644
75787 --- a/include/linux/platform_data/usb-ehci-s5p.h
75788 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75789 @@ -14,7 +14,7 @@
75790 struct s5p_ehci_platdata {
75791 int (*phy_init)(struct platform_device *pdev, int type);
75792 int (*phy_exit)(struct platform_device *pdev, int type);
75793 -};
75794 +} __no_const;
75795
75796 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75797
75798 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75799 index c256c59..8ea94c7 100644
75800 --- a/include/linux/platform_data/usb-ohci-exynos.h
75801 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75802 @@ -14,7 +14,7 @@
75803 struct exynos4_ohci_platdata {
75804 int (*phy_init)(struct platform_device *pdev, int type);
75805 int (*phy_exit)(struct platform_device *pdev, int type);
75806 -};
75807 +} __no_const;
75808
75809 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75810
75811 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75812 index 7c1d252..c5c773e 100644
75813 --- a/include/linux/pm_domain.h
75814 +++ b/include/linux/pm_domain.h
75815 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75816
75817 struct gpd_cpu_data {
75818 unsigned int saved_exit_latency;
75819 - struct cpuidle_state *idle_state;
75820 + cpuidle_state_no_const *idle_state;
75821 };
75822
75823 struct generic_pm_domain {
75824 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75825 index 6fa7cea..7bf6415 100644
75826 --- a/include/linux/pm_runtime.h
75827 +++ b/include/linux/pm_runtime.h
75828 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75829
75830 static inline void pm_runtime_mark_last_busy(struct device *dev)
75831 {
75832 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75833 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75834 }
75835
75836 #else /* !CONFIG_PM_RUNTIME */
75837 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75838 index 195aafc..49a7bc2 100644
75839 --- a/include/linux/pnp.h
75840 +++ b/include/linux/pnp.h
75841 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75842 struct pnp_fixup {
75843 char id[7];
75844 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75845 -};
75846 +} __do_const;
75847
75848 /* config parameters */
75849 #define PNP_CONFIG_NORMAL 0x0001
75850 diff --git a/include/linux/poison.h b/include/linux/poison.h
75851 index 2110a81..13a11bb 100644
75852 --- a/include/linux/poison.h
75853 +++ b/include/linux/poison.h
75854 @@ -19,8 +19,8 @@
75855 * under normal circumstances, used to verify that nobody uses
75856 * non-initialized list entries.
75857 */
75858 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75859 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75860 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75861 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75862
75863 /********** include/linux/timer.h **********/
75864 /*
75865 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75866 index d8b187c3..9a9257a 100644
75867 --- a/include/linux/power/smartreflex.h
75868 +++ b/include/linux/power/smartreflex.h
75869 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75870 int (*notify)(struct omap_sr *sr, u32 status);
75871 u8 notify_flags;
75872 u8 class_type;
75873 -};
75874 +} __do_const;
75875
75876 /**
75877 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75878 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75879 index 4ea1d37..80f4b33 100644
75880 --- a/include/linux/ppp-comp.h
75881 +++ b/include/linux/ppp-comp.h
75882 @@ -84,7 +84,7 @@ struct compressor {
75883 struct module *owner;
75884 /* Extra skb space needed by the compressor algorithm */
75885 unsigned int comp_extra;
75886 -};
75887 +} __do_const;
75888
75889 /*
75890 * The return value from decompress routine is the length of the
75891 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75892 index f5d4723..a6ea2fa 100644
75893 --- a/include/linux/preempt.h
75894 +++ b/include/linux/preempt.h
75895 @@ -18,8 +18,13 @@
75896 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75897 #endif
75898
75899 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75900 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75901 +
75902 #define inc_preempt_count() add_preempt_count(1)
75903 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75904 #define dec_preempt_count() sub_preempt_count(1)
75905 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75906
75907 #define preempt_count() (current_thread_info()->preempt_count)
75908
75909 @@ -64,6 +69,12 @@ do { \
75910 barrier(); \
75911 } while (0)
75912
75913 +#define raw_preempt_disable() \
75914 +do { \
75915 + raw_inc_preempt_count(); \
75916 + barrier(); \
75917 +} while (0)
75918 +
75919 #define sched_preempt_enable_no_resched() \
75920 do { \
75921 barrier(); \
75922 @@ -72,6 +83,12 @@ do { \
75923
75924 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75925
75926 +#define raw_preempt_enable_no_resched() \
75927 +do { \
75928 + barrier(); \
75929 + raw_dec_preempt_count(); \
75930 +} while (0)
75931 +
75932 #define preempt_enable() \
75933 do { \
75934 preempt_enable_no_resched(); \
75935 @@ -116,8 +133,10 @@ do { \
75936 * region.
75937 */
75938 #define preempt_disable() barrier()
75939 +#define raw_preempt_disable() barrier()
75940 #define sched_preempt_enable_no_resched() barrier()
75941 #define preempt_enable_no_resched() barrier()
75942 +#define raw_preempt_enable_no_resched() barrier()
75943 #define preempt_enable() barrier()
75944
75945 #define preempt_disable_notrace() barrier()
75946 diff --git a/include/linux/printk.h b/include/linux/printk.h
75947 index 22c7052..ad3fa0a 100644
75948 --- a/include/linux/printk.h
75949 +++ b/include/linux/printk.h
75950 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75951 void early_printk(const char *s, ...) { }
75952 #endif
75953
75954 +extern int kptr_restrict;
75955 +
75956 #ifdef CONFIG_PRINTK
75957 asmlinkage __printf(5, 0)
75958 int vprintk_emit(int facility, int level,
75959 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
75960
75961 extern int printk_delay_msec;
75962 extern int dmesg_restrict;
75963 -extern int kptr_restrict;
75964
75965 extern void wake_up_klogd(void);
75966
75967 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
75968 index 608e60a..c26f864 100644
75969 --- a/include/linux/proc_fs.h
75970 +++ b/include/linux/proc_fs.h
75971 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
75972 return proc_create_data(name, mode, parent, proc_fops, NULL);
75973 }
75974
75975 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
75976 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
75977 +{
75978 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75979 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
75980 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75981 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
75982 +#else
75983 + return proc_create_data(name, mode, parent, proc_fops, NULL);
75984 +#endif
75985 +}
75986 +
75987 +
75988 extern void proc_set_size(struct proc_dir_entry *, loff_t);
75989 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
75990 extern void *PDE_DATA(const struct inode *);
75991 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
75992 index 34a1e10..03a6d03 100644
75993 --- a/include/linux/proc_ns.h
75994 +++ b/include/linux/proc_ns.h
75995 @@ -14,7 +14,7 @@ struct proc_ns_operations {
75996 void (*put)(void *ns);
75997 int (*install)(struct nsproxy *nsproxy, void *ns);
75998 unsigned int (*inum)(void *ns);
75999 -};
76000 +} __do_const;
76001
76002 struct proc_ns {
76003 void *ns;
76004 diff --git a/include/linux/random.h b/include/linux/random.h
76005 index 3b9377d..e418336 100644
76006 --- a/include/linux/random.h
76007 +++ b/include/linux/random.h
76008 @@ -10,9 +10,19 @@
76009
76010
76011 extern void add_device_randomness(const void *, unsigned int);
76012 +
76013 +static inline void add_latent_entropy(void)
76014 +{
76015 +
76016 +#ifdef LATENT_ENTROPY_PLUGIN
76017 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76018 +#endif
76019 +
76020 +}
76021 +
76022 extern void add_input_randomness(unsigned int type, unsigned int code,
76023 - unsigned int value);
76024 -extern void add_interrupt_randomness(int irq, int irq_flags);
76025 + unsigned int value) __latent_entropy;
76026 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76027
76028 extern void get_random_bytes(void *buf, int nbytes);
76029 extern void get_random_bytes_arch(void *buf, int nbytes);
76030 @@ -32,6 +42,11 @@ void prandom_seed(u32 seed);
76031 u32 prandom_u32_state(struct rnd_state *);
76032 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76033
76034 +static inline unsigned long pax_get_random_long(void)
76035 +{
76036 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76037 +}
76038 +
76039 /*
76040 * Handle minimum values for seeds
76041 */
76042 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76043 index 4106721..132d42c 100644
76044 --- a/include/linux/rculist.h
76045 +++ b/include/linux/rculist.h
76046 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76047 struct list_head *prev, struct list_head *next);
76048 #endif
76049
76050 +extern void __pax_list_add_rcu(struct list_head *new,
76051 + struct list_head *prev, struct list_head *next);
76052 +
76053 /**
76054 * list_add_rcu - add a new entry to rcu-protected list
76055 * @new: new entry to be added
76056 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76057 __list_add_rcu(new, head, head->next);
76058 }
76059
76060 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76061 +{
76062 + __pax_list_add_rcu(new, head, head->next);
76063 +}
76064 +
76065 /**
76066 * list_add_tail_rcu - add a new entry to rcu-protected list
76067 * @new: new entry to be added
76068 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76069 __list_add_rcu(new, head->prev, head);
76070 }
76071
76072 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76073 + struct list_head *head)
76074 +{
76075 + __pax_list_add_rcu(new, head->prev, head);
76076 +}
76077 +
76078 /**
76079 * list_del_rcu - deletes entry from list without re-initialization
76080 * @entry: the element to delete from the list.
76081 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76082 entry->prev = LIST_POISON2;
76083 }
76084
76085 +extern void pax_list_del_rcu(struct list_head *entry);
76086 +
76087 /**
76088 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76089 * @n: the element to delete from the hash list.
76090 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76091 index 8e00f9f..9449b55 100644
76092 --- a/include/linux/reboot.h
76093 +++ b/include/linux/reboot.h
76094 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76095 * Architecture-specific implementations of sys_reboot commands.
76096 */
76097
76098 -extern void machine_restart(char *cmd);
76099 -extern void machine_halt(void);
76100 -extern void machine_power_off(void);
76101 +extern void machine_restart(char *cmd) __noreturn;
76102 +extern void machine_halt(void) __noreturn;
76103 +extern void machine_power_off(void) __noreturn;
76104
76105 extern void machine_shutdown(void);
76106 struct pt_regs;
76107 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76108 */
76109
76110 extern void kernel_restart_prepare(char *cmd);
76111 -extern void kernel_restart(char *cmd);
76112 -extern void kernel_halt(void);
76113 -extern void kernel_power_off(void);
76114 +extern void kernel_restart(char *cmd) __noreturn;
76115 +extern void kernel_halt(void) __noreturn;
76116 +extern void kernel_power_off(void) __noreturn;
76117
76118 extern int C_A_D; /* for sysctl */
76119 void ctrl_alt_del(void);
76120 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76121 * Emergency restart, callable from an interrupt handler.
76122 */
76123
76124 -extern void emergency_restart(void);
76125 +extern void emergency_restart(void) __noreturn;
76126 #include <asm/emergency-restart.h>
76127
76128 #endif /* _LINUX_REBOOT_H */
76129 diff --git a/include/linux/regset.h b/include/linux/regset.h
76130 index 8e0c9fe..ac4d221 100644
76131 --- a/include/linux/regset.h
76132 +++ b/include/linux/regset.h
76133 @@ -161,7 +161,8 @@ struct user_regset {
76134 unsigned int align;
76135 unsigned int bias;
76136 unsigned int core_note_type;
76137 -};
76138 +} __do_const;
76139 +typedef struct user_regset __no_const user_regset_no_const;
76140
76141 /**
76142 * struct user_regset_view - available regsets
76143 diff --git a/include/linux/relay.h b/include/linux/relay.h
76144 index d7c8359..818daf5 100644
76145 --- a/include/linux/relay.h
76146 +++ b/include/linux/relay.h
76147 @@ -157,7 +157,7 @@ struct rchan_callbacks
76148 * The callback should return 0 if successful, negative if not.
76149 */
76150 int (*remove_buf_file)(struct dentry *dentry);
76151 -};
76152 +} __no_const;
76153
76154 /*
76155 * CONFIG_RELAY kernel API, kernel/relay.c
76156 diff --git a/include/linux/rio.h b/include/linux/rio.h
76157 index b71d573..2f940bd 100644
76158 --- a/include/linux/rio.h
76159 +++ b/include/linux/rio.h
76160 @@ -355,7 +355,7 @@ struct rio_ops {
76161 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76162 u64 rstart, u32 size, u32 flags);
76163 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76164 -};
76165 +} __no_const;
76166
76167 #define RIO_RESOURCE_MEM 0x00000100
76168 #define RIO_RESOURCE_DOORBELL 0x00000200
76169 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76170 index 6dacb93..6174423 100644
76171 --- a/include/linux/rmap.h
76172 +++ b/include/linux/rmap.h
76173 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76174 void anon_vma_init(void); /* create anon_vma_cachep */
76175 int anon_vma_prepare(struct vm_area_struct *);
76176 void unlink_anon_vmas(struct vm_area_struct *);
76177 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76178 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76179 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76180 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76181
76182 static inline void anon_vma_merge(struct vm_area_struct *vma,
76183 struct vm_area_struct *next)
76184 diff --git a/include/linux/sched.h b/include/linux/sched.h
76185 index 078066d..4090b3b 100644
76186 --- a/include/linux/sched.h
76187 +++ b/include/linux/sched.h
76188 @@ -62,6 +62,7 @@ struct bio_list;
76189 struct fs_struct;
76190 struct perf_event_context;
76191 struct blk_plug;
76192 +struct linux_binprm;
76193
76194 /*
76195 * List of flags we want to share for kernel threads,
76196 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76197 extern int in_sched_functions(unsigned long addr);
76198
76199 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76200 -extern signed long schedule_timeout(signed long timeout);
76201 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76202 extern signed long schedule_timeout_interruptible(signed long timeout);
76203 extern signed long schedule_timeout_killable(signed long timeout);
76204 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76205 @@ -314,6 +315,19 @@ struct nsproxy;
76206 struct user_namespace;
76207
76208 #ifdef CONFIG_MMU
76209 +
76210 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76211 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76212 +#else
76213 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76214 +{
76215 + return 0;
76216 +}
76217 +#endif
76218 +
76219 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76220 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76221 +
76222 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76223 extern unsigned long
76224 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76225 @@ -589,6 +603,17 @@ struct signal_struct {
76226 #ifdef CONFIG_TASKSTATS
76227 struct taskstats *stats;
76228 #endif
76229 +
76230 +#ifdef CONFIG_GRKERNSEC
76231 + u32 curr_ip;
76232 + u32 saved_ip;
76233 + u32 gr_saddr;
76234 + u32 gr_daddr;
76235 + u16 gr_sport;
76236 + u16 gr_dport;
76237 + u8 used_accept:1;
76238 +#endif
76239 +
76240 #ifdef CONFIG_AUDIT
76241 unsigned audit_tty;
76242 unsigned audit_tty_log_passwd;
76243 @@ -669,6 +694,14 @@ struct user_struct {
76244 struct key *session_keyring; /* UID's default session keyring */
76245 #endif
76246
76247 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76248 + unsigned char kernel_banned;
76249 +#endif
76250 +#ifdef CONFIG_GRKERNSEC_BRUTE
76251 + unsigned char suid_banned;
76252 + unsigned long suid_ban_expires;
76253 +#endif
76254 +
76255 /* Hash table maintenance information */
76256 struct hlist_node uidhash_node;
76257 kuid_t uid;
76258 @@ -1151,8 +1184,8 @@ struct task_struct {
76259 struct list_head thread_group;
76260
76261 struct completion *vfork_done; /* for vfork() */
76262 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76263 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76264 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76265 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76266
76267 cputime_t utime, stime, utimescaled, stimescaled;
76268 cputime_t gtime;
76269 @@ -1177,11 +1210,6 @@ struct task_struct {
76270 struct task_cputime cputime_expires;
76271 struct list_head cpu_timers[3];
76272
76273 -/* process credentials */
76274 - const struct cred __rcu *real_cred; /* objective and real subjective task
76275 - * credentials (COW) */
76276 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76277 - * credentials (COW) */
76278 char comm[TASK_COMM_LEN]; /* executable name excluding path
76279 - access with [gs]et_task_comm (which lock
76280 it with task_lock())
76281 @@ -1198,6 +1226,10 @@ struct task_struct {
76282 #endif
76283 /* CPU-specific state of this task */
76284 struct thread_struct thread;
76285 +/* thread_info moved to task_struct */
76286 +#ifdef CONFIG_X86
76287 + struct thread_info tinfo;
76288 +#endif
76289 /* filesystem information */
76290 struct fs_struct *fs;
76291 /* open file information */
76292 @@ -1271,6 +1303,10 @@ struct task_struct {
76293 gfp_t lockdep_reclaim_gfp;
76294 #endif
76295
76296 +/* process credentials */
76297 + const struct cred __rcu *real_cred; /* objective and real subjective task
76298 + * credentials (COW) */
76299 +
76300 /* journalling filesystem info */
76301 void *journal_info;
76302
76303 @@ -1309,6 +1345,10 @@ struct task_struct {
76304 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76305 struct list_head cg_list;
76306 #endif
76307 +
76308 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76309 + * credentials (COW) */
76310 +
76311 #ifdef CONFIG_FUTEX
76312 struct robust_list_head __user *robust_list;
76313 #ifdef CONFIG_COMPAT
76314 @@ -1406,8 +1446,76 @@ struct task_struct {
76315 unsigned int sequential_io;
76316 unsigned int sequential_io_avg;
76317 #endif
76318 +
76319 +#ifdef CONFIG_GRKERNSEC
76320 + /* grsecurity */
76321 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76322 + u64 exec_id;
76323 +#endif
76324 +#ifdef CONFIG_GRKERNSEC_SETXID
76325 + const struct cred *delayed_cred;
76326 +#endif
76327 + struct dentry *gr_chroot_dentry;
76328 + struct acl_subject_label *acl;
76329 + struct acl_role_label *role;
76330 + struct file *exec_file;
76331 + unsigned long brute_expires;
76332 + u16 acl_role_id;
76333 + /* is this the task that authenticated to the special role */
76334 + u8 acl_sp_role;
76335 + u8 is_writable;
76336 + u8 brute;
76337 + u8 gr_is_chrooted;
76338 +#endif
76339 +
76340 };
76341
76342 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76343 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76344 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76345 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76346 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76347 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76348 +
76349 +#ifdef CONFIG_PAX_SOFTMODE
76350 +extern int pax_softmode;
76351 +#endif
76352 +
76353 +extern int pax_check_flags(unsigned long *);
76354 +
76355 +/* if tsk != current then task_lock must be held on it */
76356 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76357 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76358 +{
76359 + if (likely(tsk->mm))
76360 + return tsk->mm->pax_flags;
76361 + else
76362 + return 0UL;
76363 +}
76364 +
76365 +/* if tsk != current then task_lock must be held on it */
76366 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76367 +{
76368 + if (likely(tsk->mm)) {
76369 + tsk->mm->pax_flags = flags;
76370 + return 0;
76371 + }
76372 + return -EINVAL;
76373 +}
76374 +#endif
76375 +
76376 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76377 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76378 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76379 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76380 +#endif
76381 +
76382 +struct path;
76383 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76384 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76385 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76386 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76387 +
76388 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76389 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76390
76391 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76392 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76393 struct pid_namespace *ns);
76394
76395 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76396 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76397 {
76398 return tsk->pid;
76399 }
76400 @@ -1916,7 +2024,9 @@ void yield(void);
76401 extern struct exec_domain default_exec_domain;
76402
76403 union thread_union {
76404 +#ifndef CONFIG_X86
76405 struct thread_info thread_info;
76406 +#endif
76407 unsigned long stack[THREAD_SIZE/sizeof(long)];
76408 };
76409
76410 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76411 */
76412
76413 extern struct task_struct *find_task_by_vpid(pid_t nr);
76414 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76415 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76416 struct pid_namespace *ns);
76417
76418 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76419 extern void exit_itimers(struct signal_struct *);
76420 extern void flush_itimer_signals(void);
76421
76422 -extern void do_group_exit(int);
76423 +extern __noreturn void do_group_exit(int);
76424
76425 extern int allow_signal(int);
76426 extern int disallow_signal(int);
76427 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76428
76429 #endif
76430
76431 -static inline int object_is_on_stack(void *obj)
76432 +static inline int object_starts_on_stack(void *obj)
76433 {
76434 - void *stack = task_stack_page(current);
76435 + const void *stack = task_stack_page(current);
76436
76437 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76438 }
76439 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76440 index bf8086b..962b035 100644
76441 --- a/include/linux/sched/sysctl.h
76442 +++ b/include/linux/sched/sysctl.h
76443 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76444 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76445
76446 extern int sysctl_max_map_count;
76447 +extern unsigned long sysctl_heap_stack_gap;
76448
76449 extern unsigned int sysctl_sched_latency;
76450 extern unsigned int sysctl_sched_min_granularity;
76451 diff --git a/include/linux/security.h b/include/linux/security.h
76452 index 7ce53ae..8ee24a5 100644
76453 --- a/include/linux/security.h
76454 +++ b/include/linux/security.h
76455 @@ -27,6 +27,7 @@
76456 #include <linux/slab.h>
76457 #include <linux/err.h>
76458 #include <linux/string.h>
76459 +#include <linux/grsecurity.h>
76460
76461 struct linux_binprm;
76462 struct cred;
76463 @@ -116,8 +117,6 @@ struct seq_file;
76464
76465 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76466
76467 -void reset_security_ops(void);
76468 -
76469 #ifdef CONFIG_MMU
76470 extern unsigned long mmap_min_addr;
76471 extern unsigned long dac_mmap_min_addr;
76472 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76473 index 4e32edc..f8f2d18 100644
76474 --- a/include/linux/seq_file.h
76475 +++ b/include/linux/seq_file.h
76476 @@ -26,6 +26,9 @@ struct seq_file {
76477 struct mutex lock;
76478 const struct seq_operations *op;
76479 int poll_event;
76480 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76481 + u64 exec_id;
76482 +#endif
76483 #ifdef CONFIG_USER_NS
76484 struct user_namespace *user_ns;
76485 #endif
76486 @@ -38,6 +41,7 @@ struct seq_operations {
76487 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76488 int (*show) (struct seq_file *m, void *v);
76489 };
76490 +typedef struct seq_operations __no_const seq_operations_no_const;
76491
76492 #define SEQ_SKIP 1
76493
76494 diff --git a/include/linux/shm.h b/include/linux/shm.h
76495 index 429c199..4d42e38 100644
76496 --- a/include/linux/shm.h
76497 +++ b/include/linux/shm.h
76498 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76499
76500 /* The task created the shm object. NULL if the task is dead. */
76501 struct task_struct *shm_creator;
76502 +#ifdef CONFIG_GRKERNSEC
76503 + time_t shm_createtime;
76504 + pid_t shm_lapid;
76505 +#endif
76506 };
76507
76508 /* shm_mode upper byte flags */
76509 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76510 index 3b71a4e..5c9f309 100644
76511 --- a/include/linux/skbuff.h
76512 +++ b/include/linux/skbuff.h
76513 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76514 extern struct sk_buff *__alloc_skb(unsigned int size,
76515 gfp_t priority, int flags, int node);
76516 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76517 -static inline struct sk_buff *alloc_skb(unsigned int size,
76518 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76519 gfp_t priority)
76520 {
76521 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76522 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76523 */
76524 static inline int skb_queue_empty(const struct sk_buff_head *list)
76525 {
76526 - return list->next == (struct sk_buff *)list;
76527 + return list->next == (const struct sk_buff *)list;
76528 }
76529
76530 /**
76531 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76532 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76533 const struct sk_buff *skb)
76534 {
76535 - return skb->next == (struct sk_buff *)list;
76536 + return skb->next == (const struct sk_buff *)list;
76537 }
76538
76539 /**
76540 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76541 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76542 const struct sk_buff *skb)
76543 {
76544 - return skb->prev == (struct sk_buff *)list;
76545 + return skb->prev == (const struct sk_buff *)list;
76546 }
76547
76548 /**
76549 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76550 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76551 */
76552 #ifndef NET_SKB_PAD
76553 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76554 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76555 #endif
76556
76557 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76558 @@ -2345,7 +2345,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76559 int noblock, int *err);
76560 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76561 struct poll_table_struct *wait);
76562 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76563 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76564 int offset, struct iovec *to,
76565 int size);
76566 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76567 @@ -2636,6 +2636,9 @@ static inline void nf_reset(struct sk_buff *skb)
76568 nf_bridge_put(skb->nf_bridge);
76569 skb->nf_bridge = NULL;
76570 #endif
76571 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76572 + skb->nf_trace = 0;
76573 +#endif
76574 }
76575
76576 static inline void nf_reset_trace(struct sk_buff *skb)
76577 diff --git a/include/linux/slab.h b/include/linux/slab.h
76578 index 6c5cc0e..9ca0fd6 100644
76579 --- a/include/linux/slab.h
76580 +++ b/include/linux/slab.h
76581 @@ -12,15 +12,29 @@
76582 #include <linux/gfp.h>
76583 #include <linux/types.h>
76584 #include <linux/workqueue.h>
76585 -
76586 +#include <linux/err.h>
76587
76588 /*
76589 * Flags to pass to kmem_cache_create().
76590 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76591 */
76592 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76593 +
76594 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76595 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76596 +#else
76597 +#define SLAB_USERCOPY 0x00000000UL
76598 +#endif
76599 +
76600 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76601 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76602 +
76603 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76604 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76605 +#else
76606 +#define SLAB_NO_SANITIZE 0x00000000UL
76607 +#endif
76608 +
76609 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76610 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76611 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76612 @@ -89,10 +103,13 @@
76613 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76614 * Both make kfree a no-op.
76615 */
76616 -#define ZERO_SIZE_PTR ((void *)16)
76617 +#define ZERO_SIZE_PTR \
76618 +({ \
76619 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76620 + (void *)(-MAX_ERRNO-1L); \
76621 +})
76622
76623 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76624 - (unsigned long)ZERO_SIZE_PTR)
76625 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76626
76627
76628 struct mem_cgroup;
76629 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76630 void kfree(const void *);
76631 void kzfree(const void *);
76632 size_t ksize(const void *);
76633 +const char *check_heap_object(const void *ptr, unsigned long n);
76634 +bool is_usercopy_object(const void *ptr);
76635
76636 /*
76637 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76638 @@ -164,7 +183,7 @@ struct kmem_cache {
76639 unsigned int align; /* Alignment as calculated */
76640 unsigned long flags; /* Active flags on the slab */
76641 const char *name; /* Slab name for sysfs */
76642 - int refcount; /* Use counter */
76643 + atomic_t refcount; /* Use counter */
76644 void (*ctor)(void *); /* Called on object slot creation */
76645 struct list_head list; /* List of all slab caches on the system */
76646 };
76647 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76648 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76649 #endif
76650
76651 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76652 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76653 +#endif
76654 +
76655 /*
76656 * Figure out which kmalloc slab an allocation of a certain size
76657 * belongs to.
76658 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76659 * 2 = 120 .. 192 bytes
76660 * n = 2^(n-1) .. 2^n -1
76661 */
76662 -static __always_inline int kmalloc_index(size_t size)
76663 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76664 {
76665 if (!size)
76666 return 0;
76667 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76668 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76669 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76670 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76671 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76672 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76673 #define kmalloc_track_caller(size, flags) \
76674 __kmalloc_track_caller(size, flags, _RET_IP_)
76675 #else
76676 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76677 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76678 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76679 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76680 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76681 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76682 #define kmalloc_node_track_caller(size, flags, node) \
76683 __kmalloc_node_track_caller(size, flags, node, \
76684 _RET_IP_)
76685 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76686 index cd40158..4e2f7af 100644
76687 --- a/include/linux/slab_def.h
76688 +++ b/include/linux/slab_def.h
76689 @@ -50,7 +50,7 @@ struct kmem_cache {
76690 /* 4) cache creation/removal */
76691 const char *name;
76692 struct list_head list;
76693 - int refcount;
76694 + atomic_t refcount;
76695 int object_size;
76696 int align;
76697
76698 @@ -66,10 +66,14 @@ struct kmem_cache {
76699 unsigned long node_allocs;
76700 unsigned long node_frees;
76701 unsigned long node_overflow;
76702 - atomic_t allochit;
76703 - atomic_t allocmiss;
76704 - atomic_t freehit;
76705 - atomic_t freemiss;
76706 + atomic_unchecked_t allochit;
76707 + atomic_unchecked_t allocmiss;
76708 + atomic_unchecked_t freehit;
76709 + atomic_unchecked_t freemiss;
76710 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76711 + atomic_unchecked_t sanitized;
76712 + atomic_unchecked_t not_sanitized;
76713 +#endif
76714
76715 /*
76716 * If debugging is enabled, then the allocator can add additional
76717 @@ -103,7 +107,7 @@ struct kmem_cache {
76718 };
76719
76720 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76721 -void *__kmalloc(size_t size, gfp_t flags);
76722 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76723
76724 #ifdef CONFIG_TRACING
76725 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76726 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76727 cachep = kmalloc_dma_caches[i];
76728 else
76729 #endif
76730 +
76731 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76732 + if (flags & GFP_USERCOPY)
76733 + cachep = kmalloc_usercopy_caches[i];
76734 + else
76735 +#endif
76736 +
76737 cachep = kmalloc_caches[i];
76738
76739 ret = kmem_cache_alloc_trace(cachep, flags, size);
76740 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76741 }
76742
76743 #ifdef CONFIG_NUMA
76744 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76745 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76746 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76747
76748 #ifdef CONFIG_TRACING
76749 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76750 cachep = kmalloc_dma_caches[i];
76751 else
76752 #endif
76753 +
76754 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76755 + if (flags & GFP_USERCOPY)
76756 + cachep = kmalloc_usercopy_caches[i];
76757 + else
76758 +#endif
76759 +
76760 cachep = kmalloc_caches[i];
76761
76762 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76763 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76764 index 095a5a4..4b82027 100644
76765 --- a/include/linux/slob_def.h
76766 +++ b/include/linux/slob_def.h
76767 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76768 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76769 }
76770
76771 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76772 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76773
76774 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76775 {
76776 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76777 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76778 }
76779
76780 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76781 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76782 {
76783 return kmalloc(size, flags);
76784 }
76785 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76786 index 027276f..092bfe8 100644
76787 --- a/include/linux/slub_def.h
76788 +++ b/include/linux/slub_def.h
76789 @@ -80,7 +80,7 @@ struct kmem_cache {
76790 struct kmem_cache_order_objects max;
76791 struct kmem_cache_order_objects min;
76792 gfp_t allocflags; /* gfp flags to use on each alloc */
76793 - int refcount; /* Refcount for slab cache destroy */
76794 + atomic_t refcount; /* Refcount for slab cache destroy */
76795 void (*ctor)(void *);
76796 int inuse; /* Offset to metadata */
76797 int align; /* Alignment */
76798 @@ -105,7 +105,7 @@ struct kmem_cache {
76799 };
76800
76801 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76802 -void *__kmalloc(size_t size, gfp_t flags);
76803 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76804
76805 static __always_inline void *
76806 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76807 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76808 }
76809 #endif
76810
76811 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76812 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76813 {
76814 unsigned int order = get_order(size);
76815 return kmalloc_order_trace(size, flags, order);
76816 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76817 }
76818
76819 #ifdef CONFIG_NUMA
76820 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76821 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76822 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76823
76824 #ifdef CONFIG_TRACING
76825 diff --git a/include/linux/smp.h b/include/linux/smp.h
76826 index c181399..09d7b92 100644
76827 --- a/include/linux/smp.h
76828 +++ b/include/linux/smp.h
76829 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76830 #endif
76831
76832 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76833 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76834 #define put_cpu() preempt_enable()
76835 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76836
76837 /*
76838 * Callback to arch code if there's nosmp or maxcpus=0 on the
76839 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76840 index 54f91d3..be2c379 100644
76841 --- a/include/linux/sock_diag.h
76842 +++ b/include/linux/sock_diag.h
76843 @@ -11,7 +11,7 @@ struct sock;
76844 struct sock_diag_handler {
76845 __u8 family;
76846 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76847 -};
76848 +} __do_const;
76849
76850 int sock_diag_register(const struct sock_diag_handler *h);
76851 void sock_diag_unregister(const struct sock_diag_handler *h);
76852 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76853 index 680f9a3..f13aeb0 100644
76854 --- a/include/linux/sonet.h
76855 +++ b/include/linux/sonet.h
76856 @@ -7,7 +7,7 @@
76857 #include <uapi/linux/sonet.h>
76858
76859 struct k_sonet_stats {
76860 -#define __HANDLE_ITEM(i) atomic_t i
76861 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76862 __SONET_ITEMS
76863 #undef __HANDLE_ITEM
76864 };
76865 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76866 index 07d8e53..dc934c9 100644
76867 --- a/include/linux/sunrpc/addr.h
76868 +++ b/include/linux/sunrpc/addr.h
76869 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76870 {
76871 switch (sap->sa_family) {
76872 case AF_INET:
76873 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76874 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76875 case AF_INET6:
76876 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76877 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76878 }
76879 return 0;
76880 }
76881 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76882 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76883 const struct sockaddr *src)
76884 {
76885 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76886 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76887 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76888
76889 dsin->sin_family = ssin->sin_family;
76890 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76891 if (sa->sa_family != AF_INET6)
76892 return 0;
76893
76894 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76895 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76896 }
76897
76898 #endif /* _LINUX_SUNRPC_ADDR_H */
76899 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76900 index bfe11be..12bc8c4 100644
76901 --- a/include/linux/sunrpc/clnt.h
76902 +++ b/include/linux/sunrpc/clnt.h
76903 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76904 unsigned int p_timer; /* Which RTT timer to use */
76905 u32 p_statidx; /* Which procedure to account */
76906 const char * p_name; /* name of procedure */
76907 -};
76908 +} __do_const;
76909
76910 #ifdef __KERNEL__
76911
76912 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76913 index 1f0216b..6a4fa50 100644
76914 --- a/include/linux/sunrpc/svc.h
76915 +++ b/include/linux/sunrpc/svc.h
76916 @@ -411,7 +411,7 @@ struct svc_procedure {
76917 unsigned int pc_count; /* call count */
76918 unsigned int pc_cachetype; /* cache info (NFS) */
76919 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76920 -};
76921 +} __do_const;
76922
76923 /*
76924 * Function prototypes.
76925 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76926 index 0b8e3e6..33e0a01 100644
76927 --- a/include/linux/sunrpc/svc_rdma.h
76928 +++ b/include/linux/sunrpc/svc_rdma.h
76929 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76930 extern unsigned int svcrdma_max_requests;
76931 extern unsigned int svcrdma_max_req_size;
76932
76933 -extern atomic_t rdma_stat_recv;
76934 -extern atomic_t rdma_stat_read;
76935 -extern atomic_t rdma_stat_write;
76936 -extern atomic_t rdma_stat_sq_starve;
76937 -extern atomic_t rdma_stat_rq_starve;
76938 -extern atomic_t rdma_stat_rq_poll;
76939 -extern atomic_t rdma_stat_rq_prod;
76940 -extern atomic_t rdma_stat_sq_poll;
76941 -extern atomic_t rdma_stat_sq_prod;
76942 +extern atomic_unchecked_t rdma_stat_recv;
76943 +extern atomic_unchecked_t rdma_stat_read;
76944 +extern atomic_unchecked_t rdma_stat_write;
76945 +extern atomic_unchecked_t rdma_stat_sq_starve;
76946 +extern atomic_unchecked_t rdma_stat_rq_starve;
76947 +extern atomic_unchecked_t rdma_stat_rq_poll;
76948 +extern atomic_unchecked_t rdma_stat_rq_prod;
76949 +extern atomic_unchecked_t rdma_stat_sq_poll;
76950 +extern atomic_unchecked_t rdma_stat_sq_prod;
76951
76952 #define RPCRDMA_VERSION 1
76953
76954 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
76955 index 8d71d65..f79586e 100644
76956 --- a/include/linux/sunrpc/svcauth.h
76957 +++ b/include/linux/sunrpc/svcauth.h
76958 @@ -120,7 +120,7 @@ struct auth_ops {
76959 int (*release)(struct svc_rqst *rq);
76960 void (*domain_release)(struct auth_domain *);
76961 int (*set_client)(struct svc_rqst *rq);
76962 -};
76963 +} __do_const;
76964
76965 #define SVC_GARBAGE 1
76966 #define SVC_SYSERR 2
76967 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
76968 index a5ffd32..0935dea 100644
76969 --- a/include/linux/swiotlb.h
76970 +++ b/include/linux/swiotlb.h
76971 @@ -60,7 +60,8 @@ extern void
76972
76973 extern void
76974 swiotlb_free_coherent(struct device *hwdev, size_t size,
76975 - void *vaddr, dma_addr_t dma_handle);
76976 + void *vaddr, dma_addr_t dma_handle,
76977 + struct dma_attrs *attrs);
76978
76979 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
76980 unsigned long offset, size_t size,
76981 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
76982 index 84662ec..5271947 100644
76983 --- a/include/linux/syscalls.h
76984 +++ b/include/linux/syscalls.h
76985 @@ -97,8 +97,14 @@ struct sigaltstack;
76986 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
76987
76988 #define __SC_DECL(t, a) t a
76989 +#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))
76990 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
76991 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
76992 +#define __SC_LONG(t, a) __typeof( \
76993 + __builtin_choose_expr( \
76994 + sizeof(t) > sizeof(int), \
76995 + (t) 0, \
76996 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
76997 + )) a
76998 #define __SC_CAST(t, a) (t) a
76999 #define __SC_ARGS(t, a) a
77000 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77001 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77002 asmlinkage long sys_fsync(unsigned int fd);
77003 asmlinkage long sys_fdatasync(unsigned int fd);
77004 asmlinkage long sys_bdflush(int func, long data);
77005 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77006 - char __user *type, unsigned long flags,
77007 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77008 + const char __user *type, unsigned long flags,
77009 void __user *data);
77010 -asmlinkage long sys_umount(char __user *name, int flags);
77011 -asmlinkage long sys_oldumount(char __user *name);
77012 +asmlinkage long sys_umount(const char __user *name, int flags);
77013 +asmlinkage long sys_oldumount(const char __user *name);
77014 asmlinkage long sys_truncate(const char __user *path, long length);
77015 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77016 asmlinkage long sys_stat(const char __user *filename,
77017 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77018 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77019 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77020 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77021 - struct sockaddr __user *, int);
77022 + struct sockaddr __user *, int) __intentional_overflow(0);
77023 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77024 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77025 unsigned int vlen, unsigned flags);
77026 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77027 index 27b3b0b..e093dd9 100644
77028 --- a/include/linux/syscore_ops.h
77029 +++ b/include/linux/syscore_ops.h
77030 @@ -16,7 +16,7 @@ struct syscore_ops {
77031 int (*suspend)(void);
77032 void (*resume)(void);
77033 void (*shutdown)(void);
77034 -};
77035 +} __do_const;
77036
77037 extern void register_syscore_ops(struct syscore_ops *ops);
77038 extern void unregister_syscore_ops(struct syscore_ops *ops);
77039 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77040 index 14a8ff2..af52bad 100644
77041 --- a/include/linux/sysctl.h
77042 +++ b/include/linux/sysctl.h
77043 @@ -34,13 +34,13 @@ struct ctl_table_root;
77044 struct ctl_table_header;
77045 struct ctl_dir;
77046
77047 -typedef struct ctl_table ctl_table;
77048 -
77049 typedef int proc_handler (struct ctl_table *ctl, int write,
77050 void __user *buffer, size_t *lenp, loff_t *ppos);
77051
77052 extern int proc_dostring(struct ctl_table *, int,
77053 void __user *, size_t *, loff_t *);
77054 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77055 + void __user *, size_t *, loff_t *);
77056 extern int proc_dointvec(struct ctl_table *, int,
77057 void __user *, size_t *, loff_t *);
77058 extern int proc_dointvec_minmax(struct ctl_table *, int,
77059 @@ -115,7 +115,9 @@ struct ctl_table
77060 struct ctl_table_poll *poll;
77061 void *extra1;
77062 void *extra2;
77063 -};
77064 +} __do_const;
77065 +typedef struct ctl_table __no_const ctl_table_no_const;
77066 +typedef struct ctl_table ctl_table;
77067
77068 struct ctl_node {
77069 struct rb_node node;
77070 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77071 index 9e8a9b5..753de68 100644
77072 --- a/include/linux/sysfs.h
77073 +++ b/include/linux/sysfs.h
77074 @@ -33,7 +33,8 @@ struct attribute {
77075 struct lock_class_key *key;
77076 struct lock_class_key skey;
77077 #endif
77078 -};
77079 +} __do_const;
77080 +typedef struct attribute __no_const attribute_no_const;
77081
77082 /**
77083 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77084 @@ -62,7 +63,8 @@ struct attribute_group {
77085 struct attribute *, int);
77086 struct attribute **attrs;
77087 struct bin_attribute **bin_attrs;
77088 -};
77089 +} __do_const;
77090 +typedef struct attribute_group __no_const attribute_group_no_const;
77091
77092 /**
77093 * Use these macros to make defining attributes easier. See include/linux/device.h
77094 @@ -123,7 +125,8 @@ struct bin_attribute {
77095 char *, loff_t, size_t);
77096 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77097 struct vm_area_struct *vma);
77098 -};
77099 +} __do_const;
77100 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77101
77102 /**
77103 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77104 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77105 index 7faf933..9b85a0c 100644
77106 --- a/include/linux/sysrq.h
77107 +++ b/include/linux/sysrq.h
77108 @@ -16,6 +16,7 @@
77109
77110 #include <linux/errno.h>
77111 #include <linux/types.h>
77112 +#include <linux/compiler.h>
77113
77114 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77115 #define SYSRQ_DEFAULT_ENABLE 1
77116 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77117 char *help_msg;
77118 char *action_msg;
77119 int enable_mask;
77120 -};
77121 +} __do_const;
77122
77123 #ifdef CONFIG_MAGIC_SYSRQ
77124
77125 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77126 index e7e0473..7989295 100644
77127 --- a/include/linux/thread_info.h
77128 +++ b/include/linux/thread_info.h
77129 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77130 #error "no set_restore_sigmask() provided and default one won't work"
77131 #endif
77132
77133 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77134 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77135 +{
77136 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77137 + if (!__builtin_constant_p(n))
77138 +#endif
77139 + __check_object_size(ptr, n, to_user);
77140 +}
77141 +
77142 #endif /* __KERNEL__ */
77143
77144 #endif /* _LINUX_THREAD_INFO_H */
77145 diff --git a/include/linux/tty.h b/include/linux/tty.h
77146 index 01ac30e..bf18a71 100644
77147 --- a/include/linux/tty.h
77148 +++ b/include/linux/tty.h
77149 @@ -194,7 +194,7 @@ struct tty_port {
77150 const struct tty_port_operations *ops; /* Port operations */
77151 spinlock_t lock; /* Lock protecting tty field */
77152 int blocked_open; /* Waiting to open */
77153 - int count; /* Usage count */
77154 + atomic_t count; /* Usage count */
77155 wait_queue_head_t open_wait; /* Open waiters */
77156 wait_queue_head_t close_wait; /* Close waiters */
77157 wait_queue_head_t delta_msr_wait; /* Modem status change */
77158 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77159 struct tty_struct *tty, struct file *filp);
77160 static inline int tty_port_users(struct tty_port *port)
77161 {
77162 - return port->count + port->blocked_open;
77163 + return atomic_read(&port->count) + port->blocked_open;
77164 }
77165
77166 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77167 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77168 index 756a609..b302dd6 100644
77169 --- a/include/linux/tty_driver.h
77170 +++ b/include/linux/tty_driver.h
77171 @@ -285,7 +285,7 @@ struct tty_operations {
77172 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77173 #endif
77174 const struct file_operations *proc_fops;
77175 -};
77176 +} __do_const;
77177
77178 struct tty_driver {
77179 int magic; /* magic number for this structure */
77180 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77181 index a1b0489..f02e17c 100644
77182 --- a/include/linux/tty_ldisc.h
77183 +++ b/include/linux/tty_ldisc.h
77184 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77185
77186 struct module *owner;
77187
77188 - int refcount;
77189 + atomic_t refcount;
77190 };
77191
77192 struct tty_ldisc {
77193 diff --git a/include/linux/types.h b/include/linux/types.h
77194 index 4d118ba..c3ee9bf 100644
77195 --- a/include/linux/types.h
77196 +++ b/include/linux/types.h
77197 @@ -176,10 +176,26 @@ typedef struct {
77198 int counter;
77199 } atomic_t;
77200
77201 +#ifdef CONFIG_PAX_REFCOUNT
77202 +typedef struct {
77203 + int counter;
77204 +} atomic_unchecked_t;
77205 +#else
77206 +typedef atomic_t atomic_unchecked_t;
77207 +#endif
77208 +
77209 #ifdef CONFIG_64BIT
77210 typedef struct {
77211 long counter;
77212 } atomic64_t;
77213 +
77214 +#ifdef CONFIG_PAX_REFCOUNT
77215 +typedef struct {
77216 + long counter;
77217 +} atomic64_unchecked_t;
77218 +#else
77219 +typedef atomic64_t atomic64_unchecked_t;
77220 +#endif
77221 #endif
77222
77223 struct list_head {
77224 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77225 index 5ca0951..ab496a5 100644
77226 --- a/include/linux/uaccess.h
77227 +++ b/include/linux/uaccess.h
77228 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77229 long ret; \
77230 mm_segment_t old_fs = get_fs(); \
77231 \
77232 - set_fs(KERNEL_DS); \
77233 pagefault_disable(); \
77234 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77235 - pagefault_enable(); \
77236 + set_fs(KERNEL_DS); \
77237 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77238 set_fs(old_fs); \
77239 + pagefault_enable(); \
77240 ret; \
77241 })
77242
77243 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77244 index 8e522cbc..aa8572d 100644
77245 --- a/include/linux/uidgid.h
77246 +++ b/include/linux/uidgid.h
77247 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77248
77249 #endif /* CONFIG_USER_NS */
77250
77251 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77252 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77253 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77254 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77255 +
77256 #endif /* _LINUX_UIDGID_H */
77257 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77258 index 99c1b4d..562e6f3 100644
77259 --- a/include/linux/unaligned/access_ok.h
77260 +++ b/include/linux/unaligned/access_ok.h
77261 @@ -4,34 +4,34 @@
77262 #include <linux/kernel.h>
77263 #include <asm/byteorder.h>
77264
77265 -static inline u16 get_unaligned_le16(const void *p)
77266 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77267 {
77268 - return le16_to_cpup((__le16 *)p);
77269 + return le16_to_cpup((const __le16 *)p);
77270 }
77271
77272 -static inline u32 get_unaligned_le32(const void *p)
77273 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77274 {
77275 - return le32_to_cpup((__le32 *)p);
77276 + return le32_to_cpup((const __le32 *)p);
77277 }
77278
77279 -static inline u64 get_unaligned_le64(const void *p)
77280 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77281 {
77282 - return le64_to_cpup((__le64 *)p);
77283 + return le64_to_cpup((const __le64 *)p);
77284 }
77285
77286 -static inline u16 get_unaligned_be16(const void *p)
77287 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77288 {
77289 - return be16_to_cpup((__be16 *)p);
77290 + return be16_to_cpup((const __be16 *)p);
77291 }
77292
77293 -static inline u32 get_unaligned_be32(const void *p)
77294 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77295 {
77296 - return be32_to_cpup((__be32 *)p);
77297 + return be32_to_cpup((const __be32 *)p);
77298 }
77299
77300 -static inline u64 get_unaligned_be64(const void *p)
77301 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77302 {
77303 - return be64_to_cpup((__be64 *)p);
77304 + return be64_to_cpup((const __be64 *)p);
77305 }
77306
77307 static inline void put_unaligned_le16(u16 val, void *p)
77308 diff --git a/include/linux/usb.h b/include/linux/usb.h
77309 index 0eec268..4496526 100644
77310 --- a/include/linux/usb.h
77311 +++ b/include/linux/usb.h
77312 @@ -560,7 +560,7 @@ struct usb_device {
77313 int maxchild;
77314
77315 u32 quirks;
77316 - atomic_t urbnum;
77317 + atomic_unchecked_t urbnum;
77318
77319 unsigned long active_duration;
77320
77321 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77322
77323 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77324 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77325 - void *data, __u16 size, int timeout);
77326 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77327 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77328 void *data, int len, int *actual_length, int timeout);
77329 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77330 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77331 index e452ba6..78f8e80 100644
77332 --- a/include/linux/usb/renesas_usbhs.h
77333 +++ b/include/linux/usb/renesas_usbhs.h
77334 @@ -39,7 +39,7 @@ enum {
77335 */
77336 struct renesas_usbhs_driver_callback {
77337 int (*notify_hotplug)(struct platform_device *pdev);
77338 -};
77339 +} __no_const;
77340
77341 /*
77342 * callback functions for platform
77343 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77344 index 6f8fbcf..8259001 100644
77345 --- a/include/linux/vermagic.h
77346 +++ b/include/linux/vermagic.h
77347 @@ -25,9 +25,35 @@
77348 #define MODULE_ARCH_VERMAGIC ""
77349 #endif
77350
77351 +#ifdef CONFIG_PAX_REFCOUNT
77352 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77353 +#else
77354 +#define MODULE_PAX_REFCOUNT ""
77355 +#endif
77356 +
77357 +#ifdef CONSTIFY_PLUGIN
77358 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77359 +#else
77360 +#define MODULE_CONSTIFY_PLUGIN ""
77361 +#endif
77362 +
77363 +#ifdef STACKLEAK_PLUGIN
77364 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77365 +#else
77366 +#define MODULE_STACKLEAK_PLUGIN ""
77367 +#endif
77368 +
77369 +#ifdef CONFIG_GRKERNSEC
77370 +#define MODULE_GRSEC "GRSEC "
77371 +#else
77372 +#define MODULE_GRSEC ""
77373 +#endif
77374 +
77375 #define VERMAGIC_STRING \
77376 UTS_RELEASE " " \
77377 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77378 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77379 - MODULE_ARCH_VERMAGIC
77380 + MODULE_ARCH_VERMAGIC \
77381 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77382 + MODULE_GRSEC
77383
77384 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77385 index 4b8a891..c20e936 100644
77386 --- a/include/linux/vmalloc.h
77387 +++ b/include/linux/vmalloc.h
77388 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77389 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77390 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77391 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77392 +
77393 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77394 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77395 +#endif
77396 +
77397 /* bits [20..32] reserved for arch specific ioremap internals */
77398
77399 /*
77400 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77401 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77402 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77403 unsigned long start, unsigned long end, gfp_t gfp_mask,
77404 - pgprot_t prot, int node, const void *caller);
77405 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77406 extern void vfree(const void *addr);
77407
77408 extern void *vmap(struct page **pages, unsigned int count,
77409 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77410 extern void free_vm_area(struct vm_struct *area);
77411
77412 /* for /dev/kmem */
77413 -extern long vread(char *buf, char *addr, unsigned long count);
77414 -extern long vwrite(char *buf, char *addr, unsigned long count);
77415 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77416 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77417
77418 /*
77419 * Internals. Dont't use..
77420 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77421 index c586679..f06b389 100644
77422 --- a/include/linux/vmstat.h
77423 +++ b/include/linux/vmstat.h
77424 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77425 /*
77426 * Zone based page accounting with per cpu differentials.
77427 */
77428 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77429 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77430
77431 static inline void zone_page_state_add(long x, struct zone *zone,
77432 enum zone_stat_item item)
77433 {
77434 - atomic_long_add(x, &zone->vm_stat[item]);
77435 - atomic_long_add(x, &vm_stat[item]);
77436 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77437 + atomic_long_add_unchecked(x, &vm_stat[item]);
77438 }
77439
77440 static inline unsigned long global_page_state(enum zone_stat_item item)
77441 {
77442 - long x = atomic_long_read(&vm_stat[item]);
77443 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77444 #ifdef CONFIG_SMP
77445 if (x < 0)
77446 x = 0;
77447 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77448 static inline unsigned long zone_page_state(struct zone *zone,
77449 enum zone_stat_item item)
77450 {
77451 - long x = atomic_long_read(&zone->vm_stat[item]);
77452 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77453 #ifdef CONFIG_SMP
77454 if (x < 0)
77455 x = 0;
77456 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77457 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77458 enum zone_stat_item item)
77459 {
77460 - long x = atomic_long_read(&zone->vm_stat[item]);
77461 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77462
77463 #ifdef CONFIG_SMP
77464 int cpu;
77465 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77466
77467 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77468 {
77469 - atomic_long_inc(&zone->vm_stat[item]);
77470 - atomic_long_inc(&vm_stat[item]);
77471 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77472 + atomic_long_inc_unchecked(&vm_stat[item]);
77473 }
77474
77475 static inline void __inc_zone_page_state(struct page *page,
77476 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77477
77478 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77479 {
77480 - atomic_long_dec(&zone->vm_stat[item]);
77481 - atomic_long_dec(&vm_stat[item]);
77482 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77483 + atomic_long_dec_unchecked(&vm_stat[item]);
77484 }
77485
77486 static inline void __dec_zone_page_state(struct page *page,
77487 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77488 index fdbafc6..49dfe4f 100644
77489 --- a/include/linux/xattr.h
77490 +++ b/include/linux/xattr.h
77491 @@ -28,7 +28,7 @@ struct xattr_handler {
77492 size_t size, int handler_flags);
77493 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77494 size_t size, int flags, int handler_flags);
77495 -};
77496 +} __do_const;
77497
77498 struct xattr {
77499 char *name;
77500 @@ -37,6 +37,9 @@ struct xattr {
77501 };
77502
77503 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77504 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77505 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77506 +#endif
77507 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77508 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77509 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77510 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77511 index 9c5a6b4..09c9438 100644
77512 --- a/include/linux/zlib.h
77513 +++ b/include/linux/zlib.h
77514 @@ -31,6 +31,7 @@
77515 #define _ZLIB_H
77516
77517 #include <linux/zconf.h>
77518 +#include <linux/compiler.h>
77519
77520 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77521 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77522 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77523
77524 /* basic functions */
77525
77526 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77527 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77528 /*
77529 Returns the number of bytes that needs to be allocated for a per-
77530 stream workspace with the specified parameters. A pointer to this
77531 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77532 index c768c9f..bdcaa5a 100644
77533 --- a/include/media/v4l2-dev.h
77534 +++ b/include/media/v4l2-dev.h
77535 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77536 int (*mmap) (struct file *, struct vm_area_struct *);
77537 int (*open) (struct file *);
77538 int (*release) (struct file *);
77539 -};
77540 +} __do_const;
77541
77542 /*
77543 * Newer version of video_device, handled by videodev2.c
77544 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77545 index c9b1593..a572459 100644
77546 --- a/include/media/v4l2-device.h
77547 +++ b/include/media/v4l2-device.h
77548 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77549 this function returns 0. If the name ends with a digit (e.g. cx18),
77550 then the name will be set to cx18-0 since cx180 looks really odd. */
77551 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77552 - atomic_t *instance);
77553 + atomic_unchecked_t *instance);
77554
77555 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77556 Since the parent disappears this ensures that v4l2_dev doesn't have an
77557 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77558 index d9fa68f..45c88d1 100644
77559 --- a/include/net/9p/transport.h
77560 +++ b/include/net/9p/transport.h
77561 @@ -63,7 +63,7 @@ struct p9_trans_module {
77562 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77563 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77564 char *, char *, int , int, int, int);
77565 -};
77566 +} __do_const;
77567
77568 void v9fs_register_trans(struct p9_trans_module *m);
77569 void v9fs_unregister_trans(struct p9_trans_module *m);
77570 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77571 index 1a966af..2767cf6 100644
77572 --- a/include/net/bluetooth/l2cap.h
77573 +++ b/include/net/bluetooth/l2cap.h
77574 @@ -551,7 +551,7 @@ struct l2cap_ops {
77575 void (*defer) (struct l2cap_chan *chan);
77576 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77577 unsigned long len, int nb);
77578 -};
77579 +} __do_const;
77580
77581 struct l2cap_conn {
77582 struct hci_conn *hcon;
77583 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77584 index f2ae33d..c457cf0 100644
77585 --- a/include/net/caif/cfctrl.h
77586 +++ b/include/net/caif/cfctrl.h
77587 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77588 void (*radioset_rsp)(void);
77589 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77590 struct cflayer *client_layer);
77591 -};
77592 +} __no_const;
77593
77594 /* Link Setup Parameters for CAIF-Links. */
77595 struct cfctrl_link_param {
77596 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77597 struct cfctrl {
77598 struct cfsrvl serv;
77599 struct cfctrl_rsp res;
77600 - atomic_t req_seq_no;
77601 - atomic_t rsp_seq_no;
77602 + atomic_unchecked_t req_seq_no;
77603 + atomic_unchecked_t rsp_seq_no;
77604 struct list_head list;
77605 /* Protects from simultaneous access to first_req list */
77606 spinlock_t info_list_lock;
77607 diff --git a/include/net/flow.h b/include/net/flow.h
77608 index 628e11b..4c475df 100644
77609 --- a/include/net/flow.h
77610 +++ b/include/net/flow.h
77611 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77612
77613 extern void flow_cache_flush(void);
77614 extern void flow_cache_flush_deferred(void);
77615 -extern atomic_t flow_cache_genid;
77616 +extern atomic_unchecked_t flow_cache_genid;
77617
77618 #endif
77619 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77620 index 8e0b6c8..73cf605 100644
77621 --- a/include/net/genetlink.h
77622 +++ b/include/net/genetlink.h
77623 @@ -120,7 +120,7 @@ struct genl_ops {
77624 struct netlink_callback *cb);
77625 int (*done)(struct netlink_callback *cb);
77626 struct list_head ops_list;
77627 -};
77628 +} __do_const;
77629
77630 extern int __genl_register_family(struct genl_family *family);
77631
77632 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77633 index 734d9b5..48a9a4b 100644
77634 --- a/include/net/gro_cells.h
77635 +++ b/include/net/gro_cells.h
77636 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77637 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77638
77639 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77640 - atomic_long_inc(&dev->rx_dropped);
77641 + atomic_long_inc_unchecked(&dev->rx_dropped);
77642 kfree_skb(skb);
77643 return;
77644 }
77645 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77646 index de2c785..0588a6b 100644
77647 --- a/include/net/inet_connection_sock.h
77648 +++ b/include/net/inet_connection_sock.h
77649 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77650 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77651 int (*bind_conflict)(const struct sock *sk,
77652 const struct inet_bind_bucket *tb, bool relax);
77653 -};
77654 +} __do_const;
77655
77656 /** inet_connection_sock - INET connection oriented sock
77657 *
77658 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77659 index 53f464d..0bd0b49 100644
77660 --- a/include/net/inetpeer.h
77661 +++ b/include/net/inetpeer.h
77662 @@ -47,8 +47,8 @@ struct inet_peer {
77663 */
77664 union {
77665 struct {
77666 - atomic_t rid; /* Frag reception counter */
77667 - atomic_t ip_id_count; /* IP ID for the next packet */
77668 + atomic_unchecked_t rid; /* Frag reception counter */
77669 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77670 };
77671 struct rcu_head rcu;
77672 struct inet_peer *gc_next;
77673 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77674 /* can be called with or without local BH being disabled */
77675 static inline int inet_getid(struct inet_peer *p, int more)
77676 {
77677 - int old, new;
77678 + int id;
77679 more++;
77680 inet_peer_refcheck(p);
77681 - do {
77682 - old = atomic_read(&p->ip_id_count);
77683 - new = old + more;
77684 - if (!new)
77685 - new = 1;
77686 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77687 - return new;
77688 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77689 + if (!id)
77690 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77691 + return id;
77692 }
77693
77694 #endif /* _NET_INETPEER_H */
77695 diff --git a/include/net/ip.h b/include/net/ip.h
77696 index a68f838..74518ab 100644
77697 --- a/include/net/ip.h
77698 +++ b/include/net/ip.h
77699 @@ -202,7 +202,7 @@ extern struct local_ports {
77700 } sysctl_local_ports;
77701 extern void inet_get_local_port_range(int *low, int *high);
77702
77703 -extern unsigned long *sysctl_local_reserved_ports;
77704 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77705 static inline int inet_is_reserved_local_port(int port)
77706 {
77707 return test_bit(port, sysctl_local_reserved_ports);
77708 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77709 index cbf2be3..3683f6d 100644
77710 --- a/include/net/ip_fib.h
77711 +++ b/include/net/ip_fib.h
77712 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77713
77714 #define FIB_RES_SADDR(net, res) \
77715 ((FIB_RES_NH(res).nh_saddr_genid == \
77716 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77717 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77718 FIB_RES_NH(res).nh_saddr : \
77719 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77720 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77721 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77722 index f0d70f0..185f15b 100644
77723 --- a/include/net/ip_vs.h
77724 +++ b/include/net/ip_vs.h
77725 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77726 struct ip_vs_conn *control; /* Master control connection */
77727 atomic_t n_control; /* Number of controlled ones */
77728 struct ip_vs_dest *dest; /* real server */
77729 - atomic_t in_pkts; /* incoming packet counter */
77730 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77731
77732 /* packet transmitter for different forwarding methods. If it
77733 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77734 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77735 __be16 port; /* port number of the server */
77736 union nf_inet_addr addr; /* IP address of the server */
77737 volatile unsigned int flags; /* dest status flags */
77738 - atomic_t conn_flags; /* flags to copy to conn */
77739 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77740 atomic_t weight; /* server weight */
77741
77742 atomic_t refcnt; /* reference counter */
77743 @@ -993,11 +993,11 @@ struct netns_ipvs {
77744 /* ip_vs_lblc */
77745 int sysctl_lblc_expiration;
77746 struct ctl_table_header *lblc_ctl_header;
77747 - struct ctl_table *lblc_ctl_table;
77748 + ctl_table_no_const *lblc_ctl_table;
77749 /* ip_vs_lblcr */
77750 int sysctl_lblcr_expiration;
77751 struct ctl_table_header *lblcr_ctl_header;
77752 - struct ctl_table *lblcr_ctl_table;
77753 + ctl_table_no_const *lblcr_ctl_table;
77754 /* ip_vs_est */
77755 struct list_head est_list; /* estimator list */
77756 spinlock_t est_lock;
77757 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77758 index 80ffde3..968b0f4 100644
77759 --- a/include/net/irda/ircomm_tty.h
77760 +++ b/include/net/irda/ircomm_tty.h
77761 @@ -35,6 +35,7 @@
77762 #include <linux/termios.h>
77763 #include <linux/timer.h>
77764 #include <linux/tty.h> /* struct tty_struct */
77765 +#include <asm/local.h>
77766
77767 #include <net/irda/irias_object.h>
77768 #include <net/irda/ircomm_core.h>
77769 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77770 index 714cc9a..ea05f3e 100644
77771 --- a/include/net/iucv/af_iucv.h
77772 +++ b/include/net/iucv/af_iucv.h
77773 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77774 struct iucv_sock_list {
77775 struct hlist_head head;
77776 rwlock_t lock;
77777 - atomic_t autobind_name;
77778 + atomic_unchecked_t autobind_name;
77779 };
77780
77781 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77782 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77783 index df83f69..9b640b8 100644
77784 --- a/include/net/llc_c_ac.h
77785 +++ b/include/net/llc_c_ac.h
77786 @@ -87,7 +87,7 @@
77787 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77788 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77789
77790 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77791 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77792
77793 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77794 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77795 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77796 index 6ca3113..f8026dd 100644
77797 --- a/include/net/llc_c_ev.h
77798 +++ b/include/net/llc_c_ev.h
77799 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77800 return (struct llc_conn_state_ev *)skb->cb;
77801 }
77802
77803 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77804 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77805 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77806 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77807
77808 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77809 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77810 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77811 index 0e79cfb..f46db31 100644
77812 --- a/include/net/llc_c_st.h
77813 +++ b/include/net/llc_c_st.h
77814 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77815 u8 next_state;
77816 llc_conn_ev_qfyr_t *ev_qualifiers;
77817 llc_conn_action_t *ev_actions;
77818 -};
77819 +} __do_const;
77820
77821 struct llc_conn_state {
77822 u8 current_state;
77823 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77824 index 37a3bbd..55a4241 100644
77825 --- a/include/net/llc_s_ac.h
77826 +++ b/include/net/llc_s_ac.h
77827 @@ -23,7 +23,7 @@
77828 #define SAP_ACT_TEST_IND 9
77829
77830 /* All action functions must look like this */
77831 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77832 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77833
77834 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77835 struct sk_buff *skb);
77836 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77837 index 567c681..cd73ac0 100644
77838 --- a/include/net/llc_s_st.h
77839 +++ b/include/net/llc_s_st.h
77840 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77841 llc_sap_ev_t ev;
77842 u8 next_state;
77843 llc_sap_action_t *ev_actions;
77844 -};
77845 +} __do_const;
77846
77847 struct llc_sap_state {
77848 u8 curr_state;
77849 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77850 index 551ba6a..11c99c1 100644
77851 --- a/include/net/mac80211.h
77852 +++ b/include/net/mac80211.h
77853 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77854 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77855 struct dentry *dir);
77856 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77857 -};
77858 +} __do_const;
77859
77860 static inline int rate_supported(struct ieee80211_sta *sta,
77861 enum ieee80211_band band,
77862 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77863 index 7e748ad..5c6229b 100644
77864 --- a/include/net/neighbour.h
77865 +++ b/include/net/neighbour.h
77866 @@ -123,7 +123,7 @@ struct neigh_ops {
77867 void (*error_report)(struct neighbour *, struct sk_buff *);
77868 int (*output)(struct neighbour *, struct sk_buff *);
77869 int (*connected_output)(struct neighbour *, struct sk_buff *);
77870 -};
77871 +} __do_const;
77872
77873 struct pneigh_entry {
77874 struct pneigh_entry *next;
77875 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77876 index 84e37b1..8eba19a 100644
77877 --- a/include/net/net_namespace.h
77878 +++ b/include/net/net_namespace.h
77879 @@ -119,8 +119,8 @@ struct net {
77880 struct netns_ipvs *ipvs;
77881 #endif
77882 struct sock *diag_nlsk;
77883 - atomic_t rt_genid;
77884 - atomic_t fnhe_genid;
77885 + atomic_unchecked_t rt_genid;
77886 + atomic_unchecked_t fnhe_genid;
77887 };
77888
77889 /*
77890 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77891 #define __net_init __init
77892 #define __net_exit __exit_refok
77893 #define __net_initdata __initdata
77894 +#ifdef CONSTIFY_PLUGIN
77895 #define __net_initconst __initconst
77896 +#else
77897 +#define __net_initconst __initdata
77898 +#endif
77899 #endif
77900
77901 struct pernet_operations {
77902 @@ -287,7 +291,7 @@ struct pernet_operations {
77903 void (*exit_batch)(struct list_head *net_exit_list);
77904 int *id;
77905 size_t size;
77906 -};
77907 +} __do_const;
77908
77909 /*
77910 * Use these carefully. If you implement a network device and it
77911 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77912
77913 static inline int rt_genid(struct net *net)
77914 {
77915 - return atomic_read(&net->rt_genid);
77916 + return atomic_read_unchecked(&net->rt_genid);
77917 }
77918
77919 static inline void rt_genid_bump(struct net *net)
77920 {
77921 - atomic_inc(&net->rt_genid);
77922 + atomic_inc_unchecked(&net->rt_genid);
77923 }
77924
77925 static inline int fnhe_genid(struct net *net)
77926 {
77927 - return atomic_read(&net->fnhe_genid);
77928 + return atomic_read_unchecked(&net->fnhe_genid);
77929 }
77930
77931 static inline void fnhe_genid_bump(struct net *net)
77932 {
77933 - atomic_inc(&net->fnhe_genid);
77934 + atomic_inc_unchecked(&net->fnhe_genid);
77935 }
77936
77937 #endif /* __NET_NET_NAMESPACE_H */
77938 diff --git a/include/net/netdma.h b/include/net/netdma.h
77939 index 8ba8ce2..99b7fff 100644
77940 --- a/include/net/netdma.h
77941 +++ b/include/net/netdma.h
77942 @@ -24,7 +24,7 @@
77943 #include <linux/dmaengine.h>
77944 #include <linux/skbuff.h>
77945
77946 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77947 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77948 struct sk_buff *skb, int offset, struct iovec *to,
77949 size_t len, struct dma_pinned_list *pinned_list);
77950
77951 diff --git a/include/net/netlink.h b/include/net/netlink.h
77952 index 9690b0f..87aded7 100644
77953 --- a/include/net/netlink.h
77954 +++ b/include/net/netlink.h
77955 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
77956 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
77957 {
77958 if (mark)
77959 - skb_trim(skb, (unsigned char *) mark - skb->data);
77960 + skb_trim(skb, (const unsigned char *) mark - skb->data);
77961 }
77962
77963 /**
77964 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
77965 index c9c0c53..53f24c3 100644
77966 --- a/include/net/netns/conntrack.h
77967 +++ b/include/net/netns/conntrack.h
77968 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
77969 struct nf_proto_net {
77970 #ifdef CONFIG_SYSCTL
77971 struct ctl_table_header *ctl_table_header;
77972 - struct ctl_table *ctl_table;
77973 + ctl_table_no_const *ctl_table;
77974 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
77975 struct ctl_table_header *ctl_compat_header;
77976 - struct ctl_table *ctl_compat_table;
77977 + ctl_table_no_const *ctl_compat_table;
77978 #endif
77979 #endif
77980 unsigned int users;
77981 @@ -58,7 +58,7 @@ struct nf_ip_net {
77982 struct nf_icmp_net icmpv6;
77983 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
77984 struct ctl_table_header *ctl_table_header;
77985 - struct ctl_table *ctl_table;
77986 + ctl_table_no_const *ctl_table;
77987 #endif
77988 };
77989
77990 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
77991 index 2ba9de8..47bd6c7 100644
77992 --- a/include/net/netns/ipv4.h
77993 +++ b/include/net/netns/ipv4.h
77994 @@ -67,7 +67,7 @@ struct netns_ipv4 {
77995 kgid_t sysctl_ping_group_range[2];
77996 long sysctl_tcp_mem[3];
77997
77998 - atomic_t dev_addr_genid;
77999 + atomic_unchecked_t dev_addr_genid;
78000
78001 #ifdef CONFIG_IP_MROUTE
78002 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78003 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78004 index 005e2c2..023d340 100644
78005 --- a/include/net/netns/ipv6.h
78006 +++ b/include/net/netns/ipv6.h
78007 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78008 struct fib_rules_ops *mr6_rules_ops;
78009 #endif
78010 #endif
78011 - atomic_t dev_addr_genid;
78012 + atomic_unchecked_t dev_addr_genid;
78013 };
78014
78015 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78016 diff --git a/include/net/ping.h b/include/net/ping.h
78017 index 5db0224..0d65365 100644
78018 --- a/include/net/ping.h
78019 +++ b/include/net/ping.h
78020 @@ -55,7 +55,7 @@ struct ping_iter_state {
78021 extern struct proto ping_prot;
78022 extern struct ping_table ping_table;
78023 #if IS_ENABLED(CONFIG_IPV6)
78024 -extern struct pingv6_ops pingv6_ops;
78025 +extern struct pingv6_ops *pingv6_ops;
78026 #endif
78027
78028 struct pingfakehdr {
78029 diff --git a/include/net/protocol.h b/include/net/protocol.h
78030 index 047c047..b9dad15 100644
78031 --- a/include/net/protocol.h
78032 +++ b/include/net/protocol.h
78033 @@ -44,7 +44,7 @@ struct net_protocol {
78034 void (*err_handler)(struct sk_buff *skb, u32 info);
78035 unsigned int no_policy:1,
78036 netns_ok:1;
78037 -};
78038 +} __do_const;
78039
78040 #if IS_ENABLED(CONFIG_IPV6)
78041 struct inet6_protocol {
78042 @@ -57,7 +57,7 @@ struct inet6_protocol {
78043 u8 type, u8 code, int offset,
78044 __be32 info);
78045 unsigned int flags; /* INET6_PROTO_xxx */
78046 -};
78047 +} __do_const;
78048
78049 #define INET6_PROTO_NOPOLICY 0x1
78050 #define INET6_PROTO_FINAL 0x2
78051 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78052 index 7026648..584cc8c 100644
78053 --- a/include/net/rtnetlink.h
78054 +++ b/include/net/rtnetlink.h
78055 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78056 const struct net_device *dev);
78057 unsigned int (*get_num_tx_queues)(void);
78058 unsigned int (*get_num_rx_queues)(void);
78059 -};
78060 +} __do_const;
78061
78062 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78063 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78064 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78065 index 2a82d13..62a31c2 100644
78066 --- a/include/net/sctp/sm.h
78067 +++ b/include/net/sctp/sm.h
78068 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78069 typedef struct {
78070 sctp_state_fn_t *fn;
78071 const char *name;
78072 -} sctp_sm_table_entry_t;
78073 +} __do_const sctp_sm_table_entry_t;
78074
78075 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78076 * currently in use.
78077 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78078 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78079
78080 /* Extern declarations for major data structures. */
78081 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78082 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78083
78084
78085 /* Get the size of a DATA chunk payload. */
78086 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78087 index e745c92..3641448 100644
78088 --- a/include/net/sctp/structs.h
78089 +++ b/include/net/sctp/structs.h
78090 @@ -516,7 +516,7 @@ struct sctp_pf {
78091 struct sctp_association *asoc);
78092 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78093 struct sctp_af *af;
78094 -};
78095 +} __do_const;
78096
78097
78098 /* Structure to track chunk fragments that have been acked, but peer
78099 diff --git a/include/net/sock.h b/include/net/sock.h
78100 index 31d5cfb..9ee0602 100644
78101 --- a/include/net/sock.h
78102 +++ b/include/net/sock.h
78103 @@ -331,7 +331,7 @@ struct sock {
78104 unsigned int sk_napi_id;
78105 unsigned int sk_ll_usec;
78106 #endif
78107 - atomic_t sk_drops;
78108 + atomic_unchecked_t sk_drops;
78109 int sk_rcvbuf;
78110
78111 struct sk_filter __rcu *sk_filter;
78112 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78113 }
78114
78115 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78116 - char __user *from, char *to,
78117 + char __user *from, unsigned char *to,
78118 int copy, int offset)
78119 {
78120 if (skb->ip_summed == CHECKSUM_NONE) {
78121 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78122 }
78123 }
78124
78125 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78126 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78127
78128 /**
78129 * sk_page_frag - return an appropriate page_frag
78130 diff --git a/include/net/tcp.h b/include/net/tcp.h
78131 index d198005..c974a393 100644
78132 --- a/include/net/tcp.h
78133 +++ b/include/net/tcp.h
78134 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78135 extern void tcp_xmit_retransmit_queue(struct sock *);
78136 extern void tcp_simple_retransmit(struct sock *);
78137 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78138 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78139 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78140
78141 extern void tcp_send_probe0(struct sock *);
78142 extern void tcp_send_partial(struct sock *);
78143 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
78144 struct inet6_skb_parm h6;
78145 #endif
78146 } header; /* For incoming frames */
78147 - __u32 seq; /* Starting sequence number */
78148 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78149 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78150 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78151 __u32 when; /* used to compute rtt's */
78152 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78153
78154 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
78155
78156 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78157 /* 1 byte hole */
78158 - __u32 ack_seq; /* Sequence number ACK'd */
78159 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78160 };
78161
78162 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78163 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78164 index e823786..53b0608 100644
78165 --- a/include/net/xfrm.h
78166 +++ b/include/net/xfrm.h
78167 @@ -287,7 +287,6 @@ struct xfrm_dst;
78168 struct xfrm_policy_afinfo {
78169 unsigned short family;
78170 struct dst_ops *dst_ops;
78171 - void (*garbage_collect)(struct net *net);
78172 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78173 const xfrm_address_t *saddr,
78174 const xfrm_address_t *daddr);
78175 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78176 struct net_device *dev,
78177 const struct flowi *fl);
78178 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78179 -};
78180 +} __do_const;
78181
78182 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78183 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78184 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78185 int (*transport_finish)(struct sk_buff *skb,
78186 int async);
78187 void (*local_error)(struct sk_buff *skb, u32 mtu);
78188 -};
78189 +} __do_const;
78190
78191 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78192 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78193 @@ -427,7 +426,7 @@ struct xfrm_mode {
78194 struct module *owner;
78195 unsigned int encap;
78196 int flags;
78197 -};
78198 +} __do_const;
78199
78200 /* Flags for xfrm_mode. */
78201 enum {
78202 @@ -524,7 +523,7 @@ struct xfrm_policy {
78203 struct timer_list timer;
78204
78205 struct flow_cache_object flo;
78206 - atomic_t genid;
78207 + atomic_unchecked_t genid;
78208 u32 priority;
78209 u32 index;
78210 struct xfrm_mark mark;
78211 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78212 }
78213
78214 extern void xfrm_garbage_collect(struct net *net);
78215 +extern void xfrm_garbage_collect_deferred(struct net *net);
78216
78217 #else
78218
78219 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78220 static inline void xfrm_garbage_collect(struct net *net)
78221 {
78222 }
78223 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78224 +{
78225 +}
78226 #endif
78227
78228 static __inline__
78229 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78230 index 1a046b1..ee0bef0 100644
78231 --- a/include/rdma/iw_cm.h
78232 +++ b/include/rdma/iw_cm.h
78233 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78234 int backlog);
78235
78236 int (*destroy_listen)(struct iw_cm_id *cm_id);
78237 -};
78238 +} __no_const;
78239
78240 /**
78241 * iw_create_cm_id - Create an IW CM identifier.
78242 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78243 index e1379b4..67eafbe 100644
78244 --- a/include/scsi/libfc.h
78245 +++ b/include/scsi/libfc.h
78246 @@ -762,6 +762,7 @@ struct libfc_function_template {
78247 */
78248 void (*disc_stop_final) (struct fc_lport *);
78249 };
78250 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78251
78252 /**
78253 * struct fc_disc - Discovery context
78254 @@ -866,7 +867,7 @@ struct fc_lport {
78255 struct fc_vport *vport;
78256
78257 /* Operational Information */
78258 - struct libfc_function_template tt;
78259 + libfc_function_template_no_const tt;
78260 u8 link_up;
78261 u8 qfull;
78262 enum fc_lport_state state;
78263 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78264 index a44954c..5da04b2 100644
78265 --- a/include/scsi/scsi_device.h
78266 +++ b/include/scsi/scsi_device.h
78267 @@ -172,9 +172,9 @@ struct scsi_device {
78268 unsigned int max_device_blocked; /* what device_blocked counts down from */
78269 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78270
78271 - atomic_t iorequest_cnt;
78272 - atomic_t iodone_cnt;
78273 - atomic_t ioerr_cnt;
78274 + atomic_unchecked_t iorequest_cnt;
78275 + atomic_unchecked_t iodone_cnt;
78276 + atomic_unchecked_t ioerr_cnt;
78277
78278 struct device sdev_gendev,
78279 sdev_dev;
78280 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78281 index b797e8f..8e2c3aa 100644
78282 --- a/include/scsi/scsi_transport_fc.h
78283 +++ b/include/scsi/scsi_transport_fc.h
78284 @@ -751,7 +751,8 @@ struct fc_function_template {
78285 unsigned long show_host_system_hostname:1;
78286
78287 unsigned long disable_target_scan:1;
78288 -};
78289 +} __do_const;
78290 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78291
78292
78293 /**
78294 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78295 index 9031a26..750d592 100644
78296 --- a/include/sound/compress_driver.h
78297 +++ b/include/sound/compress_driver.h
78298 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78299 struct snd_compr_caps *caps);
78300 int (*get_codec_caps) (struct snd_compr_stream *stream,
78301 struct snd_compr_codec_caps *codec);
78302 -};
78303 +} __no_const;
78304
78305 /**
78306 * struct snd_compr: Compressed device
78307 diff --git a/include/sound/soc.h b/include/sound/soc.h
78308 index 6eabee7..58afb50 100644
78309 --- a/include/sound/soc.h
78310 +++ b/include/sound/soc.h
78311 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78312 /* probe ordering - for components with runtime dependencies */
78313 int probe_order;
78314 int remove_order;
78315 -};
78316 +} __do_const;
78317
78318 /* SoC platform interface */
78319 struct snd_soc_platform_driver {
78320 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78321 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78322 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78323 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78324 -};
78325 +} __do_const;
78326
78327 struct snd_soc_platform {
78328 const char *name;
78329 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78330 index e34fc90..ecefa2c 100644
78331 --- a/include/target/target_core_base.h
78332 +++ b/include/target/target_core_base.h
78333 @@ -643,7 +643,7 @@ struct se_device {
78334 spinlock_t stats_lock;
78335 /* Active commands on this virtual SE device */
78336 atomic_t simple_cmds;
78337 - atomic_t dev_ordered_id;
78338 + atomic_unchecked_t dev_ordered_id;
78339 atomic_t dev_ordered_sync;
78340 atomic_t dev_qf_count;
78341 int export_count;
78342 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78343 new file mode 100644
78344 index 0000000..fb634b7
78345 --- /dev/null
78346 +++ b/include/trace/events/fs.h
78347 @@ -0,0 +1,53 @@
78348 +#undef TRACE_SYSTEM
78349 +#define TRACE_SYSTEM fs
78350 +
78351 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78352 +#define _TRACE_FS_H
78353 +
78354 +#include <linux/fs.h>
78355 +#include <linux/tracepoint.h>
78356 +
78357 +TRACE_EVENT(do_sys_open,
78358 +
78359 + TP_PROTO(const char *filename, int flags, int mode),
78360 +
78361 + TP_ARGS(filename, flags, mode),
78362 +
78363 + TP_STRUCT__entry(
78364 + __string( filename, filename )
78365 + __field( int, flags )
78366 + __field( int, mode )
78367 + ),
78368 +
78369 + TP_fast_assign(
78370 + __assign_str(filename, filename);
78371 + __entry->flags = flags;
78372 + __entry->mode = mode;
78373 + ),
78374 +
78375 + TP_printk("\"%s\" %x %o",
78376 + __get_str(filename), __entry->flags, __entry->mode)
78377 +);
78378 +
78379 +TRACE_EVENT(open_exec,
78380 +
78381 + TP_PROTO(const char *filename),
78382 +
78383 + TP_ARGS(filename),
78384 +
78385 + TP_STRUCT__entry(
78386 + __string( filename, filename )
78387 + ),
78388 +
78389 + TP_fast_assign(
78390 + __assign_str(filename, filename);
78391 + ),
78392 +
78393 + TP_printk("\"%s\"",
78394 + __get_str(filename))
78395 +);
78396 +
78397 +#endif /* _TRACE_FS_H */
78398 +
78399 +/* This part must be outside protection */
78400 +#include <trace/define_trace.h>
78401 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78402 index 1c09820..7f5ec79 100644
78403 --- a/include/trace/events/irq.h
78404 +++ b/include/trace/events/irq.h
78405 @@ -36,7 +36,7 @@ struct softirq_action;
78406 */
78407 TRACE_EVENT(irq_handler_entry,
78408
78409 - TP_PROTO(int irq, struct irqaction *action),
78410 + TP_PROTO(int irq, const struct irqaction *action),
78411
78412 TP_ARGS(irq, action),
78413
78414 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78415 */
78416 TRACE_EVENT(irq_handler_exit,
78417
78418 - TP_PROTO(int irq, struct irqaction *action, int ret),
78419 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78420
78421 TP_ARGS(irq, action, ret),
78422
78423 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78424 index 7caf44c..23c6f27 100644
78425 --- a/include/uapi/linux/a.out.h
78426 +++ b/include/uapi/linux/a.out.h
78427 @@ -39,6 +39,14 @@ enum machine_type {
78428 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78429 };
78430
78431 +/* Constants for the N_FLAGS field */
78432 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78433 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78434 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78435 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78436 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78437 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78438 +
78439 #if !defined (N_MAGIC)
78440 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78441 #endif
78442 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78443 index d876736..ccce5c0 100644
78444 --- a/include/uapi/linux/byteorder/little_endian.h
78445 +++ b/include/uapi/linux/byteorder/little_endian.h
78446 @@ -42,51 +42,51 @@
78447
78448 static inline __le64 __cpu_to_le64p(const __u64 *p)
78449 {
78450 - return (__force __le64)*p;
78451 + return (__force const __le64)*p;
78452 }
78453 -static inline __u64 __le64_to_cpup(const __le64 *p)
78454 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78455 {
78456 - return (__force __u64)*p;
78457 + return (__force const __u64)*p;
78458 }
78459 static inline __le32 __cpu_to_le32p(const __u32 *p)
78460 {
78461 - return (__force __le32)*p;
78462 + return (__force const __le32)*p;
78463 }
78464 static inline __u32 __le32_to_cpup(const __le32 *p)
78465 {
78466 - return (__force __u32)*p;
78467 + return (__force const __u32)*p;
78468 }
78469 static inline __le16 __cpu_to_le16p(const __u16 *p)
78470 {
78471 - return (__force __le16)*p;
78472 + return (__force const __le16)*p;
78473 }
78474 static inline __u16 __le16_to_cpup(const __le16 *p)
78475 {
78476 - return (__force __u16)*p;
78477 + return (__force const __u16)*p;
78478 }
78479 static inline __be64 __cpu_to_be64p(const __u64 *p)
78480 {
78481 - return (__force __be64)__swab64p(p);
78482 + return (__force const __be64)__swab64p(p);
78483 }
78484 static inline __u64 __be64_to_cpup(const __be64 *p)
78485 {
78486 - return __swab64p((__u64 *)p);
78487 + return __swab64p((const __u64 *)p);
78488 }
78489 static inline __be32 __cpu_to_be32p(const __u32 *p)
78490 {
78491 - return (__force __be32)__swab32p(p);
78492 + return (__force const __be32)__swab32p(p);
78493 }
78494 -static inline __u32 __be32_to_cpup(const __be32 *p)
78495 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78496 {
78497 - return __swab32p((__u32 *)p);
78498 + return __swab32p((const __u32 *)p);
78499 }
78500 static inline __be16 __cpu_to_be16p(const __u16 *p)
78501 {
78502 - return (__force __be16)__swab16p(p);
78503 + return (__force const __be16)__swab16p(p);
78504 }
78505 static inline __u16 __be16_to_cpup(const __be16 *p)
78506 {
78507 - return __swab16p((__u16 *)p);
78508 + return __swab16p((const __u16 *)p);
78509 }
78510 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78511 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78512 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78513 index ef6103b..d4e65dd 100644
78514 --- a/include/uapi/linux/elf.h
78515 +++ b/include/uapi/linux/elf.h
78516 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78517 #define PT_GNU_EH_FRAME 0x6474e550
78518
78519 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78520 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78521 +
78522 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78523 +
78524 +/* Constants for the e_flags field */
78525 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78526 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78527 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78528 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78529 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78530 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78531
78532 /*
78533 * Extended Numbering
78534 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78535 #define DT_DEBUG 21
78536 #define DT_TEXTREL 22
78537 #define DT_JMPREL 23
78538 +#define DT_FLAGS 30
78539 + #define DF_TEXTREL 0x00000004
78540 #define DT_ENCODING 32
78541 #define OLD_DT_LOOS 0x60000000
78542 #define DT_LOOS 0x6000000d
78543 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78544 #define PF_W 0x2
78545 #define PF_X 0x1
78546
78547 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78548 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78549 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78550 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78551 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78552 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78553 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78554 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78555 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78556 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78557 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78558 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78559 +
78560 typedef struct elf32_phdr{
78561 Elf32_Word p_type;
78562 Elf32_Off p_offset;
78563 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78564 #define EI_OSABI 7
78565 #define EI_PAD 8
78566
78567 +#define EI_PAX 14
78568 +
78569 #define ELFMAG0 0x7f /* EI_MAG */
78570 #define ELFMAG1 'E'
78571 #define ELFMAG2 'L'
78572 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78573 index aa169c4..6a2771d 100644
78574 --- a/include/uapi/linux/personality.h
78575 +++ b/include/uapi/linux/personality.h
78576 @@ -30,6 +30,7 @@ enum {
78577 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78578 ADDR_NO_RANDOMIZE | \
78579 ADDR_COMPAT_LAYOUT | \
78580 + ADDR_LIMIT_3GB | \
78581 MMAP_PAGE_ZERO)
78582
78583 /*
78584 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78585 index 7530e74..e714828 100644
78586 --- a/include/uapi/linux/screen_info.h
78587 +++ b/include/uapi/linux/screen_info.h
78588 @@ -43,7 +43,8 @@ struct screen_info {
78589 __u16 pages; /* 0x32 */
78590 __u16 vesa_attributes; /* 0x34 */
78591 __u32 capabilities; /* 0x36 */
78592 - __u8 _reserved[6]; /* 0x3a */
78593 + __u16 vesapm_size; /* 0x3a */
78594 + __u8 _reserved[4]; /* 0x3c */
78595 } __attribute__((packed));
78596
78597 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78598 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78599 index 0e011eb..82681b1 100644
78600 --- a/include/uapi/linux/swab.h
78601 +++ b/include/uapi/linux/swab.h
78602 @@ -43,7 +43,7 @@
78603 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78604 */
78605
78606 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78607 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78608 {
78609 #ifdef __HAVE_BUILTIN_BSWAP16__
78610 return __builtin_bswap16(val);
78611 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78612 #endif
78613 }
78614
78615 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78616 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78617 {
78618 #ifdef __HAVE_BUILTIN_BSWAP32__
78619 return __builtin_bswap32(val);
78620 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78621 #endif
78622 }
78623
78624 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78625 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78626 {
78627 #ifdef __HAVE_BUILTIN_BSWAP64__
78628 return __builtin_bswap64(val);
78629 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78630 index 6d67213..8dab561 100644
78631 --- a/include/uapi/linux/sysctl.h
78632 +++ b/include/uapi/linux/sysctl.h
78633 @@ -155,7 +155,11 @@ enum
78634 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78635 };
78636
78637 -
78638 +#ifdef CONFIG_PAX_SOFTMODE
78639 +enum {
78640 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78641 +};
78642 +#endif
78643
78644 /* CTL_VM names: */
78645 enum
78646 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78647 index e4629b9..6958086 100644
78648 --- a/include/uapi/linux/xattr.h
78649 +++ b/include/uapi/linux/xattr.h
78650 @@ -63,5 +63,9 @@
78651 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78652 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78653
78654 +/* User namespace */
78655 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78656 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78657 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78658
78659 #endif /* _UAPI_LINUX_XATTR_H */
78660 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78661 index f9466fa..f4e2b81 100644
78662 --- a/include/video/udlfb.h
78663 +++ b/include/video/udlfb.h
78664 @@ -53,10 +53,10 @@ struct dlfb_data {
78665 u32 pseudo_palette[256];
78666 int blank_mode; /*one of FB_BLANK_ */
78667 /* blit-only rendering path metrics, exposed through sysfs */
78668 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78669 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78670 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78671 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78672 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78673 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78674 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78675 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78676 };
78677
78678 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78679 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78680 index 30f5362..8ed8ac9 100644
78681 --- a/include/video/uvesafb.h
78682 +++ b/include/video/uvesafb.h
78683 @@ -122,6 +122,7 @@ struct uvesafb_par {
78684 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78685 u8 pmi_setpal; /* PMI for palette changes */
78686 u16 *pmi_base; /* protected mode interface location */
78687 + u8 *pmi_code; /* protected mode code location */
78688 void *pmi_start;
78689 void *pmi_pal;
78690 u8 *vbe_state_orig; /*
78691 diff --git a/init/Kconfig b/init/Kconfig
78692 index fed81b5..0d3b964 100644
78693 --- a/init/Kconfig
78694 +++ b/init/Kconfig
78695 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78696
78697 config CHECKPOINT_RESTORE
78698 bool "Checkpoint/restore support" if EXPERT
78699 + depends on !GRKERNSEC
78700 default n
78701 help
78702 Enables additional kernel features in a sake of checkpoint/restore.
78703 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78704
78705 config COMPAT_BRK
78706 bool "Disable heap randomization"
78707 - default y
78708 + default n
78709 help
78710 Randomizing heap placement makes heap exploits harder, but it
78711 also breaks ancient binaries (including anything libc5 based).
78712 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78713 config STOP_MACHINE
78714 bool
78715 default y
78716 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78717 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78718 help
78719 Need stop_machine() primitive.
78720
78721 diff --git a/init/Makefile b/init/Makefile
78722 index 7bc47ee..6da2dc7 100644
78723 --- a/init/Makefile
78724 +++ b/init/Makefile
78725 @@ -2,6 +2,9 @@
78726 # Makefile for the linux kernel.
78727 #
78728
78729 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78730 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78731 +
78732 obj-y := main.o version.o mounts.o
78733 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78734 obj-y += noinitramfs.o
78735 diff --git a/init/do_mounts.c b/init/do_mounts.c
78736 index 816014c..c2054db 100644
78737 --- a/init/do_mounts.c
78738 +++ b/init/do_mounts.c
78739 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78740 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78741 {
78742 struct super_block *s;
78743 - int err = sys_mount(name, "/root", fs, flags, data);
78744 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78745 if (err)
78746 return err;
78747
78748 - sys_chdir("/root");
78749 + sys_chdir((const char __force_user *)"/root");
78750 s = current->fs->pwd.dentry->d_sb;
78751 ROOT_DEV = s->s_dev;
78752 printk(KERN_INFO
78753 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78754 va_start(args, fmt);
78755 vsprintf(buf, fmt, args);
78756 va_end(args);
78757 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78758 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78759 if (fd >= 0) {
78760 sys_ioctl(fd, FDEJECT, 0);
78761 sys_close(fd);
78762 }
78763 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78764 - fd = sys_open("/dev/console", O_RDWR, 0);
78765 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78766 if (fd >= 0) {
78767 sys_ioctl(fd, TCGETS, (long)&termios);
78768 termios.c_lflag &= ~ICANON;
78769 sys_ioctl(fd, TCSETSF, (long)&termios);
78770 - sys_read(fd, &c, 1);
78771 + sys_read(fd, (char __user *)&c, 1);
78772 termios.c_lflag |= ICANON;
78773 sys_ioctl(fd, TCSETSF, (long)&termios);
78774 sys_close(fd);
78775 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78776 mount_root();
78777 out:
78778 devtmpfs_mount("dev");
78779 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78780 - sys_chroot(".");
78781 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78782 + sys_chroot((const char __force_user *)".");
78783 }
78784 diff --git a/init/do_mounts.h b/init/do_mounts.h
78785 index f5b978a..69dbfe8 100644
78786 --- a/init/do_mounts.h
78787 +++ b/init/do_mounts.h
78788 @@ -15,15 +15,15 @@ extern int root_mountflags;
78789
78790 static inline int create_dev(char *name, dev_t dev)
78791 {
78792 - sys_unlink(name);
78793 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78794 + sys_unlink((char __force_user *)name);
78795 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78796 }
78797
78798 #if BITS_PER_LONG == 32
78799 static inline u32 bstat(char *name)
78800 {
78801 struct stat64 stat;
78802 - if (sys_stat64(name, &stat) != 0)
78803 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78804 return 0;
78805 if (!S_ISBLK(stat.st_mode))
78806 return 0;
78807 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78808 static inline u32 bstat(char *name)
78809 {
78810 struct stat stat;
78811 - if (sys_newstat(name, &stat) != 0)
78812 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78813 return 0;
78814 if (!S_ISBLK(stat.st_mode))
78815 return 0;
78816 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78817 index 3e0878e..8a9d7a0 100644
78818 --- a/init/do_mounts_initrd.c
78819 +++ b/init/do_mounts_initrd.c
78820 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78821 {
78822 sys_unshare(CLONE_FS | CLONE_FILES);
78823 /* stdin/stdout/stderr for /linuxrc */
78824 - sys_open("/dev/console", O_RDWR, 0);
78825 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78826 sys_dup(0);
78827 sys_dup(0);
78828 /* move initrd over / and chdir/chroot in initrd root */
78829 - sys_chdir("/root");
78830 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78831 - sys_chroot(".");
78832 + sys_chdir((const char __force_user *)"/root");
78833 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78834 + sys_chroot((const char __force_user *)".");
78835 sys_setsid();
78836 return 0;
78837 }
78838 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78839 create_dev("/dev/root.old", Root_RAM0);
78840 /* mount initrd on rootfs' /root */
78841 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78842 - sys_mkdir("/old", 0700);
78843 - sys_chdir("/old");
78844 + sys_mkdir((const char __force_user *)"/old", 0700);
78845 + sys_chdir((const char __force_user *)"/old");
78846
78847 /* try loading default modules from initrd */
78848 load_default_modules();
78849 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78850 current->flags &= ~PF_FREEZER_SKIP;
78851
78852 /* move initrd to rootfs' /old */
78853 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78854 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78855 /* switch root and cwd back to / of rootfs */
78856 - sys_chroot("..");
78857 + sys_chroot((const char __force_user *)"..");
78858
78859 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78860 - sys_chdir("/old");
78861 + sys_chdir((const char __force_user *)"/old");
78862 return;
78863 }
78864
78865 - sys_chdir("/");
78866 + sys_chdir((const char __force_user *)"/");
78867 ROOT_DEV = new_decode_dev(real_root_dev);
78868 mount_root();
78869
78870 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78871 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78872 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78873 if (!error)
78874 printk("okay\n");
78875 else {
78876 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78877 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78878 if (error == -ENOENT)
78879 printk("/initrd does not exist. Ignored.\n");
78880 else
78881 printk("failed\n");
78882 printk(KERN_NOTICE "Unmounting old root\n");
78883 - sys_umount("/old", MNT_DETACH);
78884 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78885 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78886 if (fd < 0) {
78887 error = fd;
78888 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78889 * mounted in the normal path.
78890 */
78891 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78892 - sys_unlink("/initrd.image");
78893 + sys_unlink((const char __force_user *)"/initrd.image");
78894 handle_initrd();
78895 return 1;
78896 }
78897 }
78898 - sys_unlink("/initrd.image");
78899 + sys_unlink((const char __force_user *)"/initrd.image");
78900 return 0;
78901 }
78902 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78903 index 8cb6db5..d729f50 100644
78904 --- a/init/do_mounts_md.c
78905 +++ b/init/do_mounts_md.c
78906 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78907 partitioned ? "_d" : "", minor,
78908 md_setup_args[ent].device_names);
78909
78910 - fd = sys_open(name, 0, 0);
78911 + fd = sys_open((char __force_user *)name, 0, 0);
78912 if (fd < 0) {
78913 printk(KERN_ERR "md: open failed - cannot start "
78914 "array %s\n", name);
78915 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78916 * array without it
78917 */
78918 sys_close(fd);
78919 - fd = sys_open(name, 0, 0);
78920 + fd = sys_open((char __force_user *)name, 0, 0);
78921 sys_ioctl(fd, BLKRRPART, 0);
78922 }
78923 sys_close(fd);
78924 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78925
78926 wait_for_device_probe();
78927
78928 - fd = sys_open("/dev/md0", 0, 0);
78929 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78930 if (fd >= 0) {
78931 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78932 sys_close(fd);
78933 diff --git a/init/init_task.c b/init/init_task.c
78934 index ba0a7f36..2bcf1d5 100644
78935 --- a/init/init_task.c
78936 +++ b/init/init_task.c
78937 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78938 * Initial thread structure. Alignment of this is handled by a special
78939 * linker map entry.
78940 */
78941 +#ifdef CONFIG_X86
78942 +union thread_union init_thread_union __init_task_data;
78943 +#else
78944 union thread_union init_thread_union __init_task_data =
78945 { INIT_THREAD_INFO(init_task) };
78946 +#endif
78947 diff --git a/init/initramfs.c b/init/initramfs.c
78948 index a67ef9d..2d17ed9 100644
78949 --- a/init/initramfs.c
78950 +++ b/init/initramfs.c
78951 @@ -84,7 +84,7 @@ static void __init free_hash(void)
78952 }
78953 }
78954
78955 -static long __init do_utime(char *filename, time_t mtime)
78956 +static long __init do_utime(char __force_user *filename, time_t mtime)
78957 {
78958 struct timespec t[2];
78959
78960 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
78961 struct dir_entry *de, *tmp;
78962 list_for_each_entry_safe(de, tmp, &dir_list, list) {
78963 list_del(&de->list);
78964 - do_utime(de->name, de->mtime);
78965 + do_utime((char __force_user *)de->name, de->mtime);
78966 kfree(de->name);
78967 kfree(de);
78968 }
78969 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
78970 if (nlink >= 2) {
78971 char *old = find_link(major, minor, ino, mode, collected);
78972 if (old)
78973 - return (sys_link(old, collected) < 0) ? -1 : 1;
78974 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
78975 }
78976 return 0;
78977 }
78978 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
78979 {
78980 struct stat st;
78981
78982 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
78983 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
78984 if (S_ISDIR(st.st_mode))
78985 - sys_rmdir(path);
78986 + sys_rmdir((char __force_user *)path);
78987 else
78988 - sys_unlink(path);
78989 + sys_unlink((char __force_user *)path);
78990 }
78991 }
78992
78993 @@ -315,7 +315,7 @@ static int __init do_name(void)
78994 int openflags = O_WRONLY|O_CREAT;
78995 if (ml != 1)
78996 openflags |= O_TRUNC;
78997 - wfd = sys_open(collected, openflags, mode);
78998 + wfd = sys_open((char __force_user *)collected, openflags, mode);
78999
79000 if (wfd >= 0) {
79001 sys_fchown(wfd, uid, gid);
79002 @@ -327,17 +327,17 @@ static int __init do_name(void)
79003 }
79004 }
79005 } else if (S_ISDIR(mode)) {
79006 - sys_mkdir(collected, mode);
79007 - sys_chown(collected, uid, gid);
79008 - sys_chmod(collected, mode);
79009 + sys_mkdir((char __force_user *)collected, mode);
79010 + sys_chown((char __force_user *)collected, uid, gid);
79011 + sys_chmod((char __force_user *)collected, mode);
79012 dir_add(collected, mtime);
79013 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79014 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79015 if (maybe_link() == 0) {
79016 - sys_mknod(collected, mode, rdev);
79017 - sys_chown(collected, uid, gid);
79018 - sys_chmod(collected, mode);
79019 - do_utime(collected, mtime);
79020 + sys_mknod((char __force_user *)collected, mode, rdev);
79021 + sys_chown((char __force_user *)collected, uid, gid);
79022 + sys_chmod((char __force_user *)collected, mode);
79023 + do_utime((char __force_user *)collected, mtime);
79024 }
79025 }
79026 return 0;
79027 @@ -346,15 +346,15 @@ static int __init do_name(void)
79028 static int __init do_copy(void)
79029 {
79030 if (count >= body_len) {
79031 - sys_write(wfd, victim, body_len);
79032 + sys_write(wfd, (char __force_user *)victim, body_len);
79033 sys_close(wfd);
79034 - do_utime(vcollected, mtime);
79035 + do_utime((char __force_user *)vcollected, mtime);
79036 kfree(vcollected);
79037 eat(body_len);
79038 state = SkipIt;
79039 return 0;
79040 } else {
79041 - sys_write(wfd, victim, count);
79042 + sys_write(wfd, (char __force_user *)victim, count);
79043 body_len -= count;
79044 eat(count);
79045 return 1;
79046 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79047 {
79048 collected[N_ALIGN(name_len) + body_len] = '\0';
79049 clean_path(collected, 0);
79050 - sys_symlink(collected + N_ALIGN(name_len), collected);
79051 - sys_lchown(collected, uid, gid);
79052 - do_utime(collected, mtime);
79053 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79054 + sys_lchown((char __force_user *)collected, uid, gid);
79055 + do_utime((char __force_user *)collected, mtime);
79056 state = SkipIt;
79057 next_state = Reset;
79058 return 0;
79059 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79060 {
79061 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79062 if (err)
79063 - panic(err); /* Failed to decompress INTERNAL initramfs */
79064 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79065 if (initrd_start) {
79066 #ifdef CONFIG_BLK_DEV_RAM
79067 int fd;
79068 diff --git a/init/main.c b/init/main.c
79069 index d03d2ec..9fc4737 100644
79070 --- a/init/main.c
79071 +++ b/init/main.c
79072 @@ -101,6 +101,8 @@ static inline void mark_rodata_ro(void) { }
79073 extern void tc_init(void);
79074 #endif
79075
79076 +extern void grsecurity_init(void);
79077 +
79078 /*
79079 * Debug helper: via this flag we know that we are in 'early bootup code'
79080 * where only the boot processor is running with IRQ disabled. This means
79081 @@ -154,6 +156,74 @@ static int __init set_reset_devices(char *str)
79082
79083 __setup("reset_devices", set_reset_devices);
79084
79085 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79086 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79087 +static int __init setup_grsec_proc_gid(char *str)
79088 +{
79089 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79090 + return 1;
79091 +}
79092 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79093 +#endif
79094 +
79095 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79096 +unsigned long pax_user_shadow_base __read_only;
79097 +EXPORT_SYMBOL(pax_user_shadow_base);
79098 +extern char pax_enter_kernel_user[];
79099 +extern char pax_exit_kernel_user[];
79100 +#endif
79101 +
79102 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79103 +static int __init setup_pax_nouderef(char *str)
79104 +{
79105 +#ifdef CONFIG_X86_32
79106 + unsigned int cpu;
79107 + struct desc_struct *gdt;
79108 +
79109 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79110 + gdt = get_cpu_gdt_table(cpu);
79111 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79112 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79113 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79114 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79115 + }
79116 + loadsegment(ds, __KERNEL_DS);
79117 + loadsegment(es, __KERNEL_DS);
79118 + loadsegment(ss, __KERNEL_DS);
79119 +#else
79120 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79121 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79122 + clone_pgd_mask = ~(pgdval_t)0UL;
79123 + pax_user_shadow_base = 0UL;
79124 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79125 +#endif
79126 +
79127 + return 0;
79128 +}
79129 +early_param("pax_nouderef", setup_pax_nouderef);
79130 +
79131 +#ifdef CONFIG_X86_64
79132 +static int __init setup_pax_weakuderef(char *str)
79133 +{
79134 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79135 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79136 + return 1;
79137 +}
79138 +__setup("pax_weakuderef", setup_pax_weakuderef);
79139 +#endif
79140 +#endif
79141 +
79142 +#ifdef CONFIG_PAX_SOFTMODE
79143 +int pax_softmode;
79144 +
79145 +static int __init setup_pax_softmode(char *str)
79146 +{
79147 + get_option(&str, &pax_softmode);
79148 + return 1;
79149 +}
79150 +__setup("pax_softmode=", setup_pax_softmode);
79151 +#endif
79152 +
79153 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79154 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79155 static const char *panic_later, *panic_param;
79156 @@ -679,25 +749,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79157 {
79158 int count = preempt_count();
79159 int ret;
79160 - char msgbuf[64];
79161 + const char *msg1 = "", *msg2 = "";
79162
79163 if (initcall_debug)
79164 ret = do_one_initcall_debug(fn);
79165 else
79166 ret = fn();
79167
79168 - msgbuf[0] = 0;
79169 -
79170 if (preempt_count() != count) {
79171 - sprintf(msgbuf, "preemption imbalance ");
79172 + msg1 = " preemption imbalance";
79173 preempt_count() = count;
79174 }
79175 if (irqs_disabled()) {
79176 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79177 + msg2 = " disabled interrupts";
79178 local_irq_enable();
79179 }
79180 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79181 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79182
79183 + add_latent_entropy();
79184 return ret;
79185 }
79186
79187 @@ -803,8 +872,8 @@ static int run_init_process(const char *init_filename)
79188 {
79189 argv_init[0] = init_filename;
79190 return do_execve(init_filename,
79191 - (const char __user *const __user *)argv_init,
79192 - (const char __user *const __user *)envp_init);
79193 + (const char __user *const __force_user *)argv_init,
79194 + (const char __user *const __force_user *)envp_init);
79195 }
79196
79197 static noinline void __init kernel_init_freeable(void);
79198 @@ -881,7 +950,7 @@ static noinline void __init kernel_init_freeable(void)
79199 do_basic_setup();
79200
79201 /* Open the /dev/console on the rootfs, this should never fail */
79202 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79203 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79204 pr_err("Warning: unable to open an initial console.\n");
79205
79206 (void) sys_dup(0);
79207 @@ -894,11 +963,13 @@ static noinline void __init kernel_init_freeable(void)
79208 if (!ramdisk_execute_command)
79209 ramdisk_execute_command = "/init";
79210
79211 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79212 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79213 ramdisk_execute_command = NULL;
79214 prepare_namespace();
79215 }
79216
79217 + grsecurity_init();
79218 +
79219 /*
79220 * Ok, we have completed the initial bootup, and
79221 * we're essentially up and running. Get rid of the
79222 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79223 index 130dfec..cc88451 100644
79224 --- a/ipc/ipc_sysctl.c
79225 +++ b/ipc/ipc_sysctl.c
79226 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79227 static int proc_ipc_dointvec(ctl_table *table, int write,
79228 void __user *buffer, size_t *lenp, loff_t *ppos)
79229 {
79230 - struct ctl_table ipc_table;
79231 + ctl_table_no_const ipc_table;
79232
79233 memcpy(&ipc_table, table, sizeof(ipc_table));
79234 ipc_table.data = get_ipc(table);
79235 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79236 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79237 void __user *buffer, size_t *lenp, loff_t *ppos)
79238 {
79239 - struct ctl_table ipc_table;
79240 + ctl_table_no_const ipc_table;
79241
79242 memcpy(&ipc_table, table, sizeof(ipc_table));
79243 ipc_table.data = get_ipc(table);
79244 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79245 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79246 void __user *buffer, size_t *lenp, loff_t *ppos)
79247 {
79248 - struct ctl_table ipc_table;
79249 + ctl_table_no_const ipc_table;
79250 size_t lenp_bef = *lenp;
79251 int rc;
79252
79253 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79254 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79255 void __user *buffer, size_t *lenp, loff_t *ppos)
79256 {
79257 - struct ctl_table ipc_table;
79258 + ctl_table_no_const ipc_table;
79259 memcpy(&ipc_table, table, sizeof(ipc_table));
79260 ipc_table.data = get_ipc(table);
79261
79262 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79263 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79264 void __user *buffer, size_t *lenp, loff_t *ppos)
79265 {
79266 - struct ctl_table ipc_table;
79267 + ctl_table_no_const ipc_table;
79268 size_t lenp_bef = *lenp;
79269 int oldval;
79270 int rc;
79271 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79272 index 383d638..943fdbb 100644
79273 --- a/ipc/mq_sysctl.c
79274 +++ b/ipc/mq_sysctl.c
79275 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79276 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79277 void __user *buffer, size_t *lenp, loff_t *ppos)
79278 {
79279 - struct ctl_table mq_table;
79280 + ctl_table_no_const mq_table;
79281 memcpy(&mq_table, table, sizeof(mq_table));
79282 mq_table.data = get_mq(table);
79283
79284 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79285 index ae1996d..a35f2cc 100644
79286 --- a/ipc/mqueue.c
79287 +++ b/ipc/mqueue.c
79288 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79289 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79290 info->attr.mq_msgsize);
79291
79292 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79293 spin_lock(&mq_lock);
79294 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79295 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79296 diff --git a/ipc/msg.c b/ipc/msg.c
79297 index b65fdf1..89ec2b1 100644
79298 --- a/ipc/msg.c
79299 +++ b/ipc/msg.c
79300 @@ -291,18 +291,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79301 return security_msg_queue_associate(msq, msgflg);
79302 }
79303
79304 +static struct ipc_ops msg_ops = {
79305 + .getnew = newque,
79306 + .associate = msg_security,
79307 + .more_checks = NULL
79308 +};
79309 +
79310 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79311 {
79312 struct ipc_namespace *ns;
79313 - struct ipc_ops msg_ops;
79314 struct ipc_params msg_params;
79315
79316 ns = current->nsproxy->ipc_ns;
79317
79318 - msg_ops.getnew = newque;
79319 - msg_ops.associate = msg_security;
79320 - msg_ops.more_checks = NULL;
79321 -
79322 msg_params.key = key;
79323 msg_params.flg = msgflg;
79324
79325 diff --git a/ipc/sem.c b/ipc/sem.c
79326 index 4108889..511ada1 100644
79327 --- a/ipc/sem.c
79328 +++ b/ipc/sem.c
79329 @@ -517,10 +517,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79330 return 0;
79331 }
79332
79333 +static struct ipc_ops sem_ops = {
79334 + .getnew = newary,
79335 + .associate = sem_security,
79336 + .more_checks = sem_more_checks
79337 +};
79338 +
79339 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79340 {
79341 struct ipc_namespace *ns;
79342 - struct ipc_ops sem_ops;
79343 struct ipc_params sem_params;
79344
79345 ns = current->nsproxy->ipc_ns;
79346 @@ -528,10 +533,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79347 if (nsems < 0 || nsems > ns->sc_semmsl)
79348 return -EINVAL;
79349
79350 - sem_ops.getnew = newary;
79351 - sem_ops.associate = sem_security;
79352 - sem_ops.more_checks = sem_more_checks;
79353 -
79354 sem_params.key = key;
79355 sem_params.flg = semflg;
79356 sem_params.u.nsems = nsems;
79357 diff --git a/ipc/shm.c b/ipc/shm.c
79358 index c6b4ad5..3ec3254 100644
79359 --- a/ipc/shm.c
79360 +++ b/ipc/shm.c
79361 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79362 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79363 #endif
79364
79365 +#ifdef CONFIG_GRKERNSEC
79366 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79367 + const time_t shm_createtime, const kuid_t cuid,
79368 + const int shmid);
79369 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79370 + const time_t shm_createtime);
79371 +#endif
79372 +
79373 void shm_init_ns(struct ipc_namespace *ns)
79374 {
79375 ns->shm_ctlmax = SHMMAX;
79376 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79377 shp->shm_lprid = 0;
79378 shp->shm_atim = shp->shm_dtim = 0;
79379 shp->shm_ctim = get_seconds();
79380 +#ifdef CONFIG_GRKERNSEC
79381 + {
79382 + struct timespec timeval;
79383 + do_posix_clock_monotonic_gettime(&timeval);
79384 +
79385 + shp->shm_createtime = timeval.tv_sec;
79386 + }
79387 +#endif
79388 shp->shm_segsz = size;
79389 shp->shm_nattch = 0;
79390 shp->shm_file = file;
79391 @@ -585,18 +601,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79392 return 0;
79393 }
79394
79395 +static struct ipc_ops shm_ops = {
79396 + .getnew = newseg,
79397 + .associate = shm_security,
79398 + .more_checks = shm_more_checks
79399 +};
79400 +
79401 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79402 {
79403 struct ipc_namespace *ns;
79404 - struct ipc_ops shm_ops;
79405 struct ipc_params shm_params;
79406
79407 ns = current->nsproxy->ipc_ns;
79408
79409 - shm_ops.getnew = newseg;
79410 - shm_ops.associate = shm_security;
79411 - shm_ops.more_checks = shm_more_checks;
79412 -
79413 shm_params.key = key;
79414 shm_params.flg = shmflg;
79415 shm_params.u.size = size;
79416 @@ -1028,6 +1045,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79417 f_mode = FMODE_READ | FMODE_WRITE;
79418 }
79419 if (shmflg & SHM_EXEC) {
79420 +
79421 +#ifdef CONFIG_PAX_MPROTECT
79422 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79423 + goto out;
79424 +#endif
79425 +
79426 prot |= PROT_EXEC;
79427 acc_mode |= S_IXUGO;
79428 }
79429 @@ -1051,9 +1074,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79430 if (err)
79431 goto out_unlock;
79432
79433 +#ifdef CONFIG_GRKERNSEC
79434 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79435 + shp->shm_perm.cuid, shmid) ||
79436 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79437 + err = -EACCES;
79438 + goto out_unlock;
79439 + }
79440 +#endif
79441 +
79442 path = shp->shm_file->f_path;
79443 path_get(&path);
79444 shp->shm_nattch++;
79445 +#ifdef CONFIG_GRKERNSEC
79446 + shp->shm_lapid = current->pid;
79447 +#endif
79448 size = i_size_read(path.dentry->d_inode);
79449 shm_unlock(shp);
79450
79451 diff --git a/kernel/acct.c b/kernel/acct.c
79452 index 8d6e145..33e0b1e 100644
79453 --- a/kernel/acct.c
79454 +++ b/kernel/acct.c
79455 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79456 */
79457 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79458 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79459 - file->f_op->write(file, (char *)&ac,
79460 + file->f_op->write(file, (char __force_user *)&ac,
79461 sizeof(acct_t), &file->f_pos);
79462 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79463 set_fs(fs);
79464 diff --git a/kernel/audit.c b/kernel/audit.c
79465 index 91e53d0..d9e3ec4 100644
79466 --- a/kernel/audit.c
79467 +++ b/kernel/audit.c
79468 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79469 3) suppressed due to audit_rate_limit
79470 4) suppressed due to audit_backlog_limit
79471 */
79472 -static atomic_t audit_lost = ATOMIC_INIT(0);
79473 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79474
79475 /* The netlink socket. */
79476 static struct sock *audit_sock;
79477 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79478 unsigned long now;
79479 int print;
79480
79481 - atomic_inc(&audit_lost);
79482 + atomic_inc_unchecked(&audit_lost);
79483
79484 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79485
79486 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79487 printk(KERN_WARNING
79488 "audit: audit_lost=%d audit_rate_limit=%d "
79489 "audit_backlog_limit=%d\n",
79490 - atomic_read(&audit_lost),
79491 + atomic_read_unchecked(&audit_lost),
79492 audit_rate_limit,
79493 audit_backlog_limit);
79494 audit_panic(message);
79495 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79496 status_set.pid = audit_pid;
79497 status_set.rate_limit = audit_rate_limit;
79498 status_set.backlog_limit = audit_backlog_limit;
79499 - status_set.lost = atomic_read(&audit_lost);
79500 + status_set.lost = atomic_read_unchecked(&audit_lost);
79501 status_set.backlog = skb_queue_len(&audit_skb_queue);
79502 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79503 &status_set, sizeof(status_set));
79504 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79505 index 9845cb3..3ec9369 100644
79506 --- a/kernel/auditsc.c
79507 +++ b/kernel/auditsc.c
79508 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79509 }
79510
79511 /* global counter which is incremented every time something logs in */
79512 -static atomic_t session_id = ATOMIC_INIT(0);
79513 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79514
79515 /**
79516 * audit_set_loginuid - set current task's audit_context loginuid
79517 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79518 return -EPERM;
79519 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79520
79521 - sessionid = atomic_inc_return(&session_id);
79522 + sessionid = atomic_inc_return_unchecked(&session_id);
79523 if (context && context->in_syscall) {
79524 struct audit_buffer *ab;
79525
79526 diff --git a/kernel/capability.c b/kernel/capability.c
79527 index f6c2ce5..982c0f9 100644
79528 --- a/kernel/capability.c
79529 +++ b/kernel/capability.c
79530 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79531 * before modification is attempted and the application
79532 * fails.
79533 */
79534 + if (tocopy > ARRAY_SIZE(kdata))
79535 + return -EFAULT;
79536 +
79537 if (copy_to_user(dataptr, kdata, tocopy
79538 * sizeof(struct __user_cap_data_struct))) {
79539 return -EFAULT;
79540 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79541 int ret;
79542
79543 rcu_read_lock();
79544 - ret = security_capable(__task_cred(t), ns, cap);
79545 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79546 + gr_task_is_capable(t, __task_cred(t), cap);
79547 rcu_read_unlock();
79548
79549 - return (ret == 0);
79550 + return ret;
79551 }
79552
79553 /**
79554 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79555 int ret;
79556
79557 rcu_read_lock();
79558 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79559 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79560 rcu_read_unlock();
79561
79562 - return (ret == 0);
79563 + return ret;
79564 }
79565
79566 /**
79567 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79568 BUG();
79569 }
79570
79571 - if (security_capable(current_cred(), ns, cap) == 0) {
79572 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79573 current->flags |= PF_SUPERPRIV;
79574 return true;
79575 }
79576 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79577 }
79578 EXPORT_SYMBOL(ns_capable);
79579
79580 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79581 +{
79582 + if (unlikely(!cap_valid(cap))) {
79583 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79584 + BUG();
79585 + }
79586 +
79587 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79588 + current->flags |= PF_SUPERPRIV;
79589 + return true;
79590 + }
79591 + return false;
79592 +}
79593 +EXPORT_SYMBOL(ns_capable_nolog);
79594 +
79595 /**
79596 * file_ns_capable - Determine if the file's opener had a capability in effect
79597 * @file: The file we want to check
79598 @@ -432,6 +451,12 @@ bool capable(int cap)
79599 }
79600 EXPORT_SYMBOL(capable);
79601
79602 +bool capable_nolog(int cap)
79603 +{
79604 + return ns_capable_nolog(&init_user_ns, cap);
79605 +}
79606 +EXPORT_SYMBOL(capable_nolog);
79607 +
79608 /**
79609 * nsown_capable - Check superior capability to one's own user_ns
79610 * @cap: The capability in question
79611 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79612
79613 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79614 }
79615 +
79616 +bool inode_capable_nolog(const struct inode *inode, int cap)
79617 +{
79618 + struct user_namespace *ns = current_user_ns();
79619 +
79620 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79621 +}
79622 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79623 index e919633..f46b08f 100644
79624 --- a/kernel/cgroup.c
79625 +++ b/kernel/cgroup.c
79626 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79627 struct css_set *cset = link->cset;
79628 struct task_struct *task;
79629 int count = 0;
79630 - seq_printf(seq, "css_set %p\n", cset);
79631 + seq_printf(seq, "css_set %pK\n", cset);
79632 list_for_each_entry(task, &cset->tasks, cg_list) {
79633 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79634 seq_puts(seq, " ...\n");
79635 diff --git a/kernel/compat.c b/kernel/compat.c
79636 index 0a09e48..f44f3f0 100644
79637 --- a/kernel/compat.c
79638 +++ b/kernel/compat.c
79639 @@ -13,6 +13,7 @@
79640
79641 #include <linux/linkage.h>
79642 #include <linux/compat.h>
79643 +#include <linux/module.h>
79644 #include <linux/errno.h>
79645 #include <linux/time.h>
79646 #include <linux/signal.h>
79647 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79648 mm_segment_t oldfs;
79649 long ret;
79650
79651 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79652 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79653 oldfs = get_fs();
79654 set_fs(KERNEL_DS);
79655 ret = hrtimer_nanosleep_restart(restart);
79656 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79657 oldfs = get_fs();
79658 set_fs(KERNEL_DS);
79659 ret = hrtimer_nanosleep(&tu,
79660 - rmtp ? (struct timespec __user *)&rmt : NULL,
79661 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79662 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79663 set_fs(oldfs);
79664
79665 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79666 mm_segment_t old_fs = get_fs();
79667
79668 set_fs(KERNEL_DS);
79669 - ret = sys_sigpending((old_sigset_t __user *) &s);
79670 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79671 set_fs(old_fs);
79672 if (ret == 0)
79673 ret = put_user(s, set);
79674 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79675 mm_segment_t old_fs = get_fs();
79676
79677 set_fs(KERNEL_DS);
79678 - ret = sys_old_getrlimit(resource, &r);
79679 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79680 set_fs(old_fs);
79681
79682 if (!ret) {
79683 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79684 set_fs (KERNEL_DS);
79685 ret = sys_wait4(pid,
79686 (stat_addr ?
79687 - (unsigned int __user *) &status : NULL),
79688 - options, (struct rusage __user *) &r);
79689 + (unsigned int __force_user *) &status : NULL),
79690 + options, (struct rusage __force_user *) &r);
79691 set_fs (old_fs);
79692
79693 if (ret > 0) {
79694 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79695 memset(&info, 0, sizeof(info));
79696
79697 set_fs(KERNEL_DS);
79698 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79699 - uru ? (struct rusage __user *)&ru : NULL);
79700 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79701 + uru ? (struct rusage __force_user *)&ru : NULL);
79702 set_fs(old_fs);
79703
79704 if ((ret < 0) || (info.si_signo == 0))
79705 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79706 oldfs = get_fs();
79707 set_fs(KERNEL_DS);
79708 err = sys_timer_settime(timer_id, flags,
79709 - (struct itimerspec __user *) &newts,
79710 - (struct itimerspec __user *) &oldts);
79711 + (struct itimerspec __force_user *) &newts,
79712 + (struct itimerspec __force_user *) &oldts);
79713 set_fs(oldfs);
79714 if (!err && old && put_compat_itimerspec(old, &oldts))
79715 return -EFAULT;
79716 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79717 oldfs = get_fs();
79718 set_fs(KERNEL_DS);
79719 err = sys_timer_gettime(timer_id,
79720 - (struct itimerspec __user *) &ts);
79721 + (struct itimerspec __force_user *) &ts);
79722 set_fs(oldfs);
79723 if (!err && put_compat_itimerspec(setting, &ts))
79724 return -EFAULT;
79725 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79726 oldfs = get_fs();
79727 set_fs(KERNEL_DS);
79728 err = sys_clock_settime(which_clock,
79729 - (struct timespec __user *) &ts);
79730 + (struct timespec __force_user *) &ts);
79731 set_fs(oldfs);
79732 return err;
79733 }
79734 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79735 oldfs = get_fs();
79736 set_fs(KERNEL_DS);
79737 err = sys_clock_gettime(which_clock,
79738 - (struct timespec __user *) &ts);
79739 + (struct timespec __force_user *) &ts);
79740 set_fs(oldfs);
79741 if (!err && put_compat_timespec(&ts, tp))
79742 return -EFAULT;
79743 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79744
79745 oldfs = get_fs();
79746 set_fs(KERNEL_DS);
79747 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79748 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79749 set_fs(oldfs);
79750
79751 err = compat_put_timex(utp, &txc);
79752 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79753 oldfs = get_fs();
79754 set_fs(KERNEL_DS);
79755 err = sys_clock_getres(which_clock,
79756 - (struct timespec __user *) &ts);
79757 + (struct timespec __force_user *) &ts);
79758 set_fs(oldfs);
79759 if (!err && tp && put_compat_timespec(&ts, tp))
79760 return -EFAULT;
79761 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79762 long err;
79763 mm_segment_t oldfs;
79764 struct timespec tu;
79765 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79766 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79767
79768 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79769 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79770 oldfs = get_fs();
79771 set_fs(KERNEL_DS);
79772 err = clock_nanosleep_restart(restart);
79773 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79774 oldfs = get_fs();
79775 set_fs(KERNEL_DS);
79776 err = sys_clock_nanosleep(which_clock, flags,
79777 - (struct timespec __user *) &in,
79778 - (struct timespec __user *) &out);
79779 + (struct timespec __force_user *) &in,
79780 + (struct timespec __force_user *) &out);
79781 set_fs(oldfs);
79782
79783 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79784 diff --git a/kernel/configs.c b/kernel/configs.c
79785 index c18b1f1..b9a0132 100644
79786 --- a/kernel/configs.c
79787 +++ b/kernel/configs.c
79788 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79789 struct proc_dir_entry *entry;
79790
79791 /* create the current config file */
79792 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79793 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79794 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79795 + &ikconfig_file_ops);
79796 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79797 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79798 + &ikconfig_file_ops);
79799 +#endif
79800 +#else
79801 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79802 &ikconfig_file_ops);
79803 +#endif
79804 +
79805 if (!entry)
79806 return -ENOMEM;
79807
79808 diff --git a/kernel/cred.c b/kernel/cred.c
79809 index e0573a4..3874e41 100644
79810 --- a/kernel/cred.c
79811 +++ b/kernel/cred.c
79812 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79813 validate_creds(cred);
79814 alter_cred_subscribers(cred, -1);
79815 put_cred(cred);
79816 +
79817 +#ifdef CONFIG_GRKERNSEC_SETXID
79818 + cred = (struct cred *) tsk->delayed_cred;
79819 + if (cred != NULL) {
79820 + tsk->delayed_cred = NULL;
79821 + validate_creds(cred);
79822 + alter_cred_subscribers(cred, -1);
79823 + put_cred(cred);
79824 + }
79825 +#endif
79826 }
79827
79828 /**
79829 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79830 * Always returns 0 thus allowing this function to be tail-called at the end
79831 * of, say, sys_setgid().
79832 */
79833 -int commit_creds(struct cred *new)
79834 +static int __commit_creds(struct cred *new)
79835 {
79836 struct task_struct *task = current;
79837 const struct cred *old = task->real_cred;
79838 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79839
79840 get_cred(new); /* we will require a ref for the subj creds too */
79841
79842 + gr_set_role_label(task, new->uid, new->gid);
79843 +
79844 /* dumpability changes */
79845 if (!uid_eq(old->euid, new->euid) ||
79846 !gid_eq(old->egid, new->egid) ||
79847 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79848 put_cred(old);
79849 return 0;
79850 }
79851 +#ifdef CONFIG_GRKERNSEC_SETXID
79852 +extern int set_user(struct cred *new);
79853 +
79854 +void gr_delayed_cred_worker(void)
79855 +{
79856 + const struct cred *new = current->delayed_cred;
79857 + struct cred *ncred;
79858 +
79859 + current->delayed_cred = NULL;
79860 +
79861 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79862 + // from doing get_cred on it when queueing this
79863 + put_cred(new);
79864 + return;
79865 + } else if (new == NULL)
79866 + return;
79867 +
79868 + ncred = prepare_creds();
79869 + if (!ncred)
79870 + goto die;
79871 + // uids
79872 + ncred->uid = new->uid;
79873 + ncred->euid = new->euid;
79874 + ncred->suid = new->suid;
79875 + ncred->fsuid = new->fsuid;
79876 + // gids
79877 + ncred->gid = new->gid;
79878 + ncred->egid = new->egid;
79879 + ncred->sgid = new->sgid;
79880 + ncred->fsgid = new->fsgid;
79881 + // groups
79882 + if (set_groups(ncred, new->group_info) < 0) {
79883 + abort_creds(ncred);
79884 + goto die;
79885 + }
79886 + // caps
79887 + ncred->securebits = new->securebits;
79888 + ncred->cap_inheritable = new->cap_inheritable;
79889 + ncred->cap_permitted = new->cap_permitted;
79890 + ncred->cap_effective = new->cap_effective;
79891 + ncred->cap_bset = new->cap_bset;
79892 +
79893 + if (set_user(ncred)) {
79894 + abort_creds(ncred);
79895 + goto die;
79896 + }
79897 +
79898 + // from doing get_cred on it when queueing this
79899 + put_cred(new);
79900 +
79901 + __commit_creds(ncred);
79902 + return;
79903 +die:
79904 + // from doing get_cred on it when queueing this
79905 + put_cred(new);
79906 + do_group_exit(SIGKILL);
79907 +}
79908 +#endif
79909 +
79910 +int commit_creds(struct cred *new)
79911 +{
79912 +#ifdef CONFIG_GRKERNSEC_SETXID
79913 + int ret;
79914 + int schedule_it = 0;
79915 + struct task_struct *t;
79916 +
79917 + /* we won't get called with tasklist_lock held for writing
79918 + and interrupts disabled as the cred struct in that case is
79919 + init_cred
79920 + */
79921 + if (grsec_enable_setxid && !current_is_single_threaded() &&
79922 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
79923 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
79924 + schedule_it = 1;
79925 + }
79926 + ret = __commit_creds(new);
79927 + if (schedule_it) {
79928 + rcu_read_lock();
79929 + read_lock(&tasklist_lock);
79930 + for (t = next_thread(current); t != current;
79931 + t = next_thread(t)) {
79932 + if (t->delayed_cred == NULL) {
79933 + t->delayed_cred = get_cred(new);
79934 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
79935 + set_tsk_need_resched(t);
79936 + }
79937 + }
79938 + read_unlock(&tasklist_lock);
79939 + rcu_read_unlock();
79940 + }
79941 + return ret;
79942 +#else
79943 + return __commit_creds(new);
79944 +#endif
79945 +}
79946 +
79947 EXPORT_SYMBOL(commit_creds);
79948
79949 /**
79950 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
79951 index 0506d44..2c20034 100644
79952 --- a/kernel/debug/debug_core.c
79953 +++ b/kernel/debug/debug_core.c
79954 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
79955 */
79956 static atomic_t masters_in_kgdb;
79957 static atomic_t slaves_in_kgdb;
79958 -static atomic_t kgdb_break_tasklet_var;
79959 +static atomic_unchecked_t kgdb_break_tasklet_var;
79960 atomic_t kgdb_setting_breakpoint;
79961
79962 struct task_struct *kgdb_usethread;
79963 @@ -133,7 +133,7 @@ int kgdb_single_step;
79964 static pid_t kgdb_sstep_pid;
79965
79966 /* to keep track of the CPU which is doing the single stepping*/
79967 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79968 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79969
79970 /*
79971 * If you are debugging a problem where roundup (the collection of
79972 @@ -541,7 +541,7 @@ return_normal:
79973 * kernel will only try for the value of sstep_tries before
79974 * giving up and continuing on.
79975 */
79976 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
79977 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
79978 (kgdb_info[cpu].task &&
79979 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
79980 atomic_set(&kgdb_active, -1);
79981 @@ -635,8 +635,8 @@ cpu_master_loop:
79982 }
79983
79984 kgdb_restore:
79985 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
79986 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
79987 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
79988 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
79989 if (kgdb_info[sstep_cpu].task)
79990 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
79991 else
79992 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
79993 static void kgdb_tasklet_bpt(unsigned long ing)
79994 {
79995 kgdb_breakpoint();
79996 - atomic_set(&kgdb_break_tasklet_var, 0);
79997 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
79998 }
79999
80000 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80001
80002 void kgdb_schedule_breakpoint(void)
80003 {
80004 - if (atomic_read(&kgdb_break_tasklet_var) ||
80005 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80006 atomic_read(&kgdb_active) != -1 ||
80007 atomic_read(&kgdb_setting_breakpoint))
80008 return;
80009 - atomic_inc(&kgdb_break_tasklet_var);
80010 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80011 tasklet_schedule(&kgdb_tasklet_breakpoint);
80012 }
80013 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80014 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80015 index 00eb8f7..d7e3244 100644
80016 --- a/kernel/debug/kdb/kdb_main.c
80017 +++ b/kernel/debug/kdb/kdb_main.c
80018 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80019 continue;
80020
80021 kdb_printf("%-20s%8u 0x%p ", mod->name,
80022 - mod->core_size, (void *)mod);
80023 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80024 #ifdef CONFIG_MODULE_UNLOAD
80025 kdb_printf("%4ld ", module_refcount(mod));
80026 #endif
80027 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80028 kdb_printf(" (Loading)");
80029 else
80030 kdb_printf(" (Live)");
80031 - kdb_printf(" 0x%p", mod->module_core);
80032 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80033
80034 #ifdef CONFIG_MODULE_UNLOAD
80035 {
80036 diff --git a/kernel/events/core.c b/kernel/events/core.c
80037 index f86599e..b18b180 100644
80038 --- a/kernel/events/core.c
80039 +++ b/kernel/events/core.c
80040 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80041 * 0 - disallow raw tracepoint access for unpriv
80042 * 1 - disallow cpu events for unpriv
80043 * 2 - disallow kernel profiling for unpriv
80044 + * 3 - disallow all unpriv perf event use
80045 */
80046 -int sysctl_perf_event_paranoid __read_mostly = 1;
80047 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80048 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80049 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80050 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80051 +#else
80052 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80053 +#endif
80054
80055 /* Minimum for 512 kiB + 1 user control page */
80056 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80057 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80058 update_perf_cpu_limits();
80059 }
80060
80061 -static atomic64_t perf_event_id;
80062 +static atomic64_unchecked_t perf_event_id;
80063
80064 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80065 enum event_type_t event_type);
80066 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80067
80068 static inline u64 perf_event_count(struct perf_event *event)
80069 {
80070 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80071 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80072 }
80073
80074 static u64 perf_event_read(struct perf_event *event)
80075 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80076 mutex_lock(&event->child_mutex);
80077 total += perf_event_read(event);
80078 *enabled += event->total_time_enabled +
80079 - atomic64_read(&event->child_total_time_enabled);
80080 + atomic64_read_unchecked(&event->child_total_time_enabled);
80081 *running += event->total_time_running +
80082 - atomic64_read(&event->child_total_time_running);
80083 + atomic64_read_unchecked(&event->child_total_time_running);
80084
80085 list_for_each_entry(child, &event->child_list, child_list) {
80086 total += perf_event_read(child);
80087 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80088 userpg->offset -= local64_read(&event->hw.prev_count);
80089
80090 userpg->time_enabled = enabled +
80091 - atomic64_read(&event->child_total_time_enabled);
80092 + atomic64_read_unchecked(&event->child_total_time_enabled);
80093
80094 userpg->time_running = running +
80095 - atomic64_read(&event->child_total_time_running);
80096 + atomic64_read_unchecked(&event->child_total_time_running);
80097
80098 arch_perf_update_userpage(userpg, now);
80099
80100 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80101
80102 /* Data. */
80103 sp = perf_user_stack_pointer(regs);
80104 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80105 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80106 dyn_size = dump_size - rem;
80107
80108 perf_output_skip(handle, rem);
80109 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80110 values[n++] = perf_event_count(event);
80111 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80112 values[n++] = enabled +
80113 - atomic64_read(&event->child_total_time_enabled);
80114 + atomic64_read_unchecked(&event->child_total_time_enabled);
80115 }
80116 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80117 values[n++] = running +
80118 - atomic64_read(&event->child_total_time_running);
80119 + atomic64_read_unchecked(&event->child_total_time_running);
80120 }
80121 if (read_format & PERF_FORMAT_ID)
80122 values[n++] = primary_event_id(event);
80123 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80124 * need to add enough zero bytes after the string to handle
80125 * the 64bit alignment we do later.
80126 */
80127 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80128 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80129 if (!buf) {
80130 name = strncpy(tmp, "//enomem", sizeof(tmp));
80131 goto got_name;
80132 }
80133 - name = d_path(&file->f_path, buf, PATH_MAX);
80134 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80135 if (IS_ERR(name)) {
80136 name = strncpy(tmp, "//toolong", sizeof(tmp));
80137 goto got_name;
80138 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80139 event->parent = parent_event;
80140
80141 event->ns = get_pid_ns(task_active_pid_ns(current));
80142 - event->id = atomic64_inc_return(&perf_event_id);
80143 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80144
80145 event->state = PERF_EVENT_STATE_INACTIVE;
80146
80147 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80148 if (flags & ~PERF_FLAG_ALL)
80149 return -EINVAL;
80150
80151 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80152 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80153 + return -EACCES;
80154 +#endif
80155 +
80156 err = perf_copy_attr(attr_uptr, &attr);
80157 if (err)
80158 return err;
80159 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80160 /*
80161 * Add back the child's count to the parent's count:
80162 */
80163 - atomic64_add(child_val, &parent_event->child_count);
80164 - atomic64_add(child_event->total_time_enabled,
80165 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80166 + atomic64_add_unchecked(child_event->total_time_enabled,
80167 &parent_event->child_total_time_enabled);
80168 - atomic64_add(child_event->total_time_running,
80169 + atomic64_add_unchecked(child_event->total_time_running,
80170 &parent_event->child_total_time_running);
80171
80172 /*
80173 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80174 index ca65997..60df03d 100644
80175 --- a/kernel/events/internal.h
80176 +++ b/kernel/events/internal.h
80177 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80178 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80179 }
80180
80181 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80182 -static inline unsigned int \
80183 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80184 +static inline unsigned long \
80185 func_name(struct perf_output_handle *handle, \
80186 - const void *buf, unsigned int len) \
80187 + const void user *buf, unsigned long len) \
80188 { \
80189 unsigned long size, written; \
80190 \
80191 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80192 return n;
80193 }
80194
80195 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80196 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80197
80198 #define MEMCPY_SKIP(dst, src, n) (n)
80199
80200 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80201 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80202
80203 #ifndef arch_perf_out_copy_user
80204 #define arch_perf_out_copy_user __copy_from_user_inatomic
80205 #endif
80206
80207 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80208 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80209
80210 /* Callchain handling */
80211 extern struct perf_callchain_entry *
80212 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80213 index ad8e1bd..fed7ba9 100644
80214 --- a/kernel/events/uprobes.c
80215 +++ b/kernel/events/uprobes.c
80216 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80217 {
80218 struct page *page;
80219 uprobe_opcode_t opcode;
80220 - int result;
80221 + long result;
80222
80223 pagefault_disable();
80224 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80225 diff --git a/kernel/exit.c b/kernel/exit.c
80226 index a949819..a5f127d 100644
80227 --- a/kernel/exit.c
80228 +++ b/kernel/exit.c
80229 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80230 struct task_struct *leader;
80231 int zap_leader;
80232 repeat:
80233 +#ifdef CONFIG_NET
80234 + gr_del_task_from_ip_table(p);
80235 +#endif
80236 +
80237 /* don't need to get the RCU readlock here - the process is dead and
80238 * can't be modifying its own credentials. But shut RCU-lockdep up */
80239 rcu_read_lock();
80240 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80241 * know it'll be handled, so that they don't get converted to
80242 * SIGKILL or just silently dropped.
80243 */
80244 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80245 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80246 recalc_sigpending();
80247 spin_unlock_irq(&current->sighand->siglock);
80248 return 0;
80249 @@ -698,6 +702,8 @@ void do_exit(long code)
80250 struct task_struct *tsk = current;
80251 int group_dead;
80252
80253 + set_fs(USER_DS);
80254 +
80255 profile_task_exit(tsk);
80256
80257 WARN_ON(blk_needs_flush_plug(tsk));
80258 @@ -714,7 +720,6 @@ void do_exit(long code)
80259 * mm_release()->clear_child_tid() from writing to a user-controlled
80260 * kernel address.
80261 */
80262 - set_fs(USER_DS);
80263
80264 ptrace_event(PTRACE_EVENT_EXIT, code);
80265
80266 @@ -773,6 +778,9 @@ void do_exit(long code)
80267 tsk->exit_code = code;
80268 taskstats_exit(tsk, group_dead);
80269
80270 + gr_acl_handle_psacct(tsk, code);
80271 + gr_acl_handle_exit();
80272 +
80273 exit_mm(tsk);
80274
80275 if (group_dead)
80276 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80277 * Take down every thread in the group. This is called by fatal signals
80278 * as well as by sys_exit_group (below).
80279 */
80280 -void
80281 +__noreturn void
80282 do_group_exit(int exit_code)
80283 {
80284 struct signal_struct *sig = current->signal;
80285 diff --git a/kernel/fork.c b/kernel/fork.c
80286 index 200a7a2..43e52da 100644
80287 --- a/kernel/fork.c
80288 +++ b/kernel/fork.c
80289 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80290 *stackend = STACK_END_MAGIC; /* for overflow detection */
80291
80292 #ifdef CONFIG_CC_STACKPROTECTOR
80293 - tsk->stack_canary = get_random_int();
80294 + tsk->stack_canary = pax_get_random_long();
80295 #endif
80296
80297 /*
80298 @@ -345,13 +345,81 @@ free_tsk:
80299 }
80300
80301 #ifdef CONFIG_MMU
80302 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80303 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80304 {
80305 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80306 - struct rb_node **rb_link, *rb_parent;
80307 - int retval;
80308 + struct vm_area_struct *tmp;
80309 unsigned long charge;
80310 struct mempolicy *pol;
80311 + struct file *file;
80312 +
80313 + charge = 0;
80314 + if (mpnt->vm_flags & VM_ACCOUNT) {
80315 + unsigned long len = vma_pages(mpnt);
80316 +
80317 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80318 + goto fail_nomem;
80319 + charge = len;
80320 + }
80321 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80322 + if (!tmp)
80323 + goto fail_nomem;
80324 + *tmp = *mpnt;
80325 + tmp->vm_mm = mm;
80326 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80327 + pol = mpol_dup(vma_policy(mpnt));
80328 + if (IS_ERR(pol))
80329 + goto fail_nomem_policy;
80330 + vma_set_policy(tmp, pol);
80331 + if (anon_vma_fork(tmp, mpnt))
80332 + goto fail_nomem_anon_vma_fork;
80333 + tmp->vm_flags &= ~VM_LOCKED;
80334 + tmp->vm_next = tmp->vm_prev = NULL;
80335 + tmp->vm_mirror = NULL;
80336 + file = tmp->vm_file;
80337 + if (file) {
80338 + struct inode *inode = file_inode(file);
80339 + struct address_space *mapping = file->f_mapping;
80340 +
80341 + get_file(file);
80342 + if (tmp->vm_flags & VM_DENYWRITE)
80343 + atomic_dec(&inode->i_writecount);
80344 + mutex_lock(&mapping->i_mmap_mutex);
80345 + if (tmp->vm_flags & VM_SHARED)
80346 + mapping->i_mmap_writable++;
80347 + flush_dcache_mmap_lock(mapping);
80348 + /* insert tmp into the share list, just after mpnt */
80349 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80350 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80351 + else
80352 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80353 + flush_dcache_mmap_unlock(mapping);
80354 + mutex_unlock(&mapping->i_mmap_mutex);
80355 + }
80356 +
80357 + /*
80358 + * Clear hugetlb-related page reserves for children. This only
80359 + * affects MAP_PRIVATE mappings. Faults generated by the child
80360 + * are not guaranteed to succeed, even if read-only
80361 + */
80362 + if (is_vm_hugetlb_page(tmp))
80363 + reset_vma_resv_huge_pages(tmp);
80364 +
80365 + return tmp;
80366 +
80367 +fail_nomem_anon_vma_fork:
80368 + mpol_put(pol);
80369 +fail_nomem_policy:
80370 + kmem_cache_free(vm_area_cachep, tmp);
80371 +fail_nomem:
80372 + vm_unacct_memory(charge);
80373 + return NULL;
80374 +}
80375 +
80376 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80377 +{
80378 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80379 + struct rb_node **rb_link, *rb_parent;
80380 + int retval;
80381
80382 uprobe_start_dup_mmap();
80383 down_write(&oldmm->mmap_sem);
80384 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80385
80386 prev = NULL;
80387 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80388 - struct file *file;
80389 -
80390 if (mpnt->vm_flags & VM_DONTCOPY) {
80391 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80392 -vma_pages(mpnt));
80393 continue;
80394 }
80395 - charge = 0;
80396 - if (mpnt->vm_flags & VM_ACCOUNT) {
80397 - unsigned long len = vma_pages(mpnt);
80398 -
80399 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80400 - goto fail_nomem;
80401 - charge = len;
80402 - }
80403 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80404 - if (!tmp)
80405 - goto fail_nomem;
80406 - *tmp = *mpnt;
80407 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80408 - pol = mpol_dup(vma_policy(mpnt));
80409 - retval = PTR_ERR(pol);
80410 - if (IS_ERR(pol))
80411 - goto fail_nomem_policy;
80412 - vma_set_policy(tmp, pol);
80413 - tmp->vm_mm = mm;
80414 - if (anon_vma_fork(tmp, mpnt))
80415 - goto fail_nomem_anon_vma_fork;
80416 - tmp->vm_flags &= ~VM_LOCKED;
80417 - tmp->vm_next = tmp->vm_prev = NULL;
80418 - file = tmp->vm_file;
80419 - if (file) {
80420 - struct inode *inode = file_inode(file);
80421 - struct address_space *mapping = file->f_mapping;
80422 -
80423 - get_file(file);
80424 - if (tmp->vm_flags & VM_DENYWRITE)
80425 - atomic_dec(&inode->i_writecount);
80426 - mutex_lock(&mapping->i_mmap_mutex);
80427 - if (tmp->vm_flags & VM_SHARED)
80428 - mapping->i_mmap_writable++;
80429 - flush_dcache_mmap_lock(mapping);
80430 - /* insert tmp into the share list, just after mpnt */
80431 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80432 - vma_nonlinear_insert(tmp,
80433 - &mapping->i_mmap_nonlinear);
80434 - else
80435 - vma_interval_tree_insert_after(tmp, mpnt,
80436 - &mapping->i_mmap);
80437 - flush_dcache_mmap_unlock(mapping);
80438 - mutex_unlock(&mapping->i_mmap_mutex);
80439 + tmp = dup_vma(mm, oldmm, mpnt);
80440 + if (!tmp) {
80441 + retval = -ENOMEM;
80442 + goto out;
80443 }
80444
80445 /*
80446 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80447 if (retval)
80448 goto out;
80449 }
80450 +
80451 +#ifdef CONFIG_PAX_SEGMEXEC
80452 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80453 + struct vm_area_struct *mpnt_m;
80454 +
80455 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80456 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80457 +
80458 + if (!mpnt->vm_mirror)
80459 + continue;
80460 +
80461 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80462 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80463 + mpnt->vm_mirror = mpnt_m;
80464 + } else {
80465 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80466 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80467 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80468 + mpnt->vm_mirror->vm_mirror = mpnt;
80469 + }
80470 + }
80471 + BUG_ON(mpnt_m);
80472 + }
80473 +#endif
80474 +
80475 /* a new mm has just been created */
80476 arch_dup_mmap(oldmm, mm);
80477 retval = 0;
80478 @@ -471,14 +522,6 @@ out:
80479 up_write(&oldmm->mmap_sem);
80480 uprobe_end_dup_mmap();
80481 return retval;
80482 -fail_nomem_anon_vma_fork:
80483 - mpol_put(pol);
80484 -fail_nomem_policy:
80485 - kmem_cache_free(vm_area_cachep, tmp);
80486 -fail_nomem:
80487 - retval = -ENOMEM;
80488 - vm_unacct_memory(charge);
80489 - goto out;
80490 }
80491
80492 static inline int mm_alloc_pgd(struct mm_struct *mm)
80493 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80494 return ERR_PTR(err);
80495
80496 mm = get_task_mm(task);
80497 - if (mm && mm != current->mm &&
80498 - !ptrace_may_access(task, mode)) {
80499 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80500 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80501 mmput(mm);
80502 mm = ERR_PTR(-EACCES);
80503 }
80504 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80505 spin_unlock(&fs->lock);
80506 return -EAGAIN;
80507 }
80508 - fs->users++;
80509 + atomic_inc(&fs->users);
80510 spin_unlock(&fs->lock);
80511 return 0;
80512 }
80513 tsk->fs = copy_fs_struct(fs);
80514 if (!tsk->fs)
80515 return -ENOMEM;
80516 + /* Carry through gr_chroot_dentry and is_chrooted instead
80517 + of recomputing it here. Already copied when the task struct
80518 + is duplicated. This allows pivot_root to not be treated as
80519 + a chroot
80520 + */
80521 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80522 +
80523 return 0;
80524 }
80525
80526 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80527 * parts of the process environment (as per the clone
80528 * flags). The actual kick-off is left to the caller.
80529 */
80530 -static struct task_struct *copy_process(unsigned long clone_flags,
80531 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80532 unsigned long stack_start,
80533 unsigned long stack_size,
80534 int __user *child_tidptr,
80535 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80536 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80537 #endif
80538 retval = -EAGAIN;
80539 +
80540 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80541 +
80542 if (atomic_read(&p->real_cred->user->processes) >=
80543 task_rlimit(p, RLIMIT_NPROC)) {
80544 if (p->real_cred->user != INIT_USER &&
80545 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80546 goto bad_fork_free_pid;
80547 }
80548
80549 + /* synchronizes with gr_set_acls()
80550 + we need to call this past the point of no return for fork()
80551 + */
80552 + gr_copy_label(p);
80553 +
80554 if (likely(p->pid)) {
80555 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80556
80557 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80558 bad_fork_free:
80559 free_task(p);
80560 fork_out:
80561 + gr_log_forkfail(retval);
80562 +
80563 return ERR_PTR(retval);
80564 }
80565
80566 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80567
80568 p = copy_process(clone_flags, stack_start, stack_size,
80569 child_tidptr, NULL, trace);
80570 + add_latent_entropy();
80571 /*
80572 * Do this prior waking up the new thread - the thread pointer
80573 * might get invalid after that point, if the thread exits quickly.
80574 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80575 if (clone_flags & CLONE_PARENT_SETTID)
80576 put_user(nr, parent_tidptr);
80577
80578 + gr_handle_brute_check();
80579 +
80580 if (clone_flags & CLONE_VFORK) {
80581 p->vfork_done = &vfork;
80582 init_completion(&vfork);
80583 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80584 mm_cachep = kmem_cache_create("mm_struct",
80585 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80586 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80587 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80588 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80589 mmap_init();
80590 nsproxy_cache_init();
80591 }
80592 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80593 return 0;
80594
80595 /* don't need lock here; in the worst case we'll do useless copy */
80596 - if (fs->users == 1)
80597 + if (atomic_read(&fs->users) == 1)
80598 return 0;
80599
80600 *new_fsp = copy_fs_struct(fs);
80601 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80602 fs = current->fs;
80603 spin_lock(&fs->lock);
80604 current->fs = new_fs;
80605 - if (--fs->users)
80606 + gr_set_chroot_entries(current, &current->fs->root);
80607 + if (atomic_dec_return(&fs->users))
80608 new_fs = NULL;
80609 else
80610 new_fs = fs;
80611 diff --git a/kernel/futex.c b/kernel/futex.c
80612 index c3a1a55..e32b4a98 100644
80613 --- a/kernel/futex.c
80614 +++ b/kernel/futex.c
80615 @@ -54,6 +54,7 @@
80616 #include <linux/mount.h>
80617 #include <linux/pagemap.h>
80618 #include <linux/syscalls.h>
80619 +#include <linux/ptrace.h>
80620 #include <linux/signal.h>
80621 #include <linux/export.h>
80622 #include <linux/magic.h>
80623 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80624 struct page *page, *page_head;
80625 int err, ro = 0;
80626
80627 +#ifdef CONFIG_PAX_SEGMEXEC
80628 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80629 + return -EFAULT;
80630 +#endif
80631 +
80632 /*
80633 * The futex address must be "naturally" aligned.
80634 */
80635 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80636
80637 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80638 {
80639 - int ret;
80640 + unsigned long ret;
80641
80642 pagefault_disable();
80643 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80644 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80645 {
80646 u32 curval;
80647 int i;
80648 + mm_segment_t oldfs;
80649
80650 /*
80651 * This will fail and we want it. Some arch implementations do
80652 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80653 * implementation, the non-functional ones will return
80654 * -ENOSYS.
80655 */
80656 + oldfs = get_fs();
80657 + set_fs(USER_DS);
80658 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80659 futex_cmpxchg_enabled = 1;
80660 + set_fs(oldfs);
80661
80662 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80663 plist_head_init(&futex_queues[i].chain);
80664 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80665 index f9f44fd..29885e4 100644
80666 --- a/kernel/futex_compat.c
80667 +++ b/kernel/futex_compat.c
80668 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80669 return 0;
80670 }
80671
80672 -static void __user *futex_uaddr(struct robust_list __user *entry,
80673 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80674 compat_long_t futex_offset)
80675 {
80676 compat_uptr_t base = ptr_to_compat(entry);
80677 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80678 index 9b22d03..6295b62 100644
80679 --- a/kernel/gcov/base.c
80680 +++ b/kernel/gcov/base.c
80681 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80682 }
80683
80684 #ifdef CONFIG_MODULES
80685 -static inline int within(void *addr, void *start, unsigned long size)
80686 -{
80687 - return ((addr >= start) && (addr < start + size));
80688 -}
80689 -
80690 /* Update list and generate events when modules are unloaded. */
80691 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80692 void *data)
80693 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80694 prev = NULL;
80695 /* Remove entries located in module from linked list. */
80696 for (info = gcov_info_head; info; info = info->next) {
80697 - if (within(info, mod->module_core, mod->core_size)) {
80698 + if (within_module_core_rw((unsigned long)info, mod)) {
80699 if (prev)
80700 prev->next = info->next;
80701 else
80702 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80703 index 383319b..56ebb13 100644
80704 --- a/kernel/hrtimer.c
80705 +++ b/kernel/hrtimer.c
80706 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80707 local_irq_restore(flags);
80708 }
80709
80710 -static void run_hrtimer_softirq(struct softirq_action *h)
80711 +static __latent_entropy void run_hrtimer_softirq(void)
80712 {
80713 hrtimer_peek_ahead_timers();
80714 }
80715 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80716 index 55fcce6..0e4cf34 100644
80717 --- a/kernel/irq_work.c
80718 +++ b/kernel/irq_work.c
80719 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80720 return NOTIFY_OK;
80721 }
80722
80723 -static struct notifier_block cpu_notify;
80724 +static struct notifier_block cpu_notify = {
80725 + .notifier_call = irq_work_cpu_notify,
80726 + .priority = 0,
80727 +};
80728
80729 static __init int irq_work_init_cpu_notifier(void)
80730 {
80731 - cpu_notify.notifier_call = irq_work_cpu_notify;
80732 - cpu_notify.priority = 0;
80733 register_cpu_notifier(&cpu_notify);
80734 return 0;
80735 }
80736 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80737 index 60f48fa..7f3a770 100644
80738 --- a/kernel/jump_label.c
80739 +++ b/kernel/jump_label.c
80740 @@ -13,6 +13,7 @@
80741 #include <linux/sort.h>
80742 #include <linux/err.h>
80743 #include <linux/static_key.h>
80744 +#include <linux/mm.h>
80745
80746 #ifdef HAVE_JUMP_LABEL
80747
80748 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80749
80750 size = (((unsigned long)stop - (unsigned long)start)
80751 / sizeof(struct jump_entry));
80752 + pax_open_kernel();
80753 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80754 + pax_close_kernel();
80755 }
80756
80757 static void jump_label_update(struct static_key *key, int enable);
80758 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80759 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80760 struct jump_entry *iter;
80761
80762 + pax_open_kernel();
80763 for (iter = iter_start; iter < iter_stop; iter++) {
80764 if (within_module_init(iter->code, mod))
80765 iter->code = 0;
80766 }
80767 + pax_close_kernel();
80768 }
80769
80770 static int
80771 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80772 index 3127ad5..159d880 100644
80773 --- a/kernel/kallsyms.c
80774 +++ b/kernel/kallsyms.c
80775 @@ -11,6 +11,9 @@
80776 * Changed the compression method from stem compression to "table lookup"
80777 * compression (see scripts/kallsyms.c for a more complete description)
80778 */
80779 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80780 +#define __INCLUDED_BY_HIDESYM 1
80781 +#endif
80782 #include <linux/kallsyms.h>
80783 #include <linux/module.h>
80784 #include <linux/init.h>
80785 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80786
80787 static inline int is_kernel_inittext(unsigned long addr)
80788 {
80789 + if (system_state != SYSTEM_BOOTING)
80790 + return 0;
80791 +
80792 if (addr >= (unsigned long)_sinittext
80793 && addr <= (unsigned long)_einittext)
80794 return 1;
80795 return 0;
80796 }
80797
80798 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80799 +#ifdef CONFIG_MODULES
80800 +static inline int is_module_text(unsigned long addr)
80801 +{
80802 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80803 + return 1;
80804 +
80805 + addr = ktla_ktva(addr);
80806 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80807 +}
80808 +#else
80809 +static inline int is_module_text(unsigned long addr)
80810 +{
80811 + return 0;
80812 +}
80813 +#endif
80814 +#endif
80815 +
80816 static inline int is_kernel_text(unsigned long addr)
80817 {
80818 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80819 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80820
80821 static inline int is_kernel(unsigned long addr)
80822 {
80823 +
80824 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80825 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80826 + return 1;
80827 +
80828 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80829 +#else
80830 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80831 +#endif
80832 +
80833 return 1;
80834 return in_gate_area_no_mm(addr);
80835 }
80836
80837 static int is_ksym_addr(unsigned long addr)
80838 {
80839 +
80840 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80841 + if (is_module_text(addr))
80842 + return 0;
80843 +#endif
80844 +
80845 if (all_var)
80846 return is_kernel(addr);
80847
80848 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80849
80850 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80851 {
80852 - iter->name[0] = '\0';
80853 iter->nameoff = get_symbol_offset(new_pos);
80854 iter->pos = new_pos;
80855 }
80856 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80857 {
80858 struct kallsym_iter *iter = m->private;
80859
80860 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80861 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80862 + return 0;
80863 +#endif
80864 +
80865 /* Some debugging symbols have no name. Ignore them. */
80866 if (!iter->name[0])
80867 return 0;
80868 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80869 */
80870 type = iter->exported ? toupper(iter->type) :
80871 tolower(iter->type);
80872 +
80873 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80874 type, iter->name, iter->module_name);
80875 } else
80876 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80877 struct kallsym_iter *iter;
80878 int ret;
80879
80880 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80881 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80882 if (!iter)
80883 return -ENOMEM;
80884 reset_iter(iter, 0);
80885 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80886 index e30ac0f..3528cac 100644
80887 --- a/kernel/kcmp.c
80888 +++ b/kernel/kcmp.c
80889 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80890 struct task_struct *task1, *task2;
80891 int ret;
80892
80893 +#ifdef CONFIG_GRKERNSEC
80894 + return -ENOSYS;
80895 +#endif
80896 +
80897 rcu_read_lock();
80898
80899 /*
80900 diff --git a/kernel/kexec.c b/kernel/kexec.c
80901 index 59f7b55..4022f65 100644
80902 --- a/kernel/kexec.c
80903 +++ b/kernel/kexec.c
80904 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
80905 unsigned long flags)
80906 {
80907 struct compat_kexec_segment in;
80908 - struct kexec_segment out, __user *ksegments;
80909 + struct kexec_segment out;
80910 + struct kexec_segment __user *ksegments;
80911 unsigned long i, result;
80912
80913 /* Don't allow clients that don't understand the native
80914 diff --git a/kernel/kmod.c b/kernel/kmod.c
80915 index fb32636..2fe8775 100644
80916 --- a/kernel/kmod.c
80917 +++ b/kernel/kmod.c
80918 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
80919 kfree(info->argv);
80920 }
80921
80922 -static int call_modprobe(char *module_name, int wait)
80923 +static int call_modprobe(char *module_name, char *module_param, int wait)
80924 {
80925 struct subprocess_info *info;
80926 static char *envp[] = {
80927 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
80928 NULL
80929 };
80930
80931 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
80932 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
80933 if (!argv)
80934 goto out;
80935
80936 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
80937 argv[1] = "-q";
80938 argv[2] = "--";
80939 argv[3] = module_name; /* check free_modprobe_argv() */
80940 - argv[4] = NULL;
80941 + argv[4] = module_param;
80942 + argv[5] = NULL;
80943
80944 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
80945 NULL, free_modprobe_argv, NULL);
80946 @@ -129,9 +130,8 @@ out:
80947 * If module auto-loading support is disabled then this function
80948 * becomes a no-operation.
80949 */
80950 -int __request_module(bool wait, const char *fmt, ...)
80951 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
80952 {
80953 - va_list args;
80954 char module_name[MODULE_NAME_LEN];
80955 unsigned int max_modprobes;
80956 int ret;
80957 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
80958 if (!modprobe_path[0])
80959 return 0;
80960
80961 - va_start(args, fmt);
80962 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
80963 - va_end(args);
80964 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
80965 if (ret >= MODULE_NAME_LEN)
80966 return -ENAMETOOLONG;
80967
80968 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
80969 if (ret)
80970 return ret;
80971
80972 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80973 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
80974 + /* hack to workaround consolekit/udisks stupidity */
80975 + read_lock(&tasklist_lock);
80976 + if (!strcmp(current->comm, "mount") &&
80977 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
80978 + read_unlock(&tasklist_lock);
80979 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
80980 + return -EPERM;
80981 + }
80982 + read_unlock(&tasklist_lock);
80983 + }
80984 +#endif
80985 +
80986 /* If modprobe needs a service that is in a module, we get a recursive
80987 * loop. Limit the number of running kmod threads to max_threads/2 or
80988 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
80989 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
80990
80991 trace_module_request(module_name, wait, _RET_IP_);
80992
80993 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80994 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80995
80996 atomic_dec(&kmod_concurrent);
80997 return ret;
80998 }
80999 +
81000 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81001 +{
81002 + va_list args;
81003 + int ret;
81004 +
81005 + va_start(args, fmt);
81006 + ret = ____request_module(wait, module_param, fmt, args);
81007 + va_end(args);
81008 +
81009 + return ret;
81010 +}
81011 +
81012 +int __request_module(bool wait, const char *fmt, ...)
81013 +{
81014 + va_list args;
81015 + int ret;
81016 +
81017 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81018 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81019 + char module_param[MODULE_NAME_LEN];
81020 +
81021 + memset(module_param, 0, sizeof(module_param));
81022 +
81023 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81024 +
81025 + va_start(args, fmt);
81026 + ret = ____request_module(wait, module_param, fmt, args);
81027 + va_end(args);
81028 +
81029 + return ret;
81030 + }
81031 +#endif
81032 +
81033 + va_start(args, fmt);
81034 + ret = ____request_module(wait, NULL, fmt, args);
81035 + va_end(args);
81036 +
81037 + return ret;
81038 +}
81039 +
81040 EXPORT_SYMBOL(__request_module);
81041 #endif /* CONFIG_MODULES */
81042
81043 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81044 *
81045 * Thus the __user pointer cast is valid here.
81046 */
81047 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81048 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81049
81050 /*
81051 * If ret is 0, either ____call_usermodehelper failed and the
81052 @@ -646,7 +699,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81053 static int proc_cap_handler(struct ctl_table *table, int write,
81054 void __user *buffer, size_t *lenp, loff_t *ppos)
81055 {
81056 - struct ctl_table t;
81057 + ctl_table_no_const t;
81058 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81059 kernel_cap_t new_cap;
81060 int err, i;
81061 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81062 index 6e33498..3133bd3 100644
81063 --- a/kernel/kprobes.c
81064 +++ b/kernel/kprobes.c
81065 @@ -31,6 +31,9 @@
81066 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81067 * <prasanna@in.ibm.com> added function-return probes.
81068 */
81069 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81070 +#define __INCLUDED_BY_HIDESYM 1
81071 +#endif
81072 #include <linux/kprobes.h>
81073 #include <linux/hash.h>
81074 #include <linux/init.h>
81075 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81076 * kernel image and loaded module images reside. This is required
81077 * so x86_64 can correctly handle the %rip-relative fixups.
81078 */
81079 - kip->insns = module_alloc(PAGE_SIZE);
81080 + kip->insns = module_alloc_exec(PAGE_SIZE);
81081 if (!kip->insns) {
81082 kfree(kip);
81083 return NULL;
81084 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81085 */
81086 if (!list_is_singular(&kip->list)) {
81087 list_del(&kip->list);
81088 - module_free(NULL, kip->insns);
81089 + module_free_exec(NULL, kip->insns);
81090 kfree(kip);
81091 }
81092 return 1;
81093 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81094 {
81095 int i, err = 0;
81096 unsigned long offset = 0, size = 0;
81097 - char *modname, namebuf[128];
81098 + char *modname, namebuf[KSYM_NAME_LEN];
81099 const char *symbol_name;
81100 void *addr;
81101 struct kprobe_blackpoint *kb;
81102 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81103 kprobe_type = "k";
81104
81105 if (sym)
81106 - seq_printf(pi, "%p %s %s+0x%x %s ",
81107 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81108 p->addr, kprobe_type, sym, offset,
81109 (modname ? modname : " "));
81110 else
81111 - seq_printf(pi, "%p %s %p ",
81112 + seq_printf(pi, "%pK %s %pK ",
81113 p->addr, kprobe_type, p->addr);
81114
81115 if (!pp)
81116 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81117 const char *sym = NULL;
81118 unsigned int i = *(loff_t *) v;
81119 unsigned long offset = 0;
81120 - char *modname, namebuf[128];
81121 + char *modname, namebuf[KSYM_NAME_LEN];
81122
81123 head = &kprobe_table[i];
81124 preempt_disable();
81125 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81126 index 6ada93c..dce7d5d 100644
81127 --- a/kernel/ksysfs.c
81128 +++ b/kernel/ksysfs.c
81129 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81130 {
81131 if (count+1 > UEVENT_HELPER_PATH_LEN)
81132 return -ENOENT;
81133 + if (!capable(CAP_SYS_ADMIN))
81134 + return -EPERM;
81135 memcpy(uevent_helper, buf, count);
81136 uevent_helper[count] = '\0';
81137 if (count && uevent_helper[count-1] == '\n')
81138 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81139 return count;
81140 }
81141
81142 -static struct bin_attribute notes_attr = {
81143 +static bin_attribute_no_const notes_attr __read_only = {
81144 .attr = {
81145 .name = "notes",
81146 .mode = S_IRUGO,
81147 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81148 index e16c45b..6f49c48 100644
81149 --- a/kernel/lockdep.c
81150 +++ b/kernel/lockdep.c
81151 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81152 end = (unsigned long) &_end,
81153 addr = (unsigned long) obj;
81154
81155 +#ifdef CONFIG_PAX_KERNEXEC
81156 + start = ktla_ktva(start);
81157 +#endif
81158 +
81159 /*
81160 * static variable?
81161 */
81162 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81163 if (!static_obj(lock->key)) {
81164 debug_locks_off();
81165 printk("INFO: trying to register non-static key.\n");
81166 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81167 printk("the code is fine but needs lockdep annotation.\n");
81168 printk("turning off the locking correctness validator.\n");
81169 dump_stack();
81170 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81171 if (!class)
81172 return 0;
81173 }
81174 - atomic_inc((atomic_t *)&class->ops);
81175 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81176 if (very_verbose(class)) {
81177 printk("\nacquire class [%p] %s", class->key, class->name);
81178 if (class->name_version > 1)
81179 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81180 index b2c71c5..7b88d63 100644
81181 --- a/kernel/lockdep_proc.c
81182 +++ b/kernel/lockdep_proc.c
81183 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81184 return 0;
81185 }
81186
81187 - seq_printf(m, "%p", class->key);
81188 + seq_printf(m, "%pK", class->key);
81189 #ifdef CONFIG_DEBUG_LOCKDEP
81190 seq_printf(m, " OPS:%8ld", class->ops);
81191 #endif
81192 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81193
81194 list_for_each_entry(entry, &class->locks_after, entry) {
81195 if (entry->distance == 1) {
81196 - seq_printf(m, " -> [%p] ", entry->class->key);
81197 + seq_printf(m, " -> [%pK] ", entry->class->key);
81198 print_name(m, entry->class);
81199 seq_puts(m, "\n");
81200 }
81201 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81202 if (!class->key)
81203 continue;
81204
81205 - seq_printf(m, "[%p] ", class->key);
81206 + seq_printf(m, "[%pK] ", class->key);
81207 print_name(m, class);
81208 seq_puts(m, "\n");
81209 }
81210 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81211 if (!i)
81212 seq_line(m, '-', 40-namelen, namelen);
81213
81214 - snprintf(ip, sizeof(ip), "[<%p>]",
81215 + snprintf(ip, sizeof(ip), "[<%pK>]",
81216 (void *)class->contention_point[i]);
81217 seq_printf(m, "%40s %14lu %29s %pS\n",
81218 name, stats->contention_point[i],
81219 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81220 if (!i)
81221 seq_line(m, '-', 40-namelen, namelen);
81222
81223 - snprintf(ip, sizeof(ip), "[<%p>]",
81224 + snprintf(ip, sizeof(ip), "[<%pK>]",
81225 (void *)class->contending_point[i]);
81226 seq_printf(m, "%40s %14lu %29s %pS\n",
81227 name, stats->contending_point[i],
81228 diff --git a/kernel/module.c b/kernel/module.c
81229 index 2069158..71101bb 100644
81230 --- a/kernel/module.c
81231 +++ b/kernel/module.c
81232 @@ -61,6 +61,7 @@
81233 #include <linux/pfn.h>
81234 #include <linux/bsearch.h>
81235 #include <linux/fips.h>
81236 +#include <linux/grsecurity.h>
81237 #include <uapi/linux/module.h>
81238 #include "module-internal.h"
81239
81240 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81241
81242 /* Bounds of module allocation, for speeding __module_address.
81243 * Protected by module_mutex. */
81244 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81245 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81246 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81247
81248 int register_module_notifier(struct notifier_block * nb)
81249 {
81250 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81251 return true;
81252
81253 list_for_each_entry_rcu(mod, &modules, list) {
81254 - struct symsearch arr[] = {
81255 + struct symsearch modarr[] = {
81256 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81257 NOT_GPL_ONLY, false },
81258 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81259 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81260 if (mod->state == MODULE_STATE_UNFORMED)
81261 continue;
81262
81263 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81264 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81265 return true;
81266 }
81267 return false;
81268 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81269 if (!pcpusec->sh_size)
81270 return 0;
81271
81272 - if (align > PAGE_SIZE) {
81273 + if (align-1 >= PAGE_SIZE) {
81274 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81275 mod->name, align, PAGE_SIZE);
81276 align = PAGE_SIZE;
81277 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81278 static ssize_t show_coresize(struct module_attribute *mattr,
81279 struct module_kobject *mk, char *buffer)
81280 {
81281 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81282 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81283 }
81284
81285 static struct module_attribute modinfo_coresize =
81286 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81287 static ssize_t show_initsize(struct module_attribute *mattr,
81288 struct module_kobject *mk, char *buffer)
81289 {
81290 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81291 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81292 }
81293
81294 static struct module_attribute modinfo_initsize =
81295 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81296 */
81297 #ifdef CONFIG_SYSFS
81298
81299 -#ifdef CONFIG_KALLSYMS
81300 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81301 static inline bool sect_empty(const Elf_Shdr *sect)
81302 {
81303 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81304 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81305 {
81306 unsigned int notes, loaded, i;
81307 struct module_notes_attrs *notes_attrs;
81308 - struct bin_attribute *nattr;
81309 + bin_attribute_no_const *nattr;
81310
81311 /* failed to create section attributes, so can't create notes */
81312 if (!mod->sect_attrs)
81313 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81314 static int module_add_modinfo_attrs(struct module *mod)
81315 {
81316 struct module_attribute *attr;
81317 - struct module_attribute *temp_attr;
81318 + module_attribute_no_const *temp_attr;
81319 int error = 0;
81320 int i;
81321
81322 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81323
81324 static void unset_module_core_ro_nx(struct module *mod)
81325 {
81326 - set_page_attributes(mod->module_core + mod->core_text_size,
81327 - mod->module_core + mod->core_size,
81328 + set_page_attributes(mod->module_core_rw,
81329 + mod->module_core_rw + mod->core_size_rw,
81330 set_memory_x);
81331 - set_page_attributes(mod->module_core,
81332 - mod->module_core + mod->core_ro_size,
81333 + set_page_attributes(mod->module_core_rx,
81334 + mod->module_core_rx + mod->core_size_rx,
81335 set_memory_rw);
81336 }
81337
81338 static void unset_module_init_ro_nx(struct module *mod)
81339 {
81340 - set_page_attributes(mod->module_init + mod->init_text_size,
81341 - mod->module_init + mod->init_size,
81342 + set_page_attributes(mod->module_init_rw,
81343 + mod->module_init_rw + mod->init_size_rw,
81344 set_memory_x);
81345 - set_page_attributes(mod->module_init,
81346 - mod->module_init + mod->init_ro_size,
81347 + set_page_attributes(mod->module_init_rx,
81348 + mod->module_init_rx + mod->init_size_rx,
81349 set_memory_rw);
81350 }
81351
81352 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81353 list_for_each_entry_rcu(mod, &modules, list) {
81354 if (mod->state == MODULE_STATE_UNFORMED)
81355 continue;
81356 - if ((mod->module_core) && (mod->core_text_size)) {
81357 - set_page_attributes(mod->module_core,
81358 - mod->module_core + mod->core_text_size,
81359 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81360 + set_page_attributes(mod->module_core_rx,
81361 + mod->module_core_rx + mod->core_size_rx,
81362 set_memory_rw);
81363 }
81364 - if ((mod->module_init) && (mod->init_text_size)) {
81365 - set_page_attributes(mod->module_init,
81366 - mod->module_init + mod->init_text_size,
81367 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81368 + set_page_attributes(mod->module_init_rx,
81369 + mod->module_init_rx + mod->init_size_rx,
81370 set_memory_rw);
81371 }
81372 }
81373 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81374 list_for_each_entry_rcu(mod, &modules, list) {
81375 if (mod->state == MODULE_STATE_UNFORMED)
81376 continue;
81377 - if ((mod->module_core) && (mod->core_text_size)) {
81378 - set_page_attributes(mod->module_core,
81379 - mod->module_core + mod->core_text_size,
81380 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81381 + set_page_attributes(mod->module_core_rx,
81382 + mod->module_core_rx + mod->core_size_rx,
81383 set_memory_ro);
81384 }
81385 - if ((mod->module_init) && (mod->init_text_size)) {
81386 - set_page_attributes(mod->module_init,
81387 - mod->module_init + mod->init_text_size,
81388 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81389 + set_page_attributes(mod->module_init_rx,
81390 + mod->module_init_rx + mod->init_size_rx,
81391 set_memory_ro);
81392 }
81393 }
81394 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81395
81396 /* This may be NULL, but that's OK */
81397 unset_module_init_ro_nx(mod);
81398 - module_free(mod, mod->module_init);
81399 + module_free(mod, mod->module_init_rw);
81400 + module_free_exec(mod, mod->module_init_rx);
81401 kfree(mod->args);
81402 percpu_modfree(mod);
81403
81404 /* Free lock-classes: */
81405 - lockdep_free_key_range(mod->module_core, mod->core_size);
81406 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81407 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81408
81409 /* Finally, free the core (containing the module structure) */
81410 unset_module_core_ro_nx(mod);
81411 - module_free(mod, mod->module_core);
81412 + module_free_exec(mod, mod->module_core_rx);
81413 + module_free(mod, mod->module_core_rw);
81414
81415 #ifdef CONFIG_MPU
81416 update_protections(current->mm);
81417 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81418 int ret = 0;
81419 const struct kernel_symbol *ksym;
81420
81421 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81422 + int is_fs_load = 0;
81423 + int register_filesystem_found = 0;
81424 + char *p;
81425 +
81426 + p = strstr(mod->args, "grsec_modharden_fs");
81427 + if (p) {
81428 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81429 + /* copy \0 as well */
81430 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81431 + is_fs_load = 1;
81432 + }
81433 +#endif
81434 +
81435 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81436 const char *name = info->strtab + sym[i].st_name;
81437
81438 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81439 + /* it's a real shame this will never get ripped and copied
81440 + upstream! ;(
81441 + */
81442 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81443 + register_filesystem_found = 1;
81444 +#endif
81445 +
81446 switch (sym[i].st_shndx) {
81447 case SHN_COMMON:
81448 /* We compiled with -fno-common. These are not
81449 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81450 ksym = resolve_symbol_wait(mod, info, name);
81451 /* Ok if resolved. */
81452 if (ksym && !IS_ERR(ksym)) {
81453 + pax_open_kernel();
81454 sym[i].st_value = ksym->value;
81455 + pax_close_kernel();
81456 break;
81457 }
81458
81459 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81460 secbase = (unsigned long)mod_percpu(mod);
81461 else
81462 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81463 + pax_open_kernel();
81464 sym[i].st_value += secbase;
81465 + pax_close_kernel();
81466 break;
81467 }
81468 }
81469
81470 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81471 + if (is_fs_load && !register_filesystem_found) {
81472 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81473 + ret = -EPERM;
81474 + }
81475 +#endif
81476 +
81477 return ret;
81478 }
81479
81480 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81481 || s->sh_entsize != ~0UL
81482 || strstarts(sname, ".init"))
81483 continue;
81484 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81485 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81486 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81487 + else
81488 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81489 pr_debug("\t%s\n", sname);
81490 }
81491 - switch (m) {
81492 - case 0: /* executable */
81493 - mod->core_size = debug_align(mod->core_size);
81494 - mod->core_text_size = mod->core_size;
81495 - break;
81496 - case 1: /* RO: text and ro-data */
81497 - mod->core_size = debug_align(mod->core_size);
81498 - mod->core_ro_size = mod->core_size;
81499 - break;
81500 - case 3: /* whole core */
81501 - mod->core_size = debug_align(mod->core_size);
81502 - break;
81503 - }
81504 }
81505
81506 pr_debug("Init section allocation order:\n");
81507 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81508 || s->sh_entsize != ~0UL
81509 || !strstarts(sname, ".init"))
81510 continue;
81511 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81512 - | INIT_OFFSET_MASK);
81513 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81514 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81515 + else
81516 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81517 + s->sh_entsize |= INIT_OFFSET_MASK;
81518 pr_debug("\t%s\n", sname);
81519 }
81520 - switch (m) {
81521 - case 0: /* executable */
81522 - mod->init_size = debug_align(mod->init_size);
81523 - mod->init_text_size = mod->init_size;
81524 - break;
81525 - case 1: /* RO: text and ro-data */
81526 - mod->init_size = debug_align(mod->init_size);
81527 - mod->init_ro_size = mod->init_size;
81528 - break;
81529 - case 3: /* whole init */
81530 - mod->init_size = debug_align(mod->init_size);
81531 - break;
81532 - }
81533 }
81534 }
81535
81536 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81537
81538 /* Put symbol section at end of init part of module. */
81539 symsect->sh_flags |= SHF_ALLOC;
81540 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81541 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81542 info->index.sym) | INIT_OFFSET_MASK;
81543 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81544
81545 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81546 }
81547
81548 /* Append room for core symbols at end of core part. */
81549 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81550 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81551 - mod->core_size += strtab_size;
81552 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81553 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81554 + mod->core_size_rx += strtab_size;
81555
81556 /* Put string table section at end of init part of module. */
81557 strsect->sh_flags |= SHF_ALLOC;
81558 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81559 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81560 info->index.str) | INIT_OFFSET_MASK;
81561 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81562 }
81563 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81564 /* Make sure we get permanent strtab: don't use info->strtab. */
81565 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81566
81567 + pax_open_kernel();
81568 +
81569 /* Set types up while we still have access to sections. */
81570 for (i = 0; i < mod->num_symtab; i++)
81571 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81572
81573 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81574 - mod->core_strtab = s = mod->module_core + info->stroffs;
81575 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81576 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81577 src = mod->symtab;
81578 for (ndst = i = 0; i < mod->num_symtab; i++) {
81579 if (i == 0 ||
81580 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81581 }
81582 }
81583 mod->core_num_syms = ndst;
81584 +
81585 + pax_close_kernel();
81586 }
81587 #else
81588 static inline void layout_symtab(struct module *mod, struct load_info *info)
81589 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81590 return vmalloc_exec(size);
81591 }
81592
81593 -static void *module_alloc_update_bounds(unsigned long size)
81594 +static void *module_alloc_update_bounds_rw(unsigned long size)
81595 {
81596 void *ret = module_alloc(size);
81597
81598 if (ret) {
81599 mutex_lock(&module_mutex);
81600 /* Update module bounds. */
81601 - if ((unsigned long)ret < module_addr_min)
81602 - module_addr_min = (unsigned long)ret;
81603 - if ((unsigned long)ret + size > module_addr_max)
81604 - module_addr_max = (unsigned long)ret + size;
81605 + if ((unsigned long)ret < module_addr_min_rw)
81606 + module_addr_min_rw = (unsigned long)ret;
81607 + if ((unsigned long)ret + size > module_addr_max_rw)
81608 + module_addr_max_rw = (unsigned long)ret + size;
81609 + mutex_unlock(&module_mutex);
81610 + }
81611 + return ret;
81612 +}
81613 +
81614 +static void *module_alloc_update_bounds_rx(unsigned long size)
81615 +{
81616 + void *ret = module_alloc_exec(size);
81617 +
81618 + if (ret) {
81619 + mutex_lock(&module_mutex);
81620 + /* Update module bounds. */
81621 + if ((unsigned long)ret < module_addr_min_rx)
81622 + module_addr_min_rx = (unsigned long)ret;
81623 + if ((unsigned long)ret + size > module_addr_max_rx)
81624 + module_addr_max_rx = (unsigned long)ret + size;
81625 mutex_unlock(&module_mutex);
81626 }
81627 return ret;
81628 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81629 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81630 {
81631 const char *modmagic = get_modinfo(info, "vermagic");
81632 + const char *license = get_modinfo(info, "license");
81633 int err;
81634
81635 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81636 + if (!license || !license_is_gpl_compatible(license))
81637 + return -ENOEXEC;
81638 +#endif
81639 +
81640 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81641 modmagic = NULL;
81642
81643 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81644 }
81645
81646 /* Set up license info based on the info section */
81647 - set_license(mod, get_modinfo(info, "license"));
81648 + set_license(mod, license);
81649
81650 return 0;
81651 }
81652 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81653 void *ptr;
81654
81655 /* Do the allocs. */
81656 - ptr = module_alloc_update_bounds(mod->core_size);
81657 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81658 /*
81659 * The pointer to this block is stored in the module structure
81660 * which is inside the block. Just mark it as not being a
81661 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81662 if (!ptr)
81663 return -ENOMEM;
81664
81665 - memset(ptr, 0, mod->core_size);
81666 - mod->module_core = ptr;
81667 + memset(ptr, 0, mod->core_size_rw);
81668 + mod->module_core_rw = ptr;
81669
81670 - if (mod->init_size) {
81671 - ptr = module_alloc_update_bounds(mod->init_size);
81672 + if (mod->init_size_rw) {
81673 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81674 /*
81675 * The pointer to this block is stored in the module structure
81676 * which is inside the block. This block doesn't need to be
81677 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81678 */
81679 kmemleak_ignore(ptr);
81680 if (!ptr) {
81681 - module_free(mod, mod->module_core);
81682 + module_free(mod, mod->module_core_rw);
81683 return -ENOMEM;
81684 }
81685 - memset(ptr, 0, mod->init_size);
81686 - mod->module_init = ptr;
81687 + memset(ptr, 0, mod->init_size_rw);
81688 + mod->module_init_rw = ptr;
81689 } else
81690 - mod->module_init = NULL;
81691 + mod->module_init_rw = NULL;
81692 +
81693 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81694 + kmemleak_not_leak(ptr);
81695 + if (!ptr) {
81696 + if (mod->module_init_rw)
81697 + module_free(mod, mod->module_init_rw);
81698 + module_free(mod, mod->module_core_rw);
81699 + return -ENOMEM;
81700 + }
81701 +
81702 + pax_open_kernel();
81703 + memset(ptr, 0, mod->core_size_rx);
81704 + pax_close_kernel();
81705 + mod->module_core_rx = ptr;
81706 +
81707 + if (mod->init_size_rx) {
81708 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81709 + kmemleak_ignore(ptr);
81710 + if (!ptr && mod->init_size_rx) {
81711 + module_free_exec(mod, mod->module_core_rx);
81712 + if (mod->module_init_rw)
81713 + module_free(mod, mod->module_init_rw);
81714 + module_free(mod, mod->module_core_rw);
81715 + return -ENOMEM;
81716 + }
81717 +
81718 + pax_open_kernel();
81719 + memset(ptr, 0, mod->init_size_rx);
81720 + pax_close_kernel();
81721 + mod->module_init_rx = ptr;
81722 + } else
81723 + mod->module_init_rx = NULL;
81724
81725 /* Transfer each section which specifies SHF_ALLOC */
81726 pr_debug("final section addresses:\n");
81727 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81728 if (!(shdr->sh_flags & SHF_ALLOC))
81729 continue;
81730
81731 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81732 - dest = mod->module_init
81733 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81734 - else
81735 - dest = mod->module_core + shdr->sh_entsize;
81736 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81737 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81738 + dest = mod->module_init_rw
81739 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81740 + else
81741 + dest = mod->module_init_rx
81742 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81743 + } else {
81744 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81745 + dest = mod->module_core_rw + shdr->sh_entsize;
81746 + else
81747 + dest = mod->module_core_rx + shdr->sh_entsize;
81748 + }
81749 +
81750 + if (shdr->sh_type != SHT_NOBITS) {
81751 +
81752 +#ifdef CONFIG_PAX_KERNEXEC
81753 +#ifdef CONFIG_X86_64
81754 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81755 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81756 +#endif
81757 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81758 + pax_open_kernel();
81759 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81760 + pax_close_kernel();
81761 + } else
81762 +#endif
81763
81764 - if (shdr->sh_type != SHT_NOBITS)
81765 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81766 + }
81767 /* Update sh_addr to point to copy in image. */
81768 - shdr->sh_addr = (unsigned long)dest;
81769 +
81770 +#ifdef CONFIG_PAX_KERNEXEC
81771 + if (shdr->sh_flags & SHF_EXECINSTR)
81772 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81773 + else
81774 +#endif
81775 +
81776 + shdr->sh_addr = (unsigned long)dest;
81777 pr_debug("\t0x%lx %s\n",
81778 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81779 }
81780 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81781 * Do it before processing of module parameters, so the module
81782 * can provide parameter accessor functions of its own.
81783 */
81784 - if (mod->module_init)
81785 - flush_icache_range((unsigned long)mod->module_init,
81786 - (unsigned long)mod->module_init
81787 - + mod->init_size);
81788 - flush_icache_range((unsigned long)mod->module_core,
81789 - (unsigned long)mod->module_core + mod->core_size);
81790 + if (mod->module_init_rx)
81791 + flush_icache_range((unsigned long)mod->module_init_rx,
81792 + (unsigned long)mod->module_init_rx
81793 + + mod->init_size_rx);
81794 + flush_icache_range((unsigned long)mod->module_core_rx,
81795 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81796
81797 set_fs(old_fs);
81798 }
81799 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81800 static void module_deallocate(struct module *mod, struct load_info *info)
81801 {
81802 percpu_modfree(mod);
81803 - module_free(mod, mod->module_init);
81804 - module_free(mod, mod->module_core);
81805 + module_free_exec(mod, mod->module_init_rx);
81806 + module_free_exec(mod, mod->module_core_rx);
81807 + module_free(mod, mod->module_init_rw);
81808 + module_free(mod, mod->module_core_rw);
81809 }
81810
81811 int __weak module_finalize(const Elf_Ehdr *hdr,
81812 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81813 static int post_relocation(struct module *mod, const struct load_info *info)
81814 {
81815 /* Sort exception table now relocations are done. */
81816 + pax_open_kernel();
81817 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81818 + pax_close_kernel();
81819
81820 /* Copy relocated percpu area over. */
81821 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81822 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81823 MODULE_STATE_COMING, mod);
81824
81825 /* Set RO and NX regions for core */
81826 - set_section_ro_nx(mod->module_core,
81827 - mod->core_text_size,
81828 - mod->core_ro_size,
81829 - mod->core_size);
81830 + set_section_ro_nx(mod->module_core_rx,
81831 + mod->core_size_rx,
81832 + mod->core_size_rx,
81833 + mod->core_size_rx);
81834
81835 /* Set RO and NX regions for init */
81836 - set_section_ro_nx(mod->module_init,
81837 - mod->init_text_size,
81838 - mod->init_ro_size,
81839 - mod->init_size);
81840 + set_section_ro_nx(mod->module_init_rx,
81841 + mod->init_size_rx,
81842 + mod->init_size_rx,
81843 + mod->init_size_rx);
81844
81845 do_mod_ctors(mod);
81846 /* Start the module */
81847 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81848 mod->strtab = mod->core_strtab;
81849 #endif
81850 unset_module_init_ro_nx(mod);
81851 - module_free(mod, mod->module_init);
81852 - mod->module_init = NULL;
81853 - mod->init_size = 0;
81854 - mod->init_ro_size = 0;
81855 - mod->init_text_size = 0;
81856 + module_free(mod, mod->module_init_rw);
81857 + module_free_exec(mod, mod->module_init_rx);
81858 + mod->module_init_rw = NULL;
81859 + mod->module_init_rx = NULL;
81860 + mod->init_size_rw = 0;
81861 + mod->init_size_rx = 0;
81862 mutex_unlock(&module_mutex);
81863 wake_up_all(&module_wq);
81864
81865 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81866 if (err)
81867 goto free_unload;
81868
81869 + /* Now copy in args */
81870 + mod->args = strndup_user(uargs, ~0UL >> 1);
81871 + if (IS_ERR(mod->args)) {
81872 + err = PTR_ERR(mod->args);
81873 + goto free_unload;
81874 + }
81875 +
81876 /* Set up MODINFO_ATTR fields */
81877 setup_modinfo(mod, info);
81878
81879 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81880 + {
81881 + char *p, *p2;
81882 +
81883 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81884 + 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);
81885 + err = -EPERM;
81886 + goto free_modinfo;
81887 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81888 + p += sizeof("grsec_modharden_normal") - 1;
81889 + p2 = strstr(p, "_");
81890 + if (p2) {
81891 + *p2 = '\0';
81892 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81893 + *p2 = '_';
81894 + }
81895 + err = -EPERM;
81896 + goto free_modinfo;
81897 + }
81898 + }
81899 +#endif
81900 +
81901 /* Fix up syms, so that st_value is a pointer to location. */
81902 err = simplify_symbols(mod, info);
81903 if (err < 0)
81904 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
81905
81906 flush_module_icache(mod);
81907
81908 - /* Now copy in args */
81909 - mod->args = strndup_user(uargs, ~0UL >> 1);
81910 - if (IS_ERR(mod->args)) {
81911 - err = PTR_ERR(mod->args);
81912 - goto free_arch_cleanup;
81913 - }
81914 -
81915 dynamic_debug_setup(info->debug, info->num_debug);
81916
81917 /* Finally it's fully formed, ready to start executing. */
81918 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
81919 ddebug_cleanup:
81920 dynamic_debug_remove(info->debug);
81921 synchronize_sched();
81922 - kfree(mod->args);
81923 - free_arch_cleanup:
81924 module_arch_cleanup(mod);
81925 free_modinfo:
81926 free_modinfo(mod);
81927 + kfree(mod->args);
81928 free_unload:
81929 module_unload_free(mod);
81930 unlink_mod:
81931 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
81932 unsigned long nextval;
81933
81934 /* At worse, next value is at end of module */
81935 - if (within_module_init(addr, mod))
81936 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
81937 + if (within_module_init_rx(addr, mod))
81938 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
81939 + else if (within_module_init_rw(addr, mod))
81940 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
81941 + else if (within_module_core_rx(addr, mod))
81942 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
81943 + else if (within_module_core_rw(addr, mod))
81944 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
81945 else
81946 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
81947 + return NULL;
81948
81949 /* Scan for closest preceding symbol, and next symbol. (ELF
81950 starts real symbols at 1). */
81951 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
81952 return 0;
81953
81954 seq_printf(m, "%s %u",
81955 - mod->name, mod->init_size + mod->core_size);
81956 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
81957 print_unload_info(m, mod);
81958
81959 /* Informative for users. */
81960 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
81961 mod->state == MODULE_STATE_COMING ? "Loading":
81962 "Live");
81963 /* Used by oprofile and other similar tools. */
81964 - seq_printf(m, " 0x%pK", mod->module_core);
81965 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
81966
81967 /* Taints info */
81968 if (mod->taints)
81969 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
81970
81971 static int __init proc_modules_init(void)
81972 {
81973 +#ifndef CONFIG_GRKERNSEC_HIDESYM
81974 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81975 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81976 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81977 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
81978 +#else
81979 proc_create("modules", 0, NULL, &proc_modules_operations);
81980 +#endif
81981 +#else
81982 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81983 +#endif
81984 return 0;
81985 }
81986 module_init(proc_modules_init);
81987 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
81988 {
81989 struct module *mod;
81990
81991 - if (addr < module_addr_min || addr > module_addr_max)
81992 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
81993 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
81994 return NULL;
81995
81996 list_for_each_entry_rcu(mod, &modules, list) {
81997 if (mod->state == MODULE_STATE_UNFORMED)
81998 continue;
81999 - if (within_module_core(addr, mod)
82000 - || within_module_init(addr, mod))
82001 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82002 return mod;
82003 }
82004 return NULL;
82005 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82006 */
82007 struct module *__module_text_address(unsigned long addr)
82008 {
82009 - struct module *mod = __module_address(addr);
82010 + struct module *mod;
82011 +
82012 +#ifdef CONFIG_X86_32
82013 + addr = ktla_ktva(addr);
82014 +#endif
82015 +
82016 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82017 + return NULL;
82018 +
82019 + mod = __module_address(addr);
82020 +
82021 if (mod) {
82022 /* Make sure it's within the text section. */
82023 - if (!within(addr, mod->module_init, mod->init_text_size)
82024 - && !within(addr, mod->module_core, mod->core_text_size))
82025 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82026 mod = NULL;
82027 }
82028 return mod;
82029 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82030 index 7e3443f..b2a1e6b 100644
82031 --- a/kernel/mutex-debug.c
82032 +++ b/kernel/mutex-debug.c
82033 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82034 }
82035
82036 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82037 - struct thread_info *ti)
82038 + struct task_struct *task)
82039 {
82040 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82041
82042 /* Mark the current thread as blocked on the lock: */
82043 - ti->task->blocked_on = waiter;
82044 + task->blocked_on = waiter;
82045 }
82046
82047 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82048 - struct thread_info *ti)
82049 + struct task_struct *task)
82050 {
82051 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82052 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82053 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82054 - ti->task->blocked_on = NULL;
82055 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82056 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82057 + task->blocked_on = NULL;
82058
82059 list_del_init(&waiter->list);
82060 waiter->task = NULL;
82061 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82062 index 0799fd3..d06ae3b 100644
82063 --- a/kernel/mutex-debug.h
82064 +++ b/kernel/mutex-debug.h
82065 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82066 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82067 extern void debug_mutex_add_waiter(struct mutex *lock,
82068 struct mutex_waiter *waiter,
82069 - struct thread_info *ti);
82070 + struct task_struct *task);
82071 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82072 - struct thread_info *ti);
82073 + struct task_struct *task);
82074 extern void debug_mutex_unlock(struct mutex *lock);
82075 extern void debug_mutex_init(struct mutex *lock, const char *name,
82076 struct lock_class_key *key);
82077 diff --git a/kernel/mutex.c b/kernel/mutex.c
82078 index a52ee7bb..f361f16 100644
82079 --- a/kernel/mutex.c
82080 +++ b/kernel/mutex.c
82081 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82082 node->locked = 1;
82083 return;
82084 }
82085 - ACCESS_ONCE(prev->next) = node;
82086 + ACCESS_ONCE_RW(prev->next) = node;
82087 smp_wmb();
82088 /* Wait until the lock holder passes the lock down */
82089 while (!ACCESS_ONCE(node->locked))
82090 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82091 while (!(next = ACCESS_ONCE(node->next)))
82092 arch_mutex_cpu_relax();
82093 }
82094 - ACCESS_ONCE(next->locked) = 1;
82095 + ACCESS_ONCE_RW(next->locked) = 1;
82096 smp_wmb();
82097 }
82098
82099 @@ -514,7 +514,7 @@ slowpath:
82100 spin_lock_mutex(&lock->wait_lock, flags);
82101
82102 debug_mutex_lock_common(lock, &waiter);
82103 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82104 + debug_mutex_add_waiter(lock, &waiter, task);
82105
82106 /* add waiting tasks to the end of the waitqueue (FIFO): */
82107 list_add_tail(&waiter.list, &lock->wait_list);
82108 @@ -565,7 +565,7 @@ slowpath:
82109 done:
82110 lock_acquired(&lock->dep_map, ip);
82111 /* got the lock - rejoice! */
82112 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82113 + mutex_remove_waiter(lock, &waiter, task);
82114 mutex_set_owner(lock);
82115
82116 if (!__builtin_constant_p(ww_ctx == NULL)) {
82117 @@ -604,7 +604,7 @@ done:
82118 return 0;
82119
82120 err:
82121 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82122 + mutex_remove_waiter(lock, &waiter, task);
82123 spin_unlock_mutex(&lock->wait_lock, flags);
82124 debug_mutex_free_waiter(&waiter);
82125 mutex_release(&lock->dep_map, 1, ip);
82126 diff --git a/kernel/notifier.c b/kernel/notifier.c
82127 index 2d5cc4c..d9ea600 100644
82128 --- a/kernel/notifier.c
82129 +++ b/kernel/notifier.c
82130 @@ -5,6 +5,7 @@
82131 #include <linux/rcupdate.h>
82132 #include <linux/vmalloc.h>
82133 #include <linux/reboot.h>
82134 +#include <linux/mm.h>
82135
82136 /*
82137 * Notifier list for kernel code which wants to be called
82138 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82139 while ((*nl) != NULL) {
82140 if (n->priority > (*nl)->priority)
82141 break;
82142 - nl = &((*nl)->next);
82143 + nl = (struct notifier_block **)&((*nl)->next);
82144 }
82145 - n->next = *nl;
82146 + pax_open_kernel();
82147 + *(const void **)&n->next = *nl;
82148 rcu_assign_pointer(*nl, n);
82149 + pax_close_kernel();
82150 return 0;
82151 }
82152
82153 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82154 return 0;
82155 if (n->priority > (*nl)->priority)
82156 break;
82157 - nl = &((*nl)->next);
82158 + nl = (struct notifier_block **)&((*nl)->next);
82159 }
82160 - n->next = *nl;
82161 + pax_open_kernel();
82162 + *(const void **)&n->next = *nl;
82163 rcu_assign_pointer(*nl, n);
82164 + pax_close_kernel();
82165 return 0;
82166 }
82167
82168 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82169 {
82170 while ((*nl) != NULL) {
82171 if ((*nl) == n) {
82172 + pax_open_kernel();
82173 rcu_assign_pointer(*nl, n->next);
82174 + pax_close_kernel();
82175 return 0;
82176 }
82177 - nl = &((*nl)->next);
82178 + nl = (struct notifier_block **)&((*nl)->next);
82179 }
82180 return -ENOENT;
82181 }
82182 diff --git a/kernel/panic.c b/kernel/panic.c
82183 index 8018646..b6a5b4f 100644
82184 --- a/kernel/panic.c
82185 +++ b/kernel/panic.c
82186 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82187 disable_trace_on_warning();
82188
82189 pr_warn("------------[ cut here ]------------\n");
82190 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82191 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82192 raw_smp_processor_id(), current->pid, file, line, caller);
82193
82194 if (args)
82195 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82196 */
82197 void __stack_chk_fail(void)
82198 {
82199 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82200 + dump_stack();
82201 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82202 __builtin_return_address(0));
82203 }
82204 EXPORT_SYMBOL(__stack_chk_fail);
82205 diff --git a/kernel/pid.c b/kernel/pid.c
82206 index ebe5e80..5d6d634 100644
82207 --- a/kernel/pid.c
82208 +++ b/kernel/pid.c
82209 @@ -33,6 +33,7 @@
82210 #include <linux/rculist.h>
82211 #include <linux/bootmem.h>
82212 #include <linux/hash.h>
82213 +#include <linux/security.h>
82214 #include <linux/pid_namespace.h>
82215 #include <linux/init_task.h>
82216 #include <linux/syscalls.h>
82217 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82218
82219 int pid_max = PID_MAX_DEFAULT;
82220
82221 -#define RESERVED_PIDS 300
82222 +#define RESERVED_PIDS 500
82223
82224 int pid_max_min = RESERVED_PIDS + 1;
82225 int pid_max_max = PID_MAX_LIMIT;
82226 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82227 */
82228 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82229 {
82230 + struct task_struct *task;
82231 +
82232 rcu_lockdep_assert(rcu_read_lock_held(),
82233 "find_task_by_pid_ns() needs rcu_read_lock()"
82234 " protection");
82235 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82236 +
82237 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82238 +
82239 + if (gr_pid_is_chrooted(task))
82240 + return NULL;
82241 +
82242 + return task;
82243 }
82244
82245 struct task_struct *find_task_by_vpid(pid_t vnr)
82246 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82247 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82248 }
82249
82250 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82251 +{
82252 + rcu_lockdep_assert(rcu_read_lock_held(),
82253 + "find_task_by_pid_ns() needs rcu_read_lock()"
82254 + " protection");
82255 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82256 +}
82257 +
82258 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82259 {
82260 struct pid *pid;
82261 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82262 index 601bb36..f7e6f34 100644
82263 --- a/kernel/pid_namespace.c
82264 +++ b/kernel/pid_namespace.c
82265 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82266 void __user *buffer, size_t *lenp, loff_t *ppos)
82267 {
82268 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82269 - struct ctl_table tmp = *table;
82270 + ctl_table_no_const tmp = *table;
82271
82272 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82273 return -EPERM;
82274 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82275 index c7f31aa..2b44977 100644
82276 --- a/kernel/posix-cpu-timers.c
82277 +++ b/kernel/posix-cpu-timers.c
82278 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82279
82280 static __init int init_posix_cpu_timers(void)
82281 {
82282 - struct k_clock process = {
82283 + static struct k_clock process = {
82284 .clock_getres = process_cpu_clock_getres,
82285 .clock_get = process_cpu_clock_get,
82286 .timer_create = process_cpu_timer_create,
82287 .nsleep = process_cpu_nsleep,
82288 .nsleep_restart = process_cpu_nsleep_restart,
82289 };
82290 - struct k_clock thread = {
82291 + static struct k_clock thread = {
82292 .clock_getres = thread_cpu_clock_getres,
82293 .clock_get = thread_cpu_clock_get,
82294 .timer_create = thread_cpu_timer_create,
82295 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82296 index 424c2d4..679242f 100644
82297 --- a/kernel/posix-timers.c
82298 +++ b/kernel/posix-timers.c
82299 @@ -43,6 +43,7 @@
82300 #include <linux/hash.h>
82301 #include <linux/posix-clock.h>
82302 #include <linux/posix-timers.h>
82303 +#include <linux/grsecurity.h>
82304 #include <linux/syscalls.h>
82305 #include <linux/wait.h>
82306 #include <linux/workqueue.h>
82307 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82308 * which we beg off on and pass to do_sys_settimeofday().
82309 */
82310
82311 -static struct k_clock posix_clocks[MAX_CLOCKS];
82312 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82313
82314 /*
82315 * These ones are defined below.
82316 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82317 */
82318 static __init int init_posix_timers(void)
82319 {
82320 - struct k_clock clock_realtime = {
82321 + static struct k_clock clock_realtime = {
82322 .clock_getres = hrtimer_get_res,
82323 .clock_get = posix_clock_realtime_get,
82324 .clock_set = posix_clock_realtime_set,
82325 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82326 .timer_get = common_timer_get,
82327 .timer_del = common_timer_del,
82328 };
82329 - struct k_clock clock_monotonic = {
82330 + static struct k_clock clock_monotonic = {
82331 .clock_getres = hrtimer_get_res,
82332 .clock_get = posix_ktime_get_ts,
82333 .nsleep = common_nsleep,
82334 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82335 .timer_get = common_timer_get,
82336 .timer_del = common_timer_del,
82337 };
82338 - struct k_clock clock_monotonic_raw = {
82339 + static struct k_clock clock_monotonic_raw = {
82340 .clock_getres = hrtimer_get_res,
82341 .clock_get = posix_get_monotonic_raw,
82342 };
82343 - struct k_clock clock_realtime_coarse = {
82344 + static struct k_clock clock_realtime_coarse = {
82345 .clock_getres = posix_get_coarse_res,
82346 .clock_get = posix_get_realtime_coarse,
82347 };
82348 - struct k_clock clock_monotonic_coarse = {
82349 + static struct k_clock clock_monotonic_coarse = {
82350 .clock_getres = posix_get_coarse_res,
82351 .clock_get = posix_get_monotonic_coarse,
82352 };
82353 - struct k_clock clock_tai = {
82354 + static struct k_clock clock_tai = {
82355 .clock_getres = hrtimer_get_res,
82356 .clock_get = posix_get_tai,
82357 .nsleep = common_nsleep,
82358 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82359 .timer_get = common_timer_get,
82360 .timer_del = common_timer_del,
82361 };
82362 - struct k_clock clock_boottime = {
82363 + static struct k_clock clock_boottime = {
82364 .clock_getres = hrtimer_get_res,
82365 .clock_get = posix_get_boottime,
82366 .nsleep = common_nsleep,
82367 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82368 return;
82369 }
82370
82371 - posix_clocks[clock_id] = *new_clock;
82372 + posix_clocks[clock_id] = new_clock;
82373 }
82374 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82375
82376 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82377 return (id & CLOCKFD_MASK) == CLOCKFD ?
82378 &clock_posix_dynamic : &clock_posix_cpu;
82379
82380 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82381 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82382 return NULL;
82383 - return &posix_clocks[id];
82384 + return posix_clocks[id];
82385 }
82386
82387 static int common_timer_create(struct k_itimer *new_timer)
82388 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82389 struct k_clock *kc = clockid_to_kclock(which_clock);
82390 struct k_itimer *new_timer;
82391 int error, new_timer_id;
82392 - sigevent_t event;
82393 + sigevent_t event = { };
82394 int it_id_set = IT_ID_NOT_SET;
82395
82396 if (!kc)
82397 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82398 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82399 return -EFAULT;
82400
82401 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82402 + have their clock_set fptr set to a nosettime dummy function
82403 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82404 + call common_clock_set, which calls do_sys_settimeofday, which
82405 + we hook
82406 + */
82407 +
82408 return kc->clock_set(which_clock, &new_tp);
82409 }
82410
82411 diff --git a/kernel/power/process.c b/kernel/power/process.c
82412 index 06ec886..9dba35e 100644
82413 --- a/kernel/power/process.c
82414 +++ b/kernel/power/process.c
82415 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82416 unsigned int elapsed_msecs;
82417 bool wakeup = false;
82418 int sleep_usecs = USEC_PER_MSEC;
82419 + bool timedout = false;
82420
82421 do_gettimeofday(&start);
82422
82423 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82424
82425 while (true) {
82426 todo = 0;
82427 + if (time_after(jiffies, end_time))
82428 + timedout = true;
82429 read_lock(&tasklist_lock);
82430 do_each_thread(g, p) {
82431 if (p == current || !freeze_task(p))
82432 continue;
82433
82434 - if (!freezer_should_skip(p))
82435 + if (!freezer_should_skip(p)) {
82436 todo++;
82437 + if (timedout) {
82438 + printk(KERN_ERR "Task refusing to freeze:\n");
82439 + sched_show_task(p);
82440 + }
82441 + }
82442 } while_each_thread(g, p);
82443 read_unlock(&tasklist_lock);
82444
82445 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82446 todo += wq_busy;
82447 }
82448
82449 - if (!todo || time_after(jiffies, end_time))
82450 + if (!todo || timedout)
82451 break;
82452
82453 if (pm_wakeup_pending()) {
82454 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82455 index 5b5a708..ec7637e 100644
82456 --- a/kernel/printk/printk.c
82457 +++ b/kernel/printk/printk.c
82458 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82459 if (from_file && type != SYSLOG_ACTION_OPEN)
82460 return 0;
82461
82462 +#ifdef CONFIG_GRKERNSEC_DMESG
82463 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82464 + return -EPERM;
82465 +#endif
82466 +
82467 if (syslog_action_restricted(type)) {
82468 if (capable(CAP_SYSLOG))
82469 return 0;
82470 diff --git a/kernel/profile.c b/kernel/profile.c
82471 index 6631e1e..310c266 100644
82472 --- a/kernel/profile.c
82473 +++ b/kernel/profile.c
82474 @@ -37,7 +37,7 @@ struct profile_hit {
82475 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82476 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82477
82478 -static atomic_t *prof_buffer;
82479 +static atomic_unchecked_t *prof_buffer;
82480 static unsigned long prof_len, prof_shift;
82481
82482 int prof_on __read_mostly;
82483 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82484 hits[i].pc = 0;
82485 continue;
82486 }
82487 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82488 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82489 hits[i].hits = hits[i].pc = 0;
82490 }
82491 }
82492 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82493 * Add the current hit(s) and flush the write-queue out
82494 * to the global buffer:
82495 */
82496 - atomic_add(nr_hits, &prof_buffer[pc]);
82497 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82498 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82499 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82500 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82501 hits[i].pc = hits[i].hits = 0;
82502 }
82503 out:
82504 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82505 {
82506 unsigned long pc;
82507 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82508 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82509 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82510 }
82511 #endif /* !CONFIG_SMP */
82512
82513 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82514 return -EFAULT;
82515 buf++; p++; count--; read++;
82516 }
82517 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82518 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82519 if (copy_to_user(buf, (void *)pnt, count))
82520 return -EFAULT;
82521 read += count;
82522 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82523 }
82524 #endif
82525 profile_discard_flip_buffers();
82526 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82527 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82528 return count;
82529 }
82530
82531 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82532 index a146ee3..ffed4c3 100644
82533 --- a/kernel/ptrace.c
82534 +++ b/kernel/ptrace.c
82535 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82536 if (seize)
82537 flags |= PT_SEIZED;
82538 rcu_read_lock();
82539 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82540 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82541 flags |= PT_PTRACE_CAP;
82542 rcu_read_unlock();
82543 task->ptrace = flags;
82544 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82545 break;
82546 return -EIO;
82547 }
82548 - if (copy_to_user(dst, buf, retval))
82549 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82550 return -EFAULT;
82551 copied += retval;
82552 src += retval;
82553 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82554 bool seized = child->ptrace & PT_SEIZED;
82555 int ret = -EIO;
82556 siginfo_t siginfo, *si;
82557 - void __user *datavp = (void __user *) data;
82558 + void __user *datavp = (__force void __user *) data;
82559 unsigned long __user *datalp = datavp;
82560 unsigned long flags;
82561
82562 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82563 goto out;
82564 }
82565
82566 + if (gr_handle_ptrace(child, request)) {
82567 + ret = -EPERM;
82568 + goto out_put_task_struct;
82569 + }
82570 +
82571 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82572 ret = ptrace_attach(child, request, addr, data);
82573 /*
82574 * Some architectures need to do book-keeping after
82575 * a ptrace attach.
82576 */
82577 - if (!ret)
82578 + if (!ret) {
82579 arch_ptrace_attach(child);
82580 + gr_audit_ptrace(child);
82581 + }
82582 goto out_put_task_struct;
82583 }
82584
82585 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82586 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82587 if (copied != sizeof(tmp))
82588 return -EIO;
82589 - return put_user(tmp, (unsigned long __user *)data);
82590 + return put_user(tmp, (__force unsigned long __user *)data);
82591 }
82592
82593 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82594 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82595 }
82596
82597 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82598 - compat_long_t addr, compat_long_t data)
82599 + compat_ulong_t addr, compat_ulong_t data)
82600 {
82601 struct task_struct *child;
82602 long ret;
82603 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82604 goto out;
82605 }
82606
82607 + if (gr_handle_ptrace(child, request)) {
82608 + ret = -EPERM;
82609 + goto out_put_task_struct;
82610 + }
82611 +
82612 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82613 ret = ptrace_attach(child, request, addr, data);
82614 /*
82615 * Some architectures need to do book-keeping after
82616 * a ptrace attach.
82617 */
82618 - if (!ret)
82619 + if (!ret) {
82620 arch_ptrace_attach(child);
82621 + gr_audit_ptrace(child);
82622 + }
82623 goto out_put_task_struct;
82624 }
82625
82626 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82627 index cce6ba8..7c758b1f 100644
82628 --- a/kernel/rcupdate.c
82629 +++ b/kernel/rcupdate.c
82630 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82631 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82632 */
82633 if (till_stall_check < 3) {
82634 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82635 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82636 till_stall_check = 3;
82637 } else if (till_stall_check > 300) {
82638 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82639 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82640 till_stall_check = 300;
82641 }
82642 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82643 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82644 index aa34411..4832cd4 100644
82645 --- a/kernel/rcutiny.c
82646 +++ b/kernel/rcutiny.c
82647 @@ -45,7 +45,7 @@
82648 /* Forward declarations for rcutiny_plugin.h. */
82649 struct rcu_ctrlblk;
82650 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82651 -static void rcu_process_callbacks(struct softirq_action *unused);
82652 +static void rcu_process_callbacks(void);
82653 static void __call_rcu(struct rcu_head *head,
82654 void (*func)(struct rcu_head *rcu),
82655 struct rcu_ctrlblk *rcp);
82656 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82657 false));
82658 }
82659
82660 -static void rcu_process_callbacks(struct softirq_action *unused)
82661 +static __latent_entropy void rcu_process_callbacks(void)
82662 {
82663 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82664 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82665 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82666 index f4871e5..8ef5741 100644
82667 --- a/kernel/rcutorture.c
82668 +++ b/kernel/rcutorture.c
82669 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82670 { 0 };
82671 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82672 { 0 };
82673 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82674 -static atomic_t n_rcu_torture_alloc;
82675 -static atomic_t n_rcu_torture_alloc_fail;
82676 -static atomic_t n_rcu_torture_free;
82677 -static atomic_t n_rcu_torture_mberror;
82678 -static atomic_t n_rcu_torture_error;
82679 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82680 +static atomic_unchecked_t n_rcu_torture_alloc;
82681 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82682 +static atomic_unchecked_t n_rcu_torture_free;
82683 +static atomic_unchecked_t n_rcu_torture_mberror;
82684 +static atomic_unchecked_t n_rcu_torture_error;
82685 static long n_rcu_torture_barrier_error;
82686 static long n_rcu_torture_boost_ktrerror;
82687 static long n_rcu_torture_boost_rterror;
82688 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82689
82690 spin_lock_bh(&rcu_torture_lock);
82691 if (list_empty(&rcu_torture_freelist)) {
82692 - atomic_inc(&n_rcu_torture_alloc_fail);
82693 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82694 spin_unlock_bh(&rcu_torture_lock);
82695 return NULL;
82696 }
82697 - atomic_inc(&n_rcu_torture_alloc);
82698 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82699 p = rcu_torture_freelist.next;
82700 list_del_init(p);
82701 spin_unlock_bh(&rcu_torture_lock);
82702 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82703 static void
82704 rcu_torture_free(struct rcu_torture *p)
82705 {
82706 - atomic_inc(&n_rcu_torture_free);
82707 + atomic_inc_unchecked(&n_rcu_torture_free);
82708 spin_lock_bh(&rcu_torture_lock);
82709 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82710 spin_unlock_bh(&rcu_torture_lock);
82711 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82712 i = rp->rtort_pipe_count;
82713 if (i > RCU_TORTURE_PIPE_LEN)
82714 i = RCU_TORTURE_PIPE_LEN;
82715 - atomic_inc(&rcu_torture_wcount[i]);
82716 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82717 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82718 rp->rtort_mbtest = 0;
82719 rcu_torture_free(rp);
82720 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82721 i = rp->rtort_pipe_count;
82722 if (i > RCU_TORTURE_PIPE_LEN)
82723 i = RCU_TORTURE_PIPE_LEN;
82724 - atomic_inc(&rcu_torture_wcount[i]);
82725 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82726 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82727 rp->rtort_mbtest = 0;
82728 list_del(&rp->rtort_free);
82729 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82730 i = old_rp->rtort_pipe_count;
82731 if (i > RCU_TORTURE_PIPE_LEN)
82732 i = RCU_TORTURE_PIPE_LEN;
82733 - atomic_inc(&rcu_torture_wcount[i]);
82734 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82735 old_rp->rtort_pipe_count++;
82736 cur_ops->deferred_free(old_rp);
82737 }
82738 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82739 return;
82740 }
82741 if (p->rtort_mbtest == 0)
82742 - atomic_inc(&n_rcu_torture_mberror);
82743 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82744 spin_lock(&rand_lock);
82745 cur_ops->read_delay(&rand);
82746 n_rcu_torture_timers++;
82747 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82748 continue;
82749 }
82750 if (p->rtort_mbtest == 0)
82751 - atomic_inc(&n_rcu_torture_mberror);
82752 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82753 cur_ops->read_delay(&rand);
82754 preempt_disable();
82755 pipe_count = p->rtort_pipe_count;
82756 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82757 rcu_torture_current,
82758 rcu_torture_current_version,
82759 list_empty(&rcu_torture_freelist),
82760 - atomic_read(&n_rcu_torture_alloc),
82761 - atomic_read(&n_rcu_torture_alloc_fail),
82762 - atomic_read(&n_rcu_torture_free));
82763 + atomic_read_unchecked(&n_rcu_torture_alloc),
82764 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82765 + atomic_read_unchecked(&n_rcu_torture_free));
82766 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82767 - atomic_read(&n_rcu_torture_mberror),
82768 + atomic_read_unchecked(&n_rcu_torture_mberror),
82769 n_rcu_torture_boost_ktrerror,
82770 n_rcu_torture_boost_rterror);
82771 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82772 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82773 n_barrier_attempts,
82774 n_rcu_torture_barrier_error);
82775 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82776 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82777 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82778 n_rcu_torture_barrier_error != 0 ||
82779 n_rcu_torture_boost_ktrerror != 0 ||
82780 n_rcu_torture_boost_rterror != 0 ||
82781 n_rcu_torture_boost_failure != 0 ||
82782 i > 1) {
82783 cnt += sprintf(&page[cnt], "!!! ");
82784 - atomic_inc(&n_rcu_torture_error);
82785 + atomic_inc_unchecked(&n_rcu_torture_error);
82786 WARN_ON_ONCE(1);
82787 }
82788 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82789 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82790 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82791 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82792 cnt += sprintf(&page[cnt], " %d",
82793 - atomic_read(&rcu_torture_wcount[i]));
82794 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82795 }
82796 cnt += sprintf(&page[cnt], "\n");
82797 if (cur_ops->stats)
82798 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82799
82800 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82801
82802 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82803 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82804 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82805 else if (n_online_successes != n_online_attempts ||
82806 n_offline_successes != n_offline_attempts)
82807 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82808
82809 rcu_torture_current = NULL;
82810 rcu_torture_current_version = 0;
82811 - atomic_set(&n_rcu_torture_alloc, 0);
82812 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82813 - atomic_set(&n_rcu_torture_free, 0);
82814 - atomic_set(&n_rcu_torture_mberror, 0);
82815 - atomic_set(&n_rcu_torture_error, 0);
82816 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82817 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82818 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82819 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82820 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82821 n_rcu_torture_barrier_error = 0;
82822 n_rcu_torture_boost_ktrerror = 0;
82823 n_rcu_torture_boost_rterror = 0;
82824 n_rcu_torture_boost_failure = 0;
82825 n_rcu_torture_boosts = 0;
82826 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82827 - atomic_set(&rcu_torture_wcount[i], 0);
82828 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82829 for_each_possible_cpu(cpu) {
82830 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82831 per_cpu(rcu_torture_count, cpu)[i] = 0;
82832 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82833 index 068de3a..5e7db2f 100644
82834 --- a/kernel/rcutree.c
82835 +++ b/kernel/rcutree.c
82836 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82837 rcu_prepare_for_idle(smp_processor_id());
82838 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82839 smp_mb__before_atomic_inc(); /* See above. */
82840 - atomic_inc(&rdtp->dynticks);
82841 + atomic_inc_unchecked(&rdtp->dynticks);
82842 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82843 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82844 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82845
82846 /*
82847 * It is illegal to enter an extended quiescent state while
82848 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82849 int user)
82850 {
82851 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82852 - atomic_inc(&rdtp->dynticks);
82853 + atomic_inc_unchecked(&rdtp->dynticks);
82854 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82855 smp_mb__after_atomic_inc(); /* See above. */
82856 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82857 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82858 rcu_cleanup_after_idle(smp_processor_id());
82859 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82860 if (!user && !is_idle_task(current)) {
82861 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82862 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82863
82864 if (rdtp->dynticks_nmi_nesting == 0 &&
82865 - (atomic_read(&rdtp->dynticks) & 0x1))
82866 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82867 return;
82868 rdtp->dynticks_nmi_nesting++;
82869 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82870 - atomic_inc(&rdtp->dynticks);
82871 + atomic_inc_unchecked(&rdtp->dynticks);
82872 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82873 smp_mb__after_atomic_inc(); /* See above. */
82874 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82875 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82876 }
82877
82878 /**
82879 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82880 return;
82881 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82882 smp_mb__before_atomic_inc(); /* See above. */
82883 - atomic_inc(&rdtp->dynticks);
82884 + atomic_inc_unchecked(&rdtp->dynticks);
82885 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82886 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82887 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82888 }
82889
82890 /**
82891 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82892 int ret;
82893
82894 preempt_disable();
82895 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82896 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82897 preempt_enable();
82898 return ret;
82899 }
82900 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
82901 */
82902 static int dyntick_save_progress_counter(struct rcu_data *rdp)
82903 {
82904 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
82905 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82906 return (rdp->dynticks_snap & 0x1) == 0;
82907 }
82908
82909 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
82910 unsigned int curr;
82911 unsigned int snap;
82912
82913 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
82914 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82915 snap = (unsigned int)rdp->dynticks_snap;
82916
82917 /*
82918 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
82919 rdp = this_cpu_ptr(rsp->rda);
82920 rcu_preempt_check_blocked_tasks(rnp);
82921 rnp->qsmask = rnp->qsmaskinit;
82922 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
82923 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
82924 WARN_ON_ONCE(rnp->completed != rsp->completed);
82925 - ACCESS_ONCE(rnp->completed) = rsp->completed;
82926 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
82927 if (rnp == rdp->mynode)
82928 __note_gp_changes(rsp, rnp, rdp);
82929 rcu_preempt_boost_start_gp(rnp);
82930 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
82931 */
82932 rcu_for_each_node_breadth_first(rsp, rnp) {
82933 raw_spin_lock_irq(&rnp->lock);
82934 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
82935 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
82936 rdp = this_cpu_ptr(rsp->rda);
82937 if (rnp == rdp->mynode)
82938 __note_gp_changes(rsp, rnp, rdp);
82939 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
82940 rsp->qlen += rdp->qlen;
82941 rdp->n_cbs_orphaned += rdp->qlen;
82942 rdp->qlen_lazy = 0;
82943 - ACCESS_ONCE(rdp->qlen) = 0;
82944 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82945 }
82946
82947 /*
82948 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
82949 }
82950 smp_mb(); /* List handling before counting for rcu_barrier(). */
82951 rdp->qlen_lazy -= count_lazy;
82952 - ACCESS_ONCE(rdp->qlen) -= count;
82953 + ACCESS_ONCE_RW(rdp->qlen) -= count;
82954 rdp->n_cbs_invoked += count;
82955
82956 /* Reinstate batch limit if we have worked down the excess. */
82957 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
82958 /*
82959 * Do RCU core processing for the current CPU.
82960 */
82961 -static void rcu_process_callbacks(struct softirq_action *unused)
82962 +static __latent_entropy void rcu_process_callbacks(void)
82963 {
82964 struct rcu_state *rsp;
82965
82966 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
82967 local_irq_restore(flags);
82968 return;
82969 }
82970 - ACCESS_ONCE(rdp->qlen)++;
82971 + ACCESS_ONCE_RW(rdp->qlen)++;
82972 if (lazy)
82973 rdp->qlen_lazy++;
82974 else
82975 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
82976 * counter wrap on a 32-bit system. Quite a few more CPUs would of
82977 * course be required on a 64-bit system.
82978 */
82979 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
82980 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
82981 (ulong)atomic_long_read(&rsp->expedited_done) +
82982 ULONG_MAX / 8)) {
82983 synchronize_sched();
82984 - atomic_long_inc(&rsp->expedited_wrap);
82985 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
82986 return;
82987 }
82988
82989 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
82990 * Take a ticket. Note that atomic_inc_return() implies a
82991 * full memory barrier.
82992 */
82993 - snap = atomic_long_inc_return(&rsp->expedited_start);
82994 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
82995 firstsnap = snap;
82996 get_online_cpus();
82997 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
82998 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
82999 synchronize_sched_expedited_cpu_stop,
83000 NULL) == -EAGAIN) {
83001 put_online_cpus();
83002 - atomic_long_inc(&rsp->expedited_tryfail);
83003 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83004
83005 /* Check to see if someone else did our work for us. */
83006 s = atomic_long_read(&rsp->expedited_done);
83007 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83008 /* ensure test happens before caller kfree */
83009 smp_mb__before_atomic_inc(); /* ^^^ */
83010 - atomic_long_inc(&rsp->expedited_workdone1);
83011 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83012 return;
83013 }
83014
83015 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83016 udelay(trycount * num_online_cpus());
83017 } else {
83018 wait_rcu_gp(call_rcu_sched);
83019 - atomic_long_inc(&rsp->expedited_normal);
83020 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83021 return;
83022 }
83023
83024 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83025 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83026 /* ensure test happens before caller kfree */
83027 smp_mb__before_atomic_inc(); /* ^^^ */
83028 - atomic_long_inc(&rsp->expedited_workdone2);
83029 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83030 return;
83031 }
83032
83033 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83034 * period works for us.
83035 */
83036 get_online_cpus();
83037 - snap = atomic_long_read(&rsp->expedited_start);
83038 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83039 smp_mb(); /* ensure read is before try_stop_cpus(). */
83040 }
83041 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83042 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83043
83044 /*
83045 * Everyone up to our most recent fetch is covered by our grace
83046 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83047 * than we did already did their update.
83048 */
83049 do {
83050 - atomic_long_inc(&rsp->expedited_done_tries);
83051 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83052 s = atomic_long_read(&rsp->expedited_done);
83053 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83054 /* ensure test happens before caller kfree */
83055 smp_mb__before_atomic_inc(); /* ^^^ */
83056 - atomic_long_inc(&rsp->expedited_done_lost);
83057 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83058 break;
83059 }
83060 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83061 - atomic_long_inc(&rsp->expedited_done_exit);
83062 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83063
83064 put_online_cpus();
83065 }
83066 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83067 * ACCESS_ONCE() to prevent the compiler from speculating
83068 * the increment to precede the early-exit check.
83069 */
83070 - ACCESS_ONCE(rsp->n_barrier_done)++;
83071 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83072 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83073 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83074 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83075 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83076
83077 /* Increment ->n_barrier_done to prevent duplicate work. */
83078 smp_mb(); /* Keep increment after above mechanism. */
83079 - ACCESS_ONCE(rsp->n_barrier_done)++;
83080 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83081 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83082 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83083 smp_mb(); /* Keep increment before caller's subsequent code. */
83084 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83085 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83086 init_callback_list(rdp);
83087 rdp->qlen_lazy = 0;
83088 - ACCESS_ONCE(rdp->qlen) = 0;
83089 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83090 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83091 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83092 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83093 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83094 rdp->cpu = cpu;
83095 rdp->rsp = rsp;
83096 rcu_boot_init_nocb_percpu_data(rdp);
83097 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83098 rdp->blimit = blimit;
83099 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83100 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83101 - atomic_set(&rdp->dynticks->dynticks,
83102 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83103 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83104 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83105 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83106
83107 /* Add CPU to rcu_node bitmasks. */
83108 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83109 index b383258..2440c1e 100644
83110 --- a/kernel/rcutree.h
83111 +++ b/kernel/rcutree.h
83112 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83113 long long dynticks_nesting; /* Track irq/process nesting level. */
83114 /* Process level is worth LLONG_MAX/2. */
83115 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83116 - atomic_t dynticks; /* Even value for idle, else odd. */
83117 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83118 #ifdef CONFIG_RCU_FAST_NO_HZ
83119 bool all_lazy; /* Are all CPU's CBs lazy? */
83120 unsigned long nonlazy_posted;
83121 @@ -419,17 +419,17 @@ struct rcu_state {
83122 /* _rcu_barrier(). */
83123 /* End of fields guarded by barrier_mutex. */
83124
83125 - atomic_long_t expedited_start; /* Starting ticket. */
83126 - atomic_long_t expedited_done; /* Done ticket. */
83127 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83128 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83129 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83130 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83131 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83132 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83133 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83134 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83135 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83136 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83137 + atomic_long_t expedited_done; /* Done ticket. */
83138 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83139 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83140 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83141 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83142 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83143 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83144 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83145 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83146 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83147
83148 unsigned long jiffies_force_qs; /* Time at which to invoke */
83149 /* force_quiescent_state(). */
83150 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83151 index 769e12e..7b2139b 100644
83152 --- a/kernel/rcutree_plugin.h
83153 +++ b/kernel/rcutree_plugin.h
83154 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83155
83156 /* Clean up and exit. */
83157 smp_mb(); /* ensure expedited GP seen before counter increment. */
83158 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83159 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83160 unlock_mb_ret:
83161 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83162 mb_ret:
83163 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83164 free_cpumask_var(cm);
83165 }
83166
83167 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83168 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83169 .store = &rcu_cpu_kthread_task,
83170 .thread_should_run = rcu_cpu_kthread_should_run,
83171 .thread_fn = rcu_cpu_kthread,
83172 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83173 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83174 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83175 cpu, ticks_value, ticks_title,
83176 - atomic_read(&rdtp->dynticks) & 0xfff,
83177 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83178 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83179 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83180 fast_no_hz);
83181 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83182
83183 /* Enqueue the callback on the nocb list and update counts. */
83184 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83185 - ACCESS_ONCE(*old_rhpp) = rhp;
83186 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83187 atomic_long_add(rhcount, &rdp->nocb_q_count);
83188 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83189
83190 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83191 * Extract queued callbacks, update counts, and wait
83192 * for a grace period to elapse.
83193 */
83194 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83195 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83196 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83197 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83198 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83199 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83200 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83201 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83202 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83203 rcu_nocb_wait_gp(rdp);
83204
83205 /* Each pass through the following loop invokes a callback. */
83206 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83207 list = next;
83208 }
83209 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83210 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83211 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83212 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83213 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83214 rdp->n_nocbs_invoked += c;
83215 }
83216 return 0;
83217 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83218 t = kthread_run(rcu_nocb_kthread, rdp,
83219 "rcuo%c/%d", rsp->abbr, cpu);
83220 BUG_ON(IS_ERR(t));
83221 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83222 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83223 }
83224 }
83225
83226 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83227 index cf6c174..a8f4b50 100644
83228 --- a/kernel/rcutree_trace.c
83229 +++ b/kernel/rcutree_trace.c
83230 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83231 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83232 rdp->passed_quiesce, rdp->qs_pending);
83233 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83234 - atomic_read(&rdp->dynticks->dynticks),
83235 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83236 rdp->dynticks->dynticks_nesting,
83237 rdp->dynticks->dynticks_nmi_nesting,
83238 rdp->dynticks_fqs);
83239 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83240 struct rcu_state *rsp = (struct rcu_state *)m->private;
83241
83242 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",
83243 - atomic_long_read(&rsp->expedited_start),
83244 + atomic_long_read_unchecked(&rsp->expedited_start),
83245 atomic_long_read(&rsp->expedited_done),
83246 - atomic_long_read(&rsp->expedited_wrap),
83247 - atomic_long_read(&rsp->expedited_tryfail),
83248 - atomic_long_read(&rsp->expedited_workdone1),
83249 - atomic_long_read(&rsp->expedited_workdone2),
83250 - atomic_long_read(&rsp->expedited_normal),
83251 - atomic_long_read(&rsp->expedited_stoppedcpus),
83252 - atomic_long_read(&rsp->expedited_done_tries),
83253 - atomic_long_read(&rsp->expedited_done_lost),
83254 - atomic_long_read(&rsp->expedited_done_exit));
83255 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83256 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83257 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83258 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83259 + atomic_long_read_unchecked(&rsp->expedited_normal),
83260 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83261 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83262 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83263 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83264 return 0;
83265 }
83266
83267 diff --git a/kernel/resource.c b/kernel/resource.c
83268 index 3f285dc..5755f62 100644
83269 --- a/kernel/resource.c
83270 +++ b/kernel/resource.c
83271 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83272
83273 static int __init ioresources_init(void)
83274 {
83275 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83276 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83277 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83278 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83279 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83280 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83281 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83282 +#endif
83283 +#else
83284 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83285 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83286 +#endif
83287 return 0;
83288 }
83289 __initcall(ioresources_init);
83290 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83291 index 1d96dd0..994ff19 100644
83292 --- a/kernel/rtmutex-tester.c
83293 +++ b/kernel/rtmutex-tester.c
83294 @@ -22,7 +22,7 @@
83295 #define MAX_RT_TEST_MUTEXES 8
83296
83297 static spinlock_t rttest_lock;
83298 -static atomic_t rttest_event;
83299 +static atomic_unchecked_t rttest_event;
83300
83301 struct test_thread_data {
83302 int opcode;
83303 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83304
83305 case RTTEST_LOCKCONT:
83306 td->mutexes[td->opdata] = 1;
83307 - td->event = atomic_add_return(1, &rttest_event);
83308 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83309 return 0;
83310
83311 case RTTEST_RESET:
83312 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83313 return 0;
83314
83315 case RTTEST_RESETEVENT:
83316 - atomic_set(&rttest_event, 0);
83317 + atomic_set_unchecked(&rttest_event, 0);
83318 return 0;
83319
83320 default:
83321 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83322 return ret;
83323
83324 td->mutexes[id] = 1;
83325 - td->event = atomic_add_return(1, &rttest_event);
83326 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83327 rt_mutex_lock(&mutexes[id]);
83328 - td->event = atomic_add_return(1, &rttest_event);
83329 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83330 td->mutexes[id] = 4;
83331 return 0;
83332
83333 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83334 return ret;
83335
83336 td->mutexes[id] = 1;
83337 - td->event = atomic_add_return(1, &rttest_event);
83338 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83339 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83340 - td->event = atomic_add_return(1, &rttest_event);
83341 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83342 td->mutexes[id] = ret ? 0 : 4;
83343 return ret ? -EINTR : 0;
83344
83345 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83346 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83347 return ret;
83348
83349 - td->event = atomic_add_return(1, &rttest_event);
83350 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83351 rt_mutex_unlock(&mutexes[id]);
83352 - td->event = atomic_add_return(1, &rttest_event);
83353 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83354 td->mutexes[id] = 0;
83355 return 0;
83356
83357 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83358 break;
83359
83360 td->mutexes[dat] = 2;
83361 - td->event = atomic_add_return(1, &rttest_event);
83362 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83363 break;
83364
83365 default:
83366 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83367 return;
83368
83369 td->mutexes[dat] = 3;
83370 - td->event = atomic_add_return(1, &rttest_event);
83371 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83372 break;
83373
83374 case RTTEST_LOCKNOWAIT:
83375 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83376 return;
83377
83378 td->mutexes[dat] = 1;
83379 - td->event = atomic_add_return(1, &rttest_event);
83380 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83381 return;
83382
83383 default:
83384 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83385 index 4a07353..66b5291 100644
83386 --- a/kernel/sched/auto_group.c
83387 +++ b/kernel/sched/auto_group.c
83388 @@ -11,7 +11,7 @@
83389
83390 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83391 static struct autogroup autogroup_default;
83392 -static atomic_t autogroup_seq_nr;
83393 +static atomic_unchecked_t autogroup_seq_nr;
83394
83395 void __init autogroup_init(struct task_struct *init_task)
83396 {
83397 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83398
83399 kref_init(&ag->kref);
83400 init_rwsem(&ag->lock);
83401 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83402 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83403 ag->tg = tg;
83404 #ifdef CONFIG_RT_GROUP_SCHED
83405 /*
83406 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83407 index 05c39f0..442e6fe 100644
83408 --- a/kernel/sched/core.c
83409 +++ b/kernel/sched/core.c
83410 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83411 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83412 * or number of jiffies left till timeout) if completed.
83413 */
83414 -long __sched
83415 +long __sched __intentional_overflow(-1)
83416 wait_for_completion_interruptible_timeout(struct completion *x,
83417 unsigned long timeout)
83418 {
83419 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83420 *
83421 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83422 */
83423 -int __sched wait_for_completion_killable(struct completion *x)
83424 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83425 {
83426 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83427 if (t == -ERESTARTSYS)
83428 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83429 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83430 * or number of jiffies left till timeout) if completed.
83431 */
83432 -long __sched
83433 +long __sched __intentional_overflow(-1)
83434 wait_for_completion_killable_timeout(struct completion *x,
83435 unsigned long timeout)
83436 {
83437 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83438 /* convert nice value [19,-20] to rlimit style value [1,40] */
83439 int nice_rlim = 20 - nice;
83440
83441 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83442 +
83443 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83444 capable(CAP_SYS_NICE));
83445 }
83446 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83447 if (nice > 19)
83448 nice = 19;
83449
83450 - if (increment < 0 && !can_nice(current, nice))
83451 + if (increment < 0 && (!can_nice(current, nice) ||
83452 + gr_handle_chroot_nice()))
83453 return -EPERM;
83454
83455 retval = security_task_setnice(current, nice);
83456 @@ -3344,6 +3347,7 @@ recheck:
83457 unsigned long rlim_rtprio =
83458 task_rlimit(p, RLIMIT_RTPRIO);
83459
83460 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83461 /* can't set/change the rt policy */
83462 if (policy != p->policy && !rlim_rtprio)
83463 return -EPERM;
83464 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83465
83466 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83467
83468 -static struct ctl_table sd_ctl_dir[] = {
83469 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83470 {
83471 .procname = "sched_domain",
83472 .mode = 0555,
83473 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83474 {}
83475 };
83476
83477 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83478 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83479 {
83480 - struct ctl_table *entry =
83481 + ctl_table_no_const *entry =
83482 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83483
83484 return entry;
83485 }
83486
83487 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83488 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83489 {
83490 - struct ctl_table *entry;
83491 + ctl_table_no_const *entry;
83492
83493 /*
83494 * In the intermediate directories, both the child directory and
83495 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83496 * will always be set. In the lowest directory the names are
83497 * static strings and all have proc handlers.
83498 */
83499 - for (entry = *tablep; entry->mode; entry++) {
83500 - if (entry->child)
83501 - sd_free_ctl_entry(&entry->child);
83502 + for (entry = tablep; entry->mode; entry++) {
83503 + if (entry->child) {
83504 + sd_free_ctl_entry(entry->child);
83505 + pax_open_kernel();
83506 + entry->child = NULL;
83507 + pax_close_kernel();
83508 + }
83509 if (entry->proc_handler == NULL)
83510 kfree(entry->procname);
83511 }
83512
83513 - kfree(*tablep);
83514 - *tablep = NULL;
83515 + kfree(tablep);
83516 }
83517
83518 static int min_load_idx = 0;
83519 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83520
83521 static void
83522 -set_table_entry(struct ctl_table *entry,
83523 +set_table_entry(ctl_table_no_const *entry,
83524 const char *procname, void *data, int maxlen,
83525 umode_t mode, proc_handler *proc_handler,
83526 bool load_idx)
83527 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83528 static struct ctl_table *
83529 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83530 {
83531 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83532 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83533
83534 if (table == NULL)
83535 return NULL;
83536 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83537 return table;
83538 }
83539
83540 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83541 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83542 {
83543 - struct ctl_table *entry, *table;
83544 + ctl_table_no_const *entry, *table;
83545 struct sched_domain *sd;
83546 int domain_num = 0, i;
83547 char buf[32];
83548 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83549 static void register_sched_domain_sysctl(void)
83550 {
83551 int i, cpu_num = num_possible_cpus();
83552 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83553 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83554 char buf[32];
83555
83556 WARN_ON(sd_ctl_dir[0].child);
83557 + pax_open_kernel();
83558 sd_ctl_dir[0].child = entry;
83559 + pax_close_kernel();
83560
83561 if (entry == NULL)
83562 return;
83563 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83564 if (sd_sysctl_header)
83565 unregister_sysctl_table(sd_sysctl_header);
83566 sd_sysctl_header = NULL;
83567 - if (sd_ctl_dir[0].child)
83568 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83569 + if (sd_ctl_dir[0].child) {
83570 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83571 + pax_open_kernel();
83572 + sd_ctl_dir[0].child = NULL;
83573 + pax_close_kernel();
83574 + }
83575 }
83576 #else
83577 static void register_sched_domain_sysctl(void)
83578 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83579 index 68f1609..2a9fe8a 100644
83580 --- a/kernel/sched/fair.c
83581 +++ b/kernel/sched/fair.c
83582 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83583
83584 static void reset_ptenuma_scan(struct task_struct *p)
83585 {
83586 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83587 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83588 p->mm->numa_scan_offset = 0;
83589 }
83590
83591 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83592 * run_rebalance_domains is triggered when needed from the scheduler tick.
83593 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83594 */
83595 -static void run_rebalance_domains(struct softirq_action *h)
83596 +static __latent_entropy void run_rebalance_domains(void)
83597 {
83598 int this_cpu = smp_processor_id();
83599 struct rq *this_rq = cpu_rq(this_cpu);
83600 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83601 index ef0a7b2..1b728c1 100644
83602 --- a/kernel/sched/sched.h
83603 +++ b/kernel/sched/sched.h
83604 @@ -1004,7 +1004,7 @@ struct sched_class {
83605 #ifdef CONFIG_FAIR_GROUP_SCHED
83606 void (*task_move_group) (struct task_struct *p, int on_rq);
83607 #endif
83608 -};
83609 +} __do_const;
83610
83611 #define sched_class_highest (&stop_sched_class)
83612 #define for_each_class(class) \
83613 diff --git a/kernel/signal.c b/kernel/signal.c
83614 index 50e4107..9409983 100644
83615 --- a/kernel/signal.c
83616 +++ b/kernel/signal.c
83617 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83618
83619 int print_fatal_signals __read_mostly;
83620
83621 -static void __user *sig_handler(struct task_struct *t, int sig)
83622 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83623 {
83624 return t->sighand->action[sig - 1].sa.sa_handler;
83625 }
83626
83627 -static int sig_handler_ignored(void __user *handler, int sig)
83628 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83629 {
83630 /* Is it explicitly or implicitly ignored? */
83631 return handler == SIG_IGN ||
83632 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83633
83634 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83635 {
83636 - void __user *handler;
83637 + __sighandler_t handler;
83638
83639 handler = sig_handler(t, sig);
83640
83641 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83642 atomic_inc(&user->sigpending);
83643 rcu_read_unlock();
83644
83645 + if (!override_rlimit)
83646 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83647 +
83648 if (override_rlimit ||
83649 atomic_read(&user->sigpending) <=
83650 task_rlimit(t, RLIMIT_SIGPENDING)) {
83651 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83652
83653 int unhandled_signal(struct task_struct *tsk, int sig)
83654 {
83655 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83656 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83657 if (is_global_init(tsk))
83658 return 1;
83659 if (handler != SIG_IGN && handler != SIG_DFL)
83660 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83661 }
83662 }
83663
83664 + /* allow glibc communication via tgkill to other threads in our
83665 + thread group */
83666 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83667 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83668 + && gr_handle_signal(t, sig))
83669 + return -EPERM;
83670 +
83671 return security_task_kill(t, info, sig, 0);
83672 }
83673
83674 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83675 return send_signal(sig, info, p, 1);
83676 }
83677
83678 -static int
83679 +int
83680 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83681 {
83682 return send_signal(sig, info, t, 0);
83683 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83684 unsigned long int flags;
83685 int ret, blocked, ignored;
83686 struct k_sigaction *action;
83687 + int is_unhandled = 0;
83688
83689 spin_lock_irqsave(&t->sighand->siglock, flags);
83690 action = &t->sighand->action[sig-1];
83691 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83692 }
83693 if (action->sa.sa_handler == SIG_DFL)
83694 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83695 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83696 + is_unhandled = 1;
83697 ret = specific_send_sig_info(sig, info, t);
83698 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83699
83700 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83701 + normal operation */
83702 + if (is_unhandled) {
83703 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83704 + gr_handle_crash(t, sig);
83705 + }
83706 +
83707 return ret;
83708 }
83709
83710 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83711 ret = check_kill_permission(sig, info, p);
83712 rcu_read_unlock();
83713
83714 - if (!ret && sig)
83715 + if (!ret && sig) {
83716 ret = do_send_sig_info(sig, info, p, true);
83717 + if (!ret)
83718 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83719 + }
83720
83721 return ret;
83722 }
83723 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83724 int error = -ESRCH;
83725
83726 rcu_read_lock();
83727 - p = find_task_by_vpid(pid);
83728 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83729 + /* allow glibc communication via tgkill to other threads in our
83730 + thread group */
83731 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83732 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83733 + p = find_task_by_vpid_unrestricted(pid);
83734 + else
83735 +#endif
83736 + p = find_task_by_vpid(pid);
83737 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83738 error = check_kill_permission(sig, info, p);
83739 /*
83740 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83741 }
83742 seg = get_fs();
83743 set_fs(KERNEL_DS);
83744 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83745 - (stack_t __force __user *) &uoss,
83746 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83747 + (stack_t __force_user *) &uoss,
83748 compat_user_stack_pointer());
83749 set_fs(seg);
83750 if (ret >= 0 && uoss_ptr) {
83751 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83752 index eb89e18..a4e6792 100644
83753 --- a/kernel/smpboot.c
83754 +++ b/kernel/smpboot.c
83755 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83756 }
83757 smpboot_unpark_thread(plug_thread, cpu);
83758 }
83759 - list_add(&plug_thread->list, &hotplug_threads);
83760 + pax_list_add(&plug_thread->list, &hotplug_threads);
83761 out:
83762 mutex_unlock(&smpboot_threads_lock);
83763 return ret;
83764 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83765 {
83766 get_online_cpus();
83767 mutex_lock(&smpboot_threads_lock);
83768 - list_del(&plug_thread->list);
83769 + pax_list_del(&plug_thread->list);
83770 smpboot_destroy_threads(plug_thread);
83771 mutex_unlock(&smpboot_threads_lock);
83772 put_online_cpus();
83773 diff --git a/kernel/softirq.c b/kernel/softirq.c
83774 index be3d351..e57af82 100644
83775 --- a/kernel/softirq.c
83776 +++ b/kernel/softirq.c
83777 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83778 EXPORT_SYMBOL(irq_stat);
83779 #endif
83780
83781 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83782 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83783
83784 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83785
83786 -char *softirq_to_name[NR_SOFTIRQS] = {
83787 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83788 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83789 "TASKLET", "SCHED", "HRTIMER", "RCU"
83790 };
83791 @@ -248,7 +248,7 @@ restart:
83792 kstat_incr_softirqs_this_cpu(vec_nr);
83793
83794 trace_softirq_entry(vec_nr);
83795 - h->action(h);
83796 + h->action();
83797 trace_softirq_exit(vec_nr);
83798 if (unlikely(prev_count != preempt_count())) {
83799 printk(KERN_ERR "huh, entered softirq %u %s %p"
83800 @@ -403,7 +403,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83801 or_softirq_pending(1UL << nr);
83802 }
83803
83804 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83805 +void __init open_softirq(int nr, void (*action)(void))
83806 {
83807 softirq_vec[nr].action = action;
83808 }
83809 @@ -459,7 +459,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83810
83811 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83812
83813 -static void tasklet_action(struct softirq_action *a)
83814 +static __latent_entropy void tasklet_action(void)
83815 {
83816 struct tasklet_struct *list;
83817
83818 @@ -494,7 +494,7 @@ static void tasklet_action(struct softirq_action *a)
83819 }
83820 }
83821
83822 -static void tasklet_hi_action(struct softirq_action *a)
83823 +static __latent_entropy void tasklet_hi_action(void)
83824 {
83825 struct tasklet_struct *list;
83826
83827 @@ -849,7 +849,7 @@ static struct notifier_block cpu_nfb = {
83828 .notifier_call = cpu_callback
83829 };
83830
83831 -static struct smp_hotplug_thread softirq_threads = {
83832 +static struct smp_hotplug_thread softirq_threads __read_only = {
83833 .store = &ksoftirqd,
83834 .thread_should_run = ksoftirqd_should_run,
83835 .thread_fn = run_ksoftirqd,
83836 diff --git a/kernel/srcu.c b/kernel/srcu.c
83837 index 01d5ccb..cdcbee6 100644
83838 --- a/kernel/srcu.c
83839 +++ b/kernel/srcu.c
83840 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83841
83842 idx = ACCESS_ONCE(sp->completed) & 0x1;
83843 preempt_disable();
83844 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83845 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83846 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83847 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83848 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83849 preempt_enable();
83850 return idx;
83851 }
83852 diff --git a/kernel/sys.c b/kernel/sys.c
83853 index 771129b..dc0c7e3 100644
83854 --- a/kernel/sys.c
83855 +++ b/kernel/sys.c
83856 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83857 error = -EACCES;
83858 goto out;
83859 }
83860 +
83861 + if (gr_handle_chroot_setpriority(p, niceval)) {
83862 + error = -EACCES;
83863 + goto out;
83864 + }
83865 +
83866 no_nice = security_task_setnice(p, niceval);
83867 if (no_nice) {
83868 error = no_nice;
83869 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83870 goto error;
83871 }
83872
83873 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83874 + goto error;
83875 +
83876 if (rgid != (gid_t) -1 ||
83877 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83878 new->sgid = new->egid;
83879 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83880 old = current_cred();
83881
83882 retval = -EPERM;
83883 +
83884 + if (gr_check_group_change(kgid, kgid, kgid))
83885 + goto error;
83886 +
83887 if (nsown_capable(CAP_SETGID))
83888 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83889 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83890 @@ -404,7 +417,7 @@ error:
83891 /*
83892 * change the user struct in a credentials set to match the new UID
83893 */
83894 -static int set_user(struct cred *new)
83895 +int set_user(struct cred *new)
83896 {
83897 struct user_struct *new_user;
83898
83899 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
83900 goto error;
83901 }
83902
83903 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
83904 + goto error;
83905 +
83906 if (!uid_eq(new->uid, old->uid)) {
83907 retval = set_user(new);
83908 if (retval < 0)
83909 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
83910 old = current_cred();
83911
83912 retval = -EPERM;
83913 +
83914 + if (gr_check_crash_uid(kuid))
83915 + goto error;
83916 + if (gr_check_user_change(kuid, kuid, kuid))
83917 + goto error;
83918 +
83919 if (nsown_capable(CAP_SETUID)) {
83920 new->suid = new->uid = kuid;
83921 if (!uid_eq(kuid, old->uid)) {
83922 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
83923 goto error;
83924 }
83925
83926 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
83927 + goto error;
83928 +
83929 if (ruid != (uid_t) -1) {
83930 new->uid = kruid;
83931 if (!uid_eq(kruid, old->uid)) {
83932 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
83933 goto error;
83934 }
83935
83936 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
83937 + goto error;
83938 +
83939 if (rgid != (gid_t) -1)
83940 new->gid = krgid;
83941 if (egid != (gid_t) -1)
83942 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
83943 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
83944 nsown_capable(CAP_SETUID)) {
83945 if (!uid_eq(kuid, old->fsuid)) {
83946 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
83947 + goto error;
83948 +
83949 new->fsuid = kuid;
83950 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
83951 goto change_okay;
83952 }
83953 }
83954
83955 +error:
83956 abort_creds(new);
83957 return old_fsuid;
83958
83959 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
83960 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
83961 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
83962 nsown_capable(CAP_SETGID)) {
83963 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
83964 + goto error;
83965 +
83966 if (!gid_eq(kgid, old->fsgid)) {
83967 new->fsgid = kgid;
83968 goto change_okay;
83969 }
83970 }
83971
83972 +error:
83973 abort_creds(new);
83974 return old_fsgid;
83975
83976 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
83977 return -EFAULT;
83978
83979 down_read(&uts_sem);
83980 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
83981 + error = __copy_to_user(name->sysname, &utsname()->sysname,
83982 __OLD_UTS_LEN);
83983 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
83984 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
83985 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
83986 __OLD_UTS_LEN);
83987 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
83988 - error |= __copy_to_user(&name->release, &utsname()->release,
83989 + error |= __copy_to_user(name->release, &utsname()->release,
83990 __OLD_UTS_LEN);
83991 error |= __put_user(0, name->release + __OLD_UTS_LEN);
83992 - error |= __copy_to_user(&name->version, &utsname()->version,
83993 + error |= __copy_to_user(name->version, &utsname()->version,
83994 __OLD_UTS_LEN);
83995 error |= __put_user(0, name->version + __OLD_UTS_LEN);
83996 - error |= __copy_to_user(&name->machine, &utsname()->machine,
83997 + error |= __copy_to_user(name->machine, &utsname()->machine,
83998 __OLD_UTS_LEN);
83999 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84000 up_read(&uts_sem);
84001 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84002 */
84003 new_rlim->rlim_cur = 1;
84004 }
84005 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84006 + is changed to a lower value. Since tasks can be created by the same
84007 + user in between this limit change and an execve by this task, force
84008 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84009 + */
84010 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84011 + tsk->flags |= PF_NPROC_EXCEEDED;
84012 }
84013 if (!retval) {
84014 if (old_rlim)
84015 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84016 index 07f6fc4..65fb3d4 100644
84017 --- a/kernel/sysctl.c
84018 +++ b/kernel/sysctl.c
84019 @@ -93,7 +93,6 @@
84020
84021
84022 #if defined(CONFIG_SYSCTL)
84023 -
84024 /* External variables not in a header file. */
84025 extern int sysctl_overcommit_memory;
84026 extern int sysctl_overcommit_ratio;
84027 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84028
84029 /* Constants used for minimum and maximum */
84030 #ifdef CONFIG_LOCKUP_DETECTOR
84031 -static int sixty = 60;
84032 +static int sixty __read_only = 60;
84033 #endif
84034
84035 -static int zero;
84036 -static int __maybe_unused one = 1;
84037 -static int __maybe_unused two = 2;
84038 -static int __maybe_unused three = 3;
84039 -static unsigned long one_ul = 1;
84040 -static int one_hundred = 100;
84041 +static int neg_one __read_only = -1;
84042 +static int zero __read_only = 0;
84043 +static int __maybe_unused one __read_only = 1;
84044 +static int __maybe_unused two __read_only = 2;
84045 +static int __maybe_unused three __read_only = 3;
84046 +static unsigned long one_ul __read_only = 1;
84047 +static int one_hundred __read_only = 100;
84048 #ifdef CONFIG_PRINTK
84049 -static int ten_thousand = 10000;
84050 +static int ten_thousand __read_only = 10000;
84051 #endif
84052
84053 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84054 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84055 void __user *buffer, size_t *lenp, loff_t *ppos);
84056 #endif
84057
84058 -#ifdef CONFIG_PRINTK
84059 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84060 void __user *buffer, size_t *lenp, loff_t *ppos);
84061 -#endif
84062
84063 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84064 void __user *buffer, size_t *lenp, loff_t *ppos);
84065 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84066
84067 #endif
84068
84069 +extern struct ctl_table grsecurity_table[];
84070 +
84071 static struct ctl_table kern_table[];
84072 static struct ctl_table vm_table[];
84073 static struct ctl_table fs_table[];
84074 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84075 int sysctl_legacy_va_layout;
84076 #endif
84077
84078 +#ifdef CONFIG_PAX_SOFTMODE
84079 +static ctl_table pax_table[] = {
84080 + {
84081 + .procname = "softmode",
84082 + .data = &pax_softmode,
84083 + .maxlen = sizeof(unsigned int),
84084 + .mode = 0600,
84085 + .proc_handler = &proc_dointvec,
84086 + },
84087 +
84088 + { }
84089 +};
84090 +#endif
84091 +
84092 /* The default sysctl tables: */
84093
84094 static struct ctl_table sysctl_base_table[] = {
84095 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84096 #endif
84097
84098 static struct ctl_table kern_table[] = {
84099 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84100 + {
84101 + .procname = "grsecurity",
84102 + .mode = 0500,
84103 + .child = grsecurity_table,
84104 + },
84105 +#endif
84106 +
84107 +#ifdef CONFIG_PAX_SOFTMODE
84108 + {
84109 + .procname = "pax",
84110 + .mode = 0500,
84111 + .child = pax_table,
84112 + },
84113 +#endif
84114 +
84115 {
84116 .procname = "sched_child_runs_first",
84117 .data = &sysctl_sched_child_runs_first,
84118 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84119 .data = &modprobe_path,
84120 .maxlen = KMOD_PATH_LEN,
84121 .mode = 0644,
84122 - .proc_handler = proc_dostring,
84123 + .proc_handler = proc_dostring_modpriv,
84124 },
84125 {
84126 .procname = "modules_disabled",
84127 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84128 .extra1 = &zero,
84129 .extra2 = &one,
84130 },
84131 +#endif
84132 {
84133 .procname = "kptr_restrict",
84134 .data = &kptr_restrict,
84135 .maxlen = sizeof(int),
84136 .mode = 0644,
84137 .proc_handler = proc_dointvec_minmax_sysadmin,
84138 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84139 + .extra1 = &two,
84140 +#else
84141 .extra1 = &zero,
84142 +#endif
84143 .extra2 = &two,
84144 },
84145 -#endif
84146 {
84147 .procname = "ngroups_max",
84148 .data = &ngroups_max,
84149 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84150 */
84151 {
84152 .procname = "perf_event_paranoid",
84153 - .data = &sysctl_perf_event_paranoid,
84154 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84155 + .data = &sysctl_perf_event_legitimately_concerned,
84156 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84157 .mode = 0644,
84158 - .proc_handler = proc_dointvec,
84159 + /* go ahead, be a hero */
84160 + .proc_handler = proc_dointvec_minmax_sysadmin,
84161 + .extra1 = &neg_one,
84162 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84163 + .extra2 = &three,
84164 +#else
84165 + .extra2 = &two,
84166 +#endif
84167 },
84168 {
84169 .procname = "perf_event_mlock_kb",
84170 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84171 .proc_handler = proc_dointvec_minmax,
84172 .extra1 = &zero,
84173 },
84174 + {
84175 + .procname = "heap_stack_gap",
84176 + .data = &sysctl_heap_stack_gap,
84177 + .maxlen = sizeof(sysctl_heap_stack_gap),
84178 + .mode = 0644,
84179 + .proc_handler = proc_doulongvec_minmax,
84180 + },
84181 #else
84182 {
84183 .procname = "nr_trim_pages",
84184 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84185 buffer, lenp, ppos);
84186 }
84187
84188 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84189 + void __user *buffer, size_t *lenp, loff_t *ppos)
84190 +{
84191 + if (write && !capable(CAP_SYS_MODULE))
84192 + return -EPERM;
84193 +
84194 + return _proc_do_string(table->data, table->maxlen, write,
84195 + buffer, lenp, ppos);
84196 +}
84197 +
84198 static size_t proc_skip_spaces(char **buf)
84199 {
84200 size_t ret;
84201 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84202 len = strlen(tmp);
84203 if (len > *size)
84204 len = *size;
84205 + if (len > sizeof(tmp))
84206 + len = sizeof(tmp);
84207 if (copy_to_user(*buf, tmp, len))
84208 return -EFAULT;
84209 *size -= len;
84210 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84211 static int proc_taint(struct ctl_table *table, int write,
84212 void __user *buffer, size_t *lenp, loff_t *ppos)
84213 {
84214 - struct ctl_table t;
84215 + ctl_table_no_const t;
84216 unsigned long tmptaint = get_taint();
84217 int err;
84218
84219 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84220 return err;
84221 }
84222
84223 -#ifdef CONFIG_PRINTK
84224 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84225 void __user *buffer, size_t *lenp, loff_t *ppos)
84226 {
84227 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84228
84229 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84230 }
84231 -#endif
84232
84233 struct do_proc_dointvec_minmax_conv_param {
84234 int *min;
84235 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84236 *i = val;
84237 } else {
84238 val = convdiv * (*i) / convmul;
84239 - if (!first)
84240 + if (!first) {
84241 err = proc_put_char(&buffer, &left, '\t');
84242 + if (err)
84243 + break;
84244 + }
84245 err = proc_put_long(&buffer, &left, val, false);
84246 if (err)
84247 break;
84248 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84249 return -ENOSYS;
84250 }
84251
84252 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84253 + void __user *buffer, size_t *lenp, loff_t *ppos)
84254 +{
84255 + return -ENOSYS;
84256 +}
84257 +
84258 int proc_dointvec(struct ctl_table *table, int write,
84259 void __user *buffer, size_t *lenp, loff_t *ppos)
84260 {
84261 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84262 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84263 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84264 EXPORT_SYMBOL(proc_dostring);
84265 +EXPORT_SYMBOL(proc_dostring_modpriv);
84266 EXPORT_SYMBOL(proc_doulongvec_minmax);
84267 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84268 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84269 index 145bb4d..b2aa969 100644
84270 --- a/kernel/taskstats.c
84271 +++ b/kernel/taskstats.c
84272 @@ -28,9 +28,12 @@
84273 #include <linux/fs.h>
84274 #include <linux/file.h>
84275 #include <linux/pid_namespace.h>
84276 +#include <linux/grsecurity.h>
84277 #include <net/genetlink.h>
84278 #include <linux/atomic.h>
84279
84280 +extern int gr_is_taskstats_denied(int pid);
84281 +
84282 /*
84283 * Maximum length of a cpumask that can be specified in
84284 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84285 @@ -570,6 +573,9 @@ err:
84286
84287 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84288 {
84289 + if (gr_is_taskstats_denied(current->pid))
84290 + return -EACCES;
84291 +
84292 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84293 return cmd_attr_register_cpumask(info);
84294 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84295 diff --git a/kernel/time.c b/kernel/time.c
84296 index 7c7964c..784a599 100644
84297 --- a/kernel/time.c
84298 +++ b/kernel/time.c
84299 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84300 return error;
84301
84302 if (tz) {
84303 + /* we log in do_settimeofday called below, so don't log twice
84304 + */
84305 + if (!tv)
84306 + gr_log_timechange();
84307 +
84308 sys_tz = *tz;
84309 update_vsyscall_tz();
84310 if (firsttime) {
84311 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84312 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84313 * value to a scaled second value.
84314 */
84315 -unsigned long
84316 +unsigned long __intentional_overflow(-1)
84317 timespec_to_jiffies(const struct timespec *value)
84318 {
84319 unsigned long sec = value->tv_sec;
84320 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84321 index eec50fc..65e5df6 100644
84322 --- a/kernel/time/alarmtimer.c
84323 +++ b/kernel/time/alarmtimer.c
84324 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84325 struct platform_device *pdev;
84326 int error = 0;
84327 int i;
84328 - struct k_clock alarm_clock = {
84329 + static struct k_clock alarm_clock = {
84330 .clock_getres = alarm_clock_getres,
84331 .clock_get = alarm_clock_get,
84332 .timer_create = alarm_timer_create,
84333 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84334 index 48b9fff..9e07e5f 100644
84335 --- a/kernel/time/timekeeping.c
84336 +++ b/kernel/time/timekeeping.c
84337 @@ -15,6 +15,7 @@
84338 #include <linux/init.h>
84339 #include <linux/mm.h>
84340 #include <linux/sched.h>
84341 +#include <linux/grsecurity.h>
84342 #include <linux/syscore_ops.h>
84343 #include <linux/clocksource.h>
84344 #include <linux/jiffies.h>
84345 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84346 if (!timespec_valid_strict(tv))
84347 return -EINVAL;
84348
84349 + gr_log_timechange();
84350 +
84351 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84352 write_seqcount_begin(&timekeeper_seq);
84353
84354 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84355 index 61ed862..3b52c65 100644
84356 --- a/kernel/time/timer_list.c
84357 +++ b/kernel/time/timer_list.c
84358 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84359
84360 static void print_name_offset(struct seq_file *m, void *sym)
84361 {
84362 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84363 + SEQ_printf(m, "<%p>", NULL);
84364 +#else
84365 char symname[KSYM_NAME_LEN];
84366
84367 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84368 SEQ_printf(m, "<%pK>", sym);
84369 else
84370 SEQ_printf(m, "%s", symname);
84371 +#endif
84372 }
84373
84374 static void
84375 @@ -119,7 +123,11 @@ next_one:
84376 static void
84377 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84378 {
84379 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84380 + SEQ_printf(m, " .base: %p\n", NULL);
84381 +#else
84382 SEQ_printf(m, " .base: %pK\n", base);
84383 +#endif
84384 SEQ_printf(m, " .index: %d\n",
84385 base->index);
84386 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84387 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84388 {
84389 struct proc_dir_entry *pe;
84390
84391 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84392 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84393 +#else
84394 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84395 +#endif
84396 if (!pe)
84397 return -ENOMEM;
84398 return 0;
84399 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84400 index 0b537f2..40d6c20 100644
84401 --- a/kernel/time/timer_stats.c
84402 +++ b/kernel/time/timer_stats.c
84403 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84404 static unsigned long nr_entries;
84405 static struct entry entries[MAX_ENTRIES];
84406
84407 -static atomic_t overflow_count;
84408 +static atomic_unchecked_t overflow_count;
84409
84410 /*
84411 * The entries are in a hash-table, for fast lookup:
84412 @@ -140,7 +140,7 @@ static void reset_entries(void)
84413 nr_entries = 0;
84414 memset(entries, 0, sizeof(entries));
84415 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84416 - atomic_set(&overflow_count, 0);
84417 + atomic_set_unchecked(&overflow_count, 0);
84418 }
84419
84420 static struct entry *alloc_entry(void)
84421 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84422 if (likely(entry))
84423 entry->count++;
84424 else
84425 - atomic_inc(&overflow_count);
84426 + atomic_inc_unchecked(&overflow_count);
84427
84428 out_unlock:
84429 raw_spin_unlock_irqrestore(lock, flags);
84430 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84431
84432 static void print_name_offset(struct seq_file *m, unsigned long addr)
84433 {
84434 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84435 + seq_printf(m, "<%p>", NULL);
84436 +#else
84437 char symname[KSYM_NAME_LEN];
84438
84439 if (lookup_symbol_name(addr, symname) < 0)
84440 - seq_printf(m, "<%p>", (void *)addr);
84441 + seq_printf(m, "<%pK>", (void *)addr);
84442 else
84443 seq_printf(m, "%s", symname);
84444 +#endif
84445 }
84446
84447 static int tstats_show(struct seq_file *m, void *v)
84448 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84449
84450 seq_puts(m, "Timer Stats Version: v0.2\n");
84451 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84452 - if (atomic_read(&overflow_count))
84453 + if (atomic_read_unchecked(&overflow_count))
84454 seq_printf(m, "Overflow: %d entries\n",
84455 - atomic_read(&overflow_count));
84456 + atomic_read_unchecked(&overflow_count));
84457
84458 for (i = 0; i < nr_entries; i++) {
84459 entry = entries + i;
84460 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84461 {
84462 struct proc_dir_entry *pe;
84463
84464 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84465 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84466 +#else
84467 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84468 +#endif
84469 if (!pe)
84470 return -ENOMEM;
84471 return 0;
84472 diff --git a/kernel/timer.c b/kernel/timer.c
84473 index 4296d13..0164b04 100644
84474 --- a/kernel/timer.c
84475 +++ b/kernel/timer.c
84476 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84477 /*
84478 * This function runs timers and the timer-tq in bottom half context.
84479 */
84480 -static void run_timer_softirq(struct softirq_action *h)
84481 +static __latent_entropy void run_timer_softirq(void)
84482 {
84483 struct tvec_base *base = __this_cpu_read(tvec_bases);
84484
84485 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84486 *
84487 * In all cases the return value is guaranteed to be non-negative.
84488 */
84489 -signed long __sched schedule_timeout(signed long timeout)
84490 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84491 {
84492 struct timer_list timer;
84493 unsigned long expire;
84494 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84495 index b8b8560..75b1a09 100644
84496 --- a/kernel/trace/blktrace.c
84497 +++ b/kernel/trace/blktrace.c
84498 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84499 struct blk_trace *bt = filp->private_data;
84500 char buf[16];
84501
84502 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84503 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84504
84505 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84506 }
84507 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84508 return 1;
84509
84510 bt = buf->chan->private_data;
84511 - atomic_inc(&bt->dropped);
84512 + atomic_inc_unchecked(&bt->dropped);
84513 return 0;
84514 }
84515
84516 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84517
84518 bt->dir = dir;
84519 bt->dev = dev;
84520 - atomic_set(&bt->dropped, 0);
84521 + atomic_set_unchecked(&bt->dropped, 0);
84522
84523 ret = -EIO;
84524 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84525 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84526 index a6d098c..bb8cf65 100644
84527 --- a/kernel/trace/ftrace.c
84528 +++ b/kernel/trace/ftrace.c
84529 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84530 if (unlikely(ftrace_disabled))
84531 return 0;
84532
84533 + ret = ftrace_arch_code_modify_prepare();
84534 + FTRACE_WARN_ON(ret);
84535 + if (ret)
84536 + return 0;
84537 +
84538 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84539 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84540 if (ret) {
84541 ftrace_bug(ret, ip);
84542 - return 0;
84543 }
84544 - return 1;
84545 + return ret ? 0 : 1;
84546 }
84547
84548 /*
84549 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84550 if (!count)
84551 return 0;
84552
84553 + pax_open_kernel();
84554 sort(start, count, sizeof(*start),
84555 ftrace_cmp_ips, ftrace_swap_ips);
84556 + pax_close_kernel();
84557
84558 start_pg = ftrace_allocate_pages(count);
84559 if (!start_pg)
84560 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84561 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84562
84563 static int ftrace_graph_active;
84564 -static struct notifier_block ftrace_suspend_notifier;
84565 -
84566 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84567 {
84568 return 0;
84569 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84570 return NOTIFY_DONE;
84571 }
84572
84573 +static struct notifier_block ftrace_suspend_notifier = {
84574 + .notifier_call = ftrace_suspend_notifier_call
84575 +};
84576 +
84577 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84578 trace_func_graph_ent_t entryfunc)
84579 {
84580 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84581 goto out;
84582 }
84583
84584 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84585 register_pm_notifier(&ftrace_suspend_notifier);
84586
84587 ftrace_graph_active++;
84588 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84589 index cc2f66f..05edd54 100644
84590 --- a/kernel/trace/ring_buffer.c
84591 +++ b/kernel/trace/ring_buffer.c
84592 @@ -352,9 +352,9 @@ struct buffer_data_page {
84593 */
84594 struct buffer_page {
84595 struct list_head list; /* list of buffer pages */
84596 - local_t write; /* index for next write */
84597 + local_unchecked_t write; /* index for next write */
84598 unsigned read; /* index for next read */
84599 - local_t entries; /* entries on this page */
84600 + local_unchecked_t entries; /* entries on this page */
84601 unsigned long real_end; /* real end of data */
84602 struct buffer_data_page *page; /* Actual data page */
84603 };
84604 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84605 unsigned long last_overrun;
84606 local_t entries_bytes;
84607 local_t entries;
84608 - local_t overrun;
84609 - local_t commit_overrun;
84610 + local_unchecked_t overrun;
84611 + local_unchecked_t commit_overrun;
84612 local_t dropped_events;
84613 local_t committing;
84614 local_t commits;
84615 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84616 *
84617 * We add a counter to the write field to denote this.
84618 */
84619 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84620 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84621 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84622 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84623
84624 /*
84625 * Just make sure we have seen our old_write and synchronize
84626 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84627 * cmpxchg to only update if an interrupt did not already
84628 * do it for us. If the cmpxchg fails, we don't care.
84629 */
84630 - (void)local_cmpxchg(&next_page->write, old_write, val);
84631 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84632 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84633 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84634
84635 /*
84636 * No need to worry about races with clearing out the commit.
84637 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84638
84639 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84640 {
84641 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84642 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84643 }
84644
84645 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84646 {
84647 - return local_read(&bpage->write) & RB_WRITE_MASK;
84648 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84649 }
84650
84651 static int
84652 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84653 * bytes consumed in ring buffer from here.
84654 * Increment overrun to account for the lost events.
84655 */
84656 - local_add(page_entries, &cpu_buffer->overrun);
84657 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84658 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84659 }
84660
84661 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84662 * it is our responsibility to update
84663 * the counters.
84664 */
84665 - local_add(entries, &cpu_buffer->overrun);
84666 + local_add_unchecked(entries, &cpu_buffer->overrun);
84667 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84668
84669 /*
84670 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84671 if (tail == BUF_PAGE_SIZE)
84672 tail_page->real_end = 0;
84673
84674 - local_sub(length, &tail_page->write);
84675 + local_sub_unchecked(length, &tail_page->write);
84676 return;
84677 }
84678
84679 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84680 rb_event_set_padding(event);
84681
84682 /* Set the write back to the previous setting */
84683 - local_sub(length, &tail_page->write);
84684 + local_sub_unchecked(length, &tail_page->write);
84685 return;
84686 }
84687
84688 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84689
84690 /* Set write to end of buffer */
84691 length = (tail + length) - BUF_PAGE_SIZE;
84692 - local_sub(length, &tail_page->write);
84693 + local_sub_unchecked(length, &tail_page->write);
84694 }
84695
84696 /*
84697 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84698 * about it.
84699 */
84700 if (unlikely(next_page == commit_page)) {
84701 - local_inc(&cpu_buffer->commit_overrun);
84702 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84703 goto out_reset;
84704 }
84705
84706 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84707 cpu_buffer->tail_page) &&
84708 (cpu_buffer->commit_page ==
84709 cpu_buffer->reader_page))) {
84710 - local_inc(&cpu_buffer->commit_overrun);
84711 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84712 goto out_reset;
84713 }
84714 }
84715 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84716 length += RB_LEN_TIME_EXTEND;
84717
84718 tail_page = cpu_buffer->tail_page;
84719 - write = local_add_return(length, &tail_page->write);
84720 + write = local_add_return_unchecked(length, &tail_page->write);
84721
84722 /* set write to only the index of the write */
84723 write &= RB_WRITE_MASK;
84724 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84725 kmemcheck_annotate_bitfield(event, bitfield);
84726 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84727
84728 - local_inc(&tail_page->entries);
84729 + local_inc_unchecked(&tail_page->entries);
84730
84731 /*
84732 * If this is the first commit on the page, then update
84733 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84734
84735 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84736 unsigned long write_mask =
84737 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84738 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84739 unsigned long event_length = rb_event_length(event);
84740 /*
84741 * This is on the tail page. It is possible that
84742 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84743 */
84744 old_index += write_mask;
84745 new_index += write_mask;
84746 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84747 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84748 if (index == old_index) {
84749 /* update counters */
84750 local_sub(event_length, &cpu_buffer->entries_bytes);
84751 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84752
84753 /* Do the likely case first */
84754 if (likely(bpage->page == (void *)addr)) {
84755 - local_dec(&bpage->entries);
84756 + local_dec_unchecked(&bpage->entries);
84757 return;
84758 }
84759
84760 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84761 start = bpage;
84762 do {
84763 if (bpage->page == (void *)addr) {
84764 - local_dec(&bpage->entries);
84765 + local_dec_unchecked(&bpage->entries);
84766 return;
84767 }
84768 rb_inc_page(cpu_buffer, &bpage);
84769 @@ -3139,7 +3139,7 @@ static inline unsigned long
84770 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84771 {
84772 return local_read(&cpu_buffer->entries) -
84773 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84774 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84775 }
84776
84777 /**
84778 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84779 return 0;
84780
84781 cpu_buffer = buffer->buffers[cpu];
84782 - ret = local_read(&cpu_buffer->overrun);
84783 + ret = local_read_unchecked(&cpu_buffer->overrun);
84784
84785 return ret;
84786 }
84787 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84788 return 0;
84789
84790 cpu_buffer = buffer->buffers[cpu];
84791 - ret = local_read(&cpu_buffer->commit_overrun);
84792 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84793
84794 return ret;
84795 }
84796 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84797 /* if you care about this being correct, lock the buffer */
84798 for_each_buffer_cpu(buffer, cpu) {
84799 cpu_buffer = buffer->buffers[cpu];
84800 - overruns += local_read(&cpu_buffer->overrun);
84801 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84802 }
84803
84804 return overruns;
84805 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84806 /*
84807 * Reset the reader page to size zero.
84808 */
84809 - local_set(&cpu_buffer->reader_page->write, 0);
84810 - local_set(&cpu_buffer->reader_page->entries, 0);
84811 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84812 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84813 local_set(&cpu_buffer->reader_page->page->commit, 0);
84814 cpu_buffer->reader_page->real_end = 0;
84815
84816 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84817 * want to compare with the last_overrun.
84818 */
84819 smp_mb();
84820 - overwrite = local_read(&(cpu_buffer->overrun));
84821 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84822
84823 /*
84824 * Here's the tricky part.
84825 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84826
84827 cpu_buffer->head_page
84828 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84829 - local_set(&cpu_buffer->head_page->write, 0);
84830 - local_set(&cpu_buffer->head_page->entries, 0);
84831 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84832 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84833 local_set(&cpu_buffer->head_page->page->commit, 0);
84834
84835 cpu_buffer->head_page->read = 0;
84836 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84837
84838 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84839 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84840 - local_set(&cpu_buffer->reader_page->write, 0);
84841 - local_set(&cpu_buffer->reader_page->entries, 0);
84842 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84843 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84844 local_set(&cpu_buffer->reader_page->page->commit, 0);
84845 cpu_buffer->reader_page->read = 0;
84846
84847 local_set(&cpu_buffer->entries_bytes, 0);
84848 - local_set(&cpu_buffer->overrun, 0);
84849 - local_set(&cpu_buffer->commit_overrun, 0);
84850 + local_set_unchecked(&cpu_buffer->overrun, 0);
84851 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84852 local_set(&cpu_buffer->dropped_events, 0);
84853 local_set(&cpu_buffer->entries, 0);
84854 local_set(&cpu_buffer->committing, 0);
84855 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84856 rb_init_page(bpage);
84857 bpage = reader->page;
84858 reader->page = *data_page;
84859 - local_set(&reader->write, 0);
84860 - local_set(&reader->entries, 0);
84861 + local_set_unchecked(&reader->write, 0);
84862 + local_set_unchecked(&reader->entries, 0);
84863 reader->read = 0;
84864 *data_page = bpage;
84865
84866 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84867 index 496f94d..754aeea 100644
84868 --- a/kernel/trace/trace.c
84869 +++ b/kernel/trace/trace.c
84870 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84871 return 0;
84872 }
84873
84874 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84875 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84876 {
84877 /* do nothing if flag is already set */
84878 if (!!(trace_flags & mask) == !!enabled)
84879 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84880 index afaae41..64871f8 100644
84881 --- a/kernel/trace/trace.h
84882 +++ b/kernel/trace/trace.h
84883 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84884 void trace_printk_init_buffers(void);
84885 void trace_printk_start_comm(void);
84886 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84887 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84888 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84889
84890 /*
84891 * Normal trace_printk() and friends allocates special buffers
84892 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84893 index 26dc348..8708ca7 100644
84894 --- a/kernel/trace/trace_clock.c
84895 +++ b/kernel/trace/trace_clock.c
84896 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
84897 return now;
84898 }
84899
84900 -static atomic64_t trace_counter;
84901 +static atomic64_unchecked_t trace_counter;
84902
84903 /*
84904 * trace_clock_counter(): simply an atomic counter.
84905 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
84906 */
84907 u64 notrace trace_clock_counter(void)
84908 {
84909 - return atomic64_add_return(1, &trace_counter);
84910 + return atomic64_inc_return_unchecked(&trace_counter);
84911 }
84912 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
84913 index 29a7ebc..eb473cf 100644
84914 --- a/kernel/trace/trace_events.c
84915 +++ b/kernel/trace/trace_events.c
84916 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
84917 struct ftrace_module_file_ops {
84918 struct list_head list;
84919 struct module *mod;
84920 - struct file_operations id;
84921 - struct file_operations enable;
84922 - struct file_operations format;
84923 - struct file_operations filter;
84924 };
84925
84926 static struct ftrace_module_file_ops *
84927 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
84928
84929 file_ops->mod = mod;
84930
84931 - file_ops->id = ftrace_event_id_fops;
84932 - file_ops->id.owner = mod;
84933 -
84934 - file_ops->enable = ftrace_enable_fops;
84935 - file_ops->enable.owner = mod;
84936 -
84937 - file_ops->filter = ftrace_event_filter_fops;
84938 - file_ops->filter.owner = mod;
84939 -
84940 - file_ops->format = ftrace_event_format_fops;
84941 - file_ops->format.owner = mod;
84942 + pax_open_kernel();
84943 + mod->trace_id.owner = mod;
84944 + mod->trace_enable.owner = mod;
84945 + mod->trace_filter.owner = mod;
84946 + mod->trace_format.owner = mod;
84947 + pax_close_kernel();
84948
84949 list_add(&file_ops->list, &ftrace_module_file_list);
84950
84951 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
84952 struct ftrace_module_file_ops *file_ops)
84953 {
84954 return __trace_add_new_event(call, tr,
84955 - &file_ops->id, &file_ops->enable,
84956 - &file_ops->filter, &file_ops->format);
84957 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
84958 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
84959 }
84960
84961 #else
84962 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
84963 index b3dcfb2..ebee344 100644
84964 --- a/kernel/trace/trace_mmiotrace.c
84965 +++ b/kernel/trace/trace_mmiotrace.c
84966 @@ -24,7 +24,7 @@ struct header_iter {
84967 static struct trace_array *mmio_trace_array;
84968 static bool overrun_detected;
84969 static unsigned long prev_overruns;
84970 -static atomic_t dropped_count;
84971 +static atomic_unchecked_t dropped_count;
84972
84973 static void mmio_reset_data(struct trace_array *tr)
84974 {
84975 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
84976
84977 static unsigned long count_overruns(struct trace_iterator *iter)
84978 {
84979 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
84980 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
84981 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
84982
84983 if (over > prev_overruns)
84984 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
84985 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
84986 sizeof(*entry), 0, pc);
84987 if (!event) {
84988 - atomic_inc(&dropped_count);
84989 + atomic_inc_unchecked(&dropped_count);
84990 return;
84991 }
84992 entry = ring_buffer_event_data(event);
84993 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
84994 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
84995 sizeof(*entry), 0, pc);
84996 if (!event) {
84997 - atomic_inc(&dropped_count);
84998 + atomic_inc_unchecked(&dropped_count);
84999 return;
85000 }
85001 entry = ring_buffer_event_data(event);
85002 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85003 index 34e7cba..6f9a729 100644
85004 --- a/kernel/trace/trace_output.c
85005 +++ b/kernel/trace/trace_output.c
85006 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85007
85008 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85009 if (!IS_ERR(p)) {
85010 - p = mangle_path(s->buffer + s->len, p, "\n");
85011 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85012 if (p) {
85013 s->len = p - s->buffer;
85014 return 1;
85015 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85016 goto out;
85017 }
85018
85019 + pax_open_kernel();
85020 if (event->funcs->trace == NULL)
85021 - event->funcs->trace = trace_nop_print;
85022 + *(void **)&event->funcs->trace = trace_nop_print;
85023 if (event->funcs->raw == NULL)
85024 - event->funcs->raw = trace_nop_print;
85025 + *(void **)&event->funcs->raw = trace_nop_print;
85026 if (event->funcs->hex == NULL)
85027 - event->funcs->hex = trace_nop_print;
85028 + *(void **)&event->funcs->hex = trace_nop_print;
85029 if (event->funcs->binary == NULL)
85030 - event->funcs->binary = trace_nop_print;
85031 + *(void **)&event->funcs->binary = trace_nop_print;
85032 + pax_close_kernel();
85033
85034 key = event->type & (EVENT_HASHSIZE - 1);
85035
85036 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85037 index b20428c..4845a10 100644
85038 --- a/kernel/trace/trace_stack.c
85039 +++ b/kernel/trace/trace_stack.c
85040 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85041 return;
85042
85043 /* we do not handle interrupt stacks yet */
85044 - if (!object_is_on_stack(stack))
85045 + if (!object_starts_on_stack(stack))
85046 return;
85047
85048 local_irq_save(flags);
85049 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85050 index 9064b91..1f5d2f8 100644
85051 --- a/kernel/user_namespace.c
85052 +++ b/kernel/user_namespace.c
85053 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85054 !kgid_has_mapping(parent_ns, group))
85055 return -EPERM;
85056
85057 +#ifdef CONFIG_GRKERNSEC
85058 + /*
85059 + * This doesn't really inspire confidence:
85060 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85061 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85062 + * Increases kernel attack surface in areas developers
85063 + * previously cared little about ("low importance due
85064 + * to requiring "root" capability")
85065 + * To be removed when this code receives *proper* review
85066 + */
85067 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85068 + !capable(CAP_SETGID))
85069 + return -EPERM;
85070 +#endif
85071 +
85072 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85073 if (!ns)
85074 return -ENOMEM;
85075 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85076 if (atomic_read(&current->mm->mm_users) > 1)
85077 return -EINVAL;
85078
85079 - if (current->fs->users != 1)
85080 + if (atomic_read(&current->fs->users) != 1)
85081 return -EINVAL;
85082
85083 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85084 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85085 index 4f69f9a..7c6f8f8 100644
85086 --- a/kernel/utsname_sysctl.c
85087 +++ b/kernel/utsname_sysctl.c
85088 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85089 static int proc_do_uts_string(ctl_table *table, int write,
85090 void __user *buffer, size_t *lenp, loff_t *ppos)
85091 {
85092 - struct ctl_table uts_table;
85093 + ctl_table_no_const uts_table;
85094 int r;
85095 memcpy(&uts_table, table, sizeof(uts_table));
85096 uts_table.data = get_uts(table, write);
85097 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85098 index 1241d8c..d5cfc28 100644
85099 --- a/kernel/watchdog.c
85100 +++ b/kernel/watchdog.c
85101 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85102 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85103 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85104
85105 -static struct smp_hotplug_thread watchdog_threads = {
85106 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85107 .store = &softlockup_watchdog,
85108 .thread_should_run = watchdog_should_run,
85109 .thread_fn = watchdog,
85110 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85111 index e93f7b9..989fcd7 100644
85112 --- a/kernel/workqueue.c
85113 +++ b/kernel/workqueue.c
85114 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85115 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85116 worker_flags |= WORKER_REBOUND;
85117 worker_flags &= ~WORKER_UNBOUND;
85118 - ACCESS_ONCE(worker->flags) = worker_flags;
85119 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85120 }
85121
85122 spin_unlock_irq(&pool->lock);
85123 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85124 index 1501aa5..e771896 100644
85125 --- a/lib/Kconfig.debug
85126 +++ b/lib/Kconfig.debug
85127 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85128
85129 config DEBUG_WW_MUTEX_SLOWPATH
85130 bool "Wait/wound mutex debugging: Slowpath testing"
85131 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85132 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85133 select DEBUG_LOCK_ALLOC
85134 select DEBUG_SPINLOCK
85135 select DEBUG_MUTEXES
85136 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85137
85138 config DEBUG_LOCK_ALLOC
85139 bool "Lock debugging: detect incorrect freeing of live locks"
85140 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85141 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85142 select DEBUG_SPINLOCK
85143 select DEBUG_MUTEXES
85144 select LOCKDEP
85145 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85146
85147 config PROVE_LOCKING
85148 bool "Lock debugging: prove locking correctness"
85149 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85150 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85151 select LOCKDEP
85152 select DEBUG_SPINLOCK
85153 select DEBUG_MUTEXES
85154 @@ -914,7 +914,7 @@ config LOCKDEP
85155
85156 config LOCK_STAT
85157 bool "Lock usage statistics"
85158 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85159 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85160 select LOCKDEP
85161 select DEBUG_SPINLOCK
85162 select DEBUG_MUTEXES
85163 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85164 depends on DEBUG_KERNEL
85165 depends on STACKTRACE_SUPPORT
85166 depends on PROC_FS
85167 + depends on !GRKERNSEC_HIDESYM
85168 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85169 select KALLSYMS
85170 select KALLSYMS_ALL
85171 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85172 config DEBUG_STRICT_USER_COPY_CHECKS
85173 bool "Strict user copy size checks"
85174 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85175 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85176 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85177 help
85178 Enabling this option turns a certain set of sanity checks for user
85179 copy operations into compile time failures.
85180 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85181
85182 config PROVIDE_OHCI1394_DMA_INIT
85183 bool "Remote debugging over FireWire early on boot"
85184 - depends on PCI && X86
85185 + depends on PCI && X86 && !GRKERNSEC
85186 help
85187 If you want to debug problems which hang or crash the kernel early
85188 on boot and the crashing machine has a FireWire port, you can use
85189 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85190
85191 config FIREWIRE_OHCI_REMOTE_DMA
85192 bool "Remote debugging over FireWire with firewire-ohci"
85193 - depends on FIREWIRE_OHCI
85194 + depends on FIREWIRE_OHCI && !GRKERNSEC
85195 help
85196 This option lets you use the FireWire bus for remote debugging
85197 with help of the firewire-ohci driver. It enables unfiltered
85198 diff --git a/lib/Makefile b/lib/Makefile
85199 index 7baccfd..3ceb95f 100644
85200 --- a/lib/Makefile
85201 +++ b/lib/Makefile
85202 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85203
85204 obj-$(CONFIG_BTREE) += btree.o
85205 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85206 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85207 +obj-y += list_debug.o
85208 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85209
85210 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85211 diff --git a/lib/bitmap.c b/lib/bitmap.c
85212 index 06f7e4f..f3cf2b0 100644
85213 --- a/lib/bitmap.c
85214 +++ b/lib/bitmap.c
85215 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85216 {
85217 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85218 u32 chunk;
85219 - const char __user __force *ubuf = (const char __user __force *)buf;
85220 + const char __user *ubuf = (const char __force_user *)buf;
85221
85222 bitmap_zero(maskp, nmaskbits);
85223
85224 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85225 {
85226 if (!access_ok(VERIFY_READ, ubuf, ulen))
85227 return -EFAULT;
85228 - return __bitmap_parse((const char __force *)ubuf,
85229 + return __bitmap_parse((const char __force_kernel *)ubuf,
85230 ulen, 1, maskp, nmaskbits);
85231
85232 }
85233 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85234 {
85235 unsigned a, b;
85236 int c, old_c, totaldigits;
85237 - const char __user __force *ubuf = (const char __user __force *)buf;
85238 + const char __user *ubuf = (const char __force_user *)buf;
85239 int exp_digit, in_range;
85240
85241 totaldigits = c = 0;
85242 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85243 {
85244 if (!access_ok(VERIFY_READ, ubuf, ulen))
85245 return -EFAULT;
85246 - return __bitmap_parselist((const char __force *)ubuf,
85247 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85248 ulen, 1, maskp, nmaskbits);
85249 }
85250 EXPORT_SYMBOL(bitmap_parselist_user);
85251 diff --git a/lib/bug.c b/lib/bug.c
85252 index 1686034..a9c00c8 100644
85253 --- a/lib/bug.c
85254 +++ b/lib/bug.c
85255 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85256 return BUG_TRAP_TYPE_NONE;
85257
85258 bug = find_bug(bugaddr);
85259 + if (!bug)
85260 + return BUG_TRAP_TYPE_NONE;
85261
85262 file = NULL;
85263 line = 0;
85264 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85265 index 37061ed..da83f48 100644
85266 --- a/lib/debugobjects.c
85267 +++ b/lib/debugobjects.c
85268 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85269 if (limit > 4)
85270 return;
85271
85272 - is_on_stack = object_is_on_stack(addr);
85273 + is_on_stack = object_starts_on_stack(addr);
85274 if (is_on_stack == onstack)
85275 return;
85276
85277 diff --git a/lib/devres.c b/lib/devres.c
85278 index 8235331..5881053 100644
85279 --- a/lib/devres.c
85280 +++ b/lib/devres.c
85281 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85282 void devm_iounmap(struct device *dev, void __iomem *addr)
85283 {
85284 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85285 - (void *)addr));
85286 + (void __force *)addr));
85287 iounmap(addr);
85288 }
85289 EXPORT_SYMBOL(devm_iounmap);
85290 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85291 {
85292 ioport_unmap(addr);
85293 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85294 - devm_ioport_map_match, (void *)addr));
85295 + devm_ioport_map_match, (void __force *)addr));
85296 }
85297 EXPORT_SYMBOL(devm_ioport_unmap);
85298 #endif /* CONFIG_HAS_IOPORT */
85299 diff --git a/lib/div64.c b/lib/div64.c
85300 index a163b6c..9618fa5 100644
85301 --- a/lib/div64.c
85302 +++ b/lib/div64.c
85303 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85304 EXPORT_SYMBOL(__div64_32);
85305
85306 #ifndef div_s64_rem
85307 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85308 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85309 {
85310 u64 quotient;
85311
85312 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85313 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85314 */
85315 #ifndef div64_u64
85316 -u64 div64_u64(u64 dividend, u64 divisor)
85317 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85318 {
85319 u32 high = divisor >> 32;
85320 u64 quot;
85321 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85322 index d87a17a..ac0d79a 100644
85323 --- a/lib/dma-debug.c
85324 +++ b/lib/dma-debug.c
85325 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85326
85327 void dma_debug_add_bus(struct bus_type *bus)
85328 {
85329 - struct notifier_block *nb;
85330 + notifier_block_no_const *nb;
85331
85332 if (global_disable)
85333 return;
85334 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85335
85336 static void check_for_stack(struct device *dev, void *addr)
85337 {
85338 - if (object_is_on_stack(addr))
85339 + if (object_starts_on_stack(addr))
85340 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85341 "stack [addr=%p]\n", addr);
85342 }
85343 diff --git a/lib/inflate.c b/lib/inflate.c
85344 index 013a761..c28f3fc 100644
85345 --- a/lib/inflate.c
85346 +++ b/lib/inflate.c
85347 @@ -269,7 +269,7 @@ static void free(void *where)
85348 malloc_ptr = free_mem_ptr;
85349 }
85350 #else
85351 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85352 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85353 #define free(a) kfree(a)
85354 #endif
85355
85356 diff --git a/lib/ioremap.c b/lib/ioremap.c
85357 index 0c9216c..863bd89 100644
85358 --- a/lib/ioremap.c
85359 +++ b/lib/ioremap.c
85360 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85361 unsigned long next;
85362
85363 phys_addr -= addr;
85364 - pmd = pmd_alloc(&init_mm, pud, addr);
85365 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85366 if (!pmd)
85367 return -ENOMEM;
85368 do {
85369 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85370 unsigned long next;
85371
85372 phys_addr -= addr;
85373 - pud = pud_alloc(&init_mm, pgd, addr);
85374 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85375 if (!pud)
85376 return -ENOMEM;
85377 do {
85378 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85379 index bd2bea9..6b3c95e 100644
85380 --- a/lib/is_single_threaded.c
85381 +++ b/lib/is_single_threaded.c
85382 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85383 struct task_struct *p, *t;
85384 bool ret;
85385
85386 + if (!mm)
85387 + return true;
85388 +
85389 if (atomic_read(&task->signal->live) != 1)
85390 return false;
85391
85392 diff --git a/lib/kobject.c b/lib/kobject.c
85393 index 4a1f33d..2f3ca75 100644
85394 --- a/lib/kobject.c
85395 +++ b/lib/kobject.c
85396 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85397
85398
85399 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85400 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85401 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85402
85403 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85404 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85405 {
85406 enum kobj_ns_type type = ops->type;
85407 int error;
85408 diff --git a/lib/list_debug.c b/lib/list_debug.c
85409 index c24c2f7..06e070b 100644
85410 --- a/lib/list_debug.c
85411 +++ b/lib/list_debug.c
85412 @@ -11,7 +11,9 @@
85413 #include <linux/bug.h>
85414 #include <linux/kernel.h>
85415 #include <linux/rculist.h>
85416 +#include <linux/mm.h>
85417
85418 +#ifdef CONFIG_DEBUG_LIST
85419 /*
85420 * Insert a new entry between two known consecutive entries.
85421 *
85422 @@ -19,21 +21,32 @@
85423 * the prev/next entries already!
85424 */
85425
85426 -void __list_add(struct list_head *new,
85427 - struct list_head *prev,
85428 - struct list_head *next)
85429 +static bool __list_add_debug(struct list_head *new,
85430 + struct list_head *prev,
85431 + struct list_head *next)
85432 {
85433 - WARN(next->prev != prev,
85434 + if (WARN(next->prev != prev,
85435 "list_add corruption. next->prev should be "
85436 "prev (%p), but was %p. (next=%p).\n",
85437 - prev, next->prev, next);
85438 - WARN(prev->next != next,
85439 + prev, next->prev, next) ||
85440 + WARN(prev->next != next,
85441 "list_add corruption. prev->next should be "
85442 "next (%p), but was %p. (prev=%p).\n",
85443 - next, prev->next, prev);
85444 - WARN(new == prev || new == next,
85445 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85446 - new, prev, next);
85447 + next, prev->next, prev) ||
85448 + WARN(new == prev || new == next,
85449 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85450 + new, prev, next))
85451 + return false;
85452 + return true;
85453 +}
85454 +
85455 +void __list_add(struct list_head *new,
85456 + struct list_head *prev,
85457 + struct list_head *next)
85458 +{
85459 + if (!__list_add_debug(new, prev, next))
85460 + return;
85461 +
85462 next->prev = new;
85463 new->next = next;
85464 new->prev = prev;
85465 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85466 }
85467 EXPORT_SYMBOL(__list_add);
85468
85469 -void __list_del_entry(struct list_head *entry)
85470 +static bool __list_del_entry_debug(struct list_head *entry)
85471 {
85472 struct list_head *prev, *next;
85473
85474 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85475 WARN(next->prev != entry,
85476 "list_del corruption. next->prev should be %p, "
85477 "but was %p\n", entry, next->prev))
85478 + return false;
85479 + return true;
85480 +}
85481 +
85482 +void __list_del_entry(struct list_head *entry)
85483 +{
85484 + if (!__list_del_entry_debug(entry))
85485 return;
85486
85487 - __list_del(prev, next);
85488 + __list_del(entry->prev, entry->next);
85489 }
85490 EXPORT_SYMBOL(__list_del_entry);
85491
85492 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85493 void __list_add_rcu(struct list_head *new,
85494 struct list_head *prev, struct list_head *next)
85495 {
85496 - WARN(next->prev != prev,
85497 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85498 - prev, next->prev, next);
85499 - WARN(prev->next != next,
85500 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85501 - next, prev->next, prev);
85502 + if (!__list_add_debug(new, prev, next))
85503 + return;
85504 +
85505 new->next = next;
85506 new->prev = prev;
85507 rcu_assign_pointer(list_next_rcu(prev), new);
85508 next->prev = new;
85509 }
85510 EXPORT_SYMBOL(__list_add_rcu);
85511 +#endif
85512 +
85513 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85514 +{
85515 +#ifdef CONFIG_DEBUG_LIST
85516 + if (!__list_add_debug(new, prev, next))
85517 + return;
85518 +#endif
85519 +
85520 + pax_open_kernel();
85521 + next->prev = new;
85522 + new->next = next;
85523 + new->prev = prev;
85524 + prev->next = new;
85525 + pax_close_kernel();
85526 +}
85527 +EXPORT_SYMBOL(__pax_list_add);
85528 +
85529 +void pax_list_del(struct list_head *entry)
85530 +{
85531 +#ifdef CONFIG_DEBUG_LIST
85532 + if (!__list_del_entry_debug(entry))
85533 + return;
85534 +#endif
85535 +
85536 + pax_open_kernel();
85537 + __list_del(entry->prev, entry->next);
85538 + entry->next = LIST_POISON1;
85539 + entry->prev = LIST_POISON2;
85540 + pax_close_kernel();
85541 +}
85542 +EXPORT_SYMBOL(pax_list_del);
85543 +
85544 +void pax_list_del_init(struct list_head *entry)
85545 +{
85546 + pax_open_kernel();
85547 + __list_del(entry->prev, entry->next);
85548 + INIT_LIST_HEAD(entry);
85549 + pax_close_kernel();
85550 +}
85551 +EXPORT_SYMBOL(pax_list_del_init);
85552 +
85553 +void __pax_list_add_rcu(struct list_head *new,
85554 + struct list_head *prev, struct list_head *next)
85555 +{
85556 +#ifdef CONFIG_DEBUG_LIST
85557 + if (!__list_add_debug(new, prev, next))
85558 + return;
85559 +#endif
85560 +
85561 + pax_open_kernel();
85562 + new->next = next;
85563 + new->prev = prev;
85564 + rcu_assign_pointer(list_next_rcu(prev), new);
85565 + next->prev = new;
85566 + pax_close_kernel();
85567 +}
85568 +EXPORT_SYMBOL(__pax_list_add_rcu);
85569 +
85570 +void pax_list_del_rcu(struct list_head *entry)
85571 +{
85572 +#ifdef CONFIG_DEBUG_LIST
85573 + if (!__list_del_entry_debug(entry))
85574 + return;
85575 +#endif
85576 +
85577 + pax_open_kernel();
85578 + __list_del(entry->prev, entry->next);
85579 + entry->next = LIST_POISON1;
85580 + entry->prev = LIST_POISON2;
85581 + pax_close_kernel();
85582 +}
85583 +EXPORT_SYMBOL(pax_list_del_rcu);
85584 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85585 index 7deeb62..144eb47 100644
85586 --- a/lib/percpu-refcount.c
85587 +++ b/lib/percpu-refcount.c
85588 @@ -29,7 +29,7 @@
85589 * can't hit 0 before we've added up all the percpu refs.
85590 */
85591
85592 -#define PCPU_COUNT_BIAS (1U << 31)
85593 +#define PCPU_COUNT_BIAS (1U << 30)
85594
85595 /**
85596 * percpu_ref_init - initialize a percpu refcount
85597 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85598 index e796429..6e38f9f 100644
85599 --- a/lib/radix-tree.c
85600 +++ b/lib/radix-tree.c
85601 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85602 int nr;
85603 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85604 };
85605 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85606 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85607
85608 static inline void *ptr_to_indirect(void *ptr)
85609 {
85610 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85611 index bb2b201..46abaf9 100644
85612 --- a/lib/strncpy_from_user.c
85613 +++ b/lib/strncpy_from_user.c
85614 @@ -21,7 +21,7 @@
85615 */
85616 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85617 {
85618 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85619 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85620 long res = 0;
85621
85622 /*
85623 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85624 index a28df52..3d55877 100644
85625 --- a/lib/strnlen_user.c
85626 +++ b/lib/strnlen_user.c
85627 @@ -26,7 +26,7 @@
85628 */
85629 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85630 {
85631 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85632 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85633 long align, res = 0;
85634 unsigned long c;
85635
85636 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85637 index d23762e..e21eab2 100644
85638 --- a/lib/swiotlb.c
85639 +++ b/lib/swiotlb.c
85640 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85641
85642 void
85643 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85644 - dma_addr_t dev_addr)
85645 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85646 {
85647 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85648
85649 diff --git a/lib/usercopy.c b/lib/usercopy.c
85650 index 4f5b1dd..7cab418 100644
85651 --- a/lib/usercopy.c
85652 +++ b/lib/usercopy.c
85653 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85654 WARN(1, "Buffer overflow detected!\n");
85655 }
85656 EXPORT_SYMBOL(copy_from_user_overflow);
85657 +
85658 +void copy_to_user_overflow(void)
85659 +{
85660 + WARN(1, "Buffer overflow detected!\n");
85661 +}
85662 +EXPORT_SYMBOL(copy_to_user_overflow);
85663 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85664 index 739a363..aa668d7 100644
85665 --- a/lib/vsprintf.c
85666 +++ b/lib/vsprintf.c
85667 @@ -16,6 +16,9 @@
85668 * - scnprintf and vscnprintf
85669 */
85670
85671 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85672 +#define __INCLUDED_BY_HIDESYM 1
85673 +#endif
85674 #include <stdarg.h>
85675 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85676 #include <linux/types.h>
85677 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85678 return number(buf, end, *(const netdev_features_t *)addr, spec);
85679 }
85680
85681 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85682 +int kptr_restrict __read_mostly = 2;
85683 +#else
85684 int kptr_restrict __read_mostly;
85685 +#endif
85686
85687 /*
85688 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85689 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85690 * - 'f' For simple symbolic function names without offset
85691 * - 'S' For symbolic direct pointers with offset
85692 * - 's' For symbolic direct pointers without offset
85693 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85694 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85695 * - 'B' For backtraced symbolic direct pointers with offset
85696 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85697 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85698
85699 if (!ptr && *fmt != 'K') {
85700 /*
85701 - * Print (null) with the same width as a pointer so it makes
85702 + * Print (nil) with the same width as a pointer so it makes
85703 * tabular output look nice.
85704 */
85705 if (spec.field_width == -1)
85706 spec.field_width = default_width;
85707 - return string(buf, end, "(null)", spec);
85708 + return string(buf, end, "(nil)", spec);
85709 }
85710
85711 switch (*fmt) {
85712 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85713 /* Fallthrough */
85714 case 'S':
85715 case 's':
85716 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85717 + break;
85718 +#else
85719 + return symbol_string(buf, end, ptr, spec, fmt);
85720 +#endif
85721 + case 'A':
85722 case 'B':
85723 return symbol_string(buf, end, ptr, spec, fmt);
85724 case 'R':
85725 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85726 va_end(va);
85727 return buf;
85728 }
85729 + case 'P':
85730 + break;
85731 case 'K':
85732 /*
85733 * %pK cannot be used in IRQ context because its test
85734 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85735 return number(buf, end,
85736 (unsigned long long) *((phys_addr_t *)ptr), spec);
85737 }
85738 +
85739 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85740 + /* 'P' = approved pointers to copy to userland,
85741 + as in the /proc/kallsyms case, as we make it display nothing
85742 + for non-root users, and the real contents for root users
85743 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85744 + above
85745 + */
85746 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85747 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85748 + dump_stack();
85749 + ptr = NULL;
85750 + }
85751 +#endif
85752 +
85753 spec.flags |= SMALL;
85754 if (spec.field_width == -1) {
85755 spec.field_width = default_width;
85756 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85757 typeof(type) value; \
85758 if (sizeof(type) == 8) { \
85759 args = PTR_ALIGN(args, sizeof(u32)); \
85760 - *(u32 *)&value = *(u32 *)args; \
85761 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85762 + *(u32 *)&value = *(const u32 *)args; \
85763 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85764 } else { \
85765 args = PTR_ALIGN(args, sizeof(type)); \
85766 - value = *(typeof(type) *)args; \
85767 + value = *(const typeof(type) *)args; \
85768 } \
85769 args += sizeof(type); \
85770 value; \
85771 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85772 case FORMAT_TYPE_STR: {
85773 const char *str_arg = args;
85774 args += strlen(str_arg) + 1;
85775 - str = string(str, end, (char *)str_arg, spec);
85776 + str = string(str, end, str_arg, spec);
85777 break;
85778 }
85779
85780 diff --git a/localversion-grsec b/localversion-grsec
85781 new file mode 100644
85782 index 0000000..7cd6065
85783 --- /dev/null
85784 +++ b/localversion-grsec
85785 @@ -0,0 +1 @@
85786 +-grsec
85787 diff --git a/mm/Kconfig b/mm/Kconfig
85788 index 8028dcc..9a2dbe7 100644
85789 --- a/mm/Kconfig
85790 +++ b/mm/Kconfig
85791 @@ -317,10 +317,10 @@ config KSM
85792 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85793
85794 config DEFAULT_MMAP_MIN_ADDR
85795 - int "Low address space to protect from user allocation"
85796 + int "Low address space to protect from user allocation"
85797 depends on MMU
85798 - default 4096
85799 - help
85800 + default 65536
85801 + help
85802 This is the portion of low virtual memory which should be protected
85803 from userspace allocation. Keeping a user from writing to low pages
85804 can help reduce the impact of kernel NULL pointer bugs.
85805 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
85806
85807 config HWPOISON_INJECT
85808 tristate "HWPoison pages injector"
85809 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85810 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85811 select PROC_PAGE_MONITOR
85812
85813 config NOMMU_INITIAL_TRIM_EXCESS
85814 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85815 index e04454c..ca5be3e 100644
85816 --- a/mm/backing-dev.c
85817 +++ b/mm/backing-dev.c
85818 @@ -12,7 +12,7 @@
85819 #include <linux/device.h>
85820 #include <trace/events/writeback.h>
85821
85822 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85823 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85824
85825 struct backing_dev_info default_backing_dev_info = {
85826 .name = "default",
85827 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85828 return err;
85829
85830 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85831 - atomic_long_inc_return(&bdi_seq));
85832 + atomic_long_inc_return_unchecked(&bdi_seq));
85833 if (err) {
85834 bdi_destroy(bdi);
85835 return err;
85836 diff --git a/mm/filemap.c b/mm/filemap.c
85837 index 4b51ac1..5aa90ff 100644
85838 --- a/mm/filemap.c
85839 +++ b/mm/filemap.c
85840 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85841 struct address_space *mapping = file->f_mapping;
85842
85843 if (!mapping->a_ops->readpage)
85844 - return -ENOEXEC;
85845 + return -ENODEV;
85846 file_accessed(file);
85847 vma->vm_ops = &generic_file_vm_ops;
85848 return 0;
85849 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85850
85851 while (bytes) {
85852 char __user *buf = iov->iov_base + base;
85853 - int copy = min(bytes, iov->iov_len - base);
85854 + size_t copy = min(bytes, iov->iov_len - base);
85855
85856 base = 0;
85857 left = __copy_from_user_inatomic(vaddr, buf, copy);
85858 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85859 BUG_ON(!in_atomic());
85860 kaddr = kmap_atomic(page);
85861 if (likely(i->nr_segs == 1)) {
85862 - int left;
85863 + size_t left;
85864 char __user *buf = i->iov->iov_base + i->iov_offset;
85865 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85866 copied = bytes - left;
85867 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85868
85869 kaddr = kmap(page);
85870 if (likely(i->nr_segs == 1)) {
85871 - int left;
85872 + size_t left;
85873 char __user *buf = i->iov->iov_base + i->iov_offset;
85874 left = __copy_from_user(kaddr + offset, buf, bytes);
85875 copied = bytes - left;
85876 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
85877 * zero-length segments (without overruning the iovec).
85878 */
85879 while (bytes || unlikely(i->count && !iov->iov_len)) {
85880 - int copy;
85881 + size_t copy;
85882
85883 copy = min(bytes, iov->iov_len - base);
85884 BUG_ON(!i->count || i->count < copy);
85885 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
85886 *pos = i_size_read(inode);
85887
85888 if (limit != RLIM_INFINITY) {
85889 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
85890 if (*pos >= limit) {
85891 send_sig(SIGXFSZ, current, 0);
85892 return -EFBIG;
85893 diff --git a/mm/fremap.c b/mm/fremap.c
85894 index 5bff081..d8189a9 100644
85895 --- a/mm/fremap.c
85896 +++ b/mm/fremap.c
85897 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
85898 retry:
85899 vma = find_vma(mm, start);
85900
85901 +#ifdef CONFIG_PAX_SEGMEXEC
85902 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
85903 + goto out;
85904 +#endif
85905 +
85906 /*
85907 * Make sure the vma is shared, that it supports prefaulting,
85908 * and that the remapped range is valid and fully within
85909 diff --git a/mm/highmem.c b/mm/highmem.c
85910 index b32b70c..e512eb0 100644
85911 --- a/mm/highmem.c
85912 +++ b/mm/highmem.c
85913 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
85914 * So no dangers, even with speculative execution.
85915 */
85916 page = pte_page(pkmap_page_table[i]);
85917 + pax_open_kernel();
85918 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
85919 -
85920 + pax_close_kernel();
85921 set_page_address(page, NULL);
85922 need_flush = 1;
85923 }
85924 @@ -198,9 +199,11 @@ start:
85925 }
85926 }
85927 vaddr = PKMAP_ADDR(last_pkmap_nr);
85928 +
85929 + pax_open_kernel();
85930 set_pte_at(&init_mm, vaddr,
85931 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
85932 -
85933 + pax_close_kernel();
85934 pkmap_count[last_pkmap_nr] = 1;
85935 set_page_address(page, (void *)vaddr);
85936
85937 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
85938 index b60f330..ee7de7e 100644
85939 --- a/mm/hugetlb.c
85940 +++ b/mm/hugetlb.c
85941 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
85942 struct hstate *h = &default_hstate;
85943 unsigned long tmp;
85944 int ret;
85945 + ctl_table_no_const hugetlb_table;
85946
85947 tmp = h->max_huge_pages;
85948
85949 if (write && h->order >= MAX_ORDER)
85950 return -EINVAL;
85951
85952 - table->data = &tmp;
85953 - table->maxlen = sizeof(unsigned long);
85954 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85955 + hugetlb_table = *table;
85956 + hugetlb_table.data = &tmp;
85957 + hugetlb_table.maxlen = sizeof(unsigned long);
85958 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85959 if (ret)
85960 goto out;
85961
85962 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
85963 struct hstate *h = &default_hstate;
85964 unsigned long tmp;
85965 int ret;
85966 + ctl_table_no_const hugetlb_table;
85967
85968 tmp = h->nr_overcommit_huge_pages;
85969
85970 if (write && h->order >= MAX_ORDER)
85971 return -EINVAL;
85972
85973 - table->data = &tmp;
85974 - table->maxlen = sizeof(unsigned long);
85975 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85976 + hugetlb_table = *table;
85977 + hugetlb_table.data = &tmp;
85978 + hugetlb_table.maxlen = sizeof(unsigned long);
85979 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85980 if (ret)
85981 goto out;
85982
85983 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
85984 return 1;
85985 }
85986
85987 +#ifdef CONFIG_PAX_SEGMEXEC
85988 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
85989 +{
85990 + struct mm_struct *mm = vma->vm_mm;
85991 + struct vm_area_struct *vma_m;
85992 + unsigned long address_m;
85993 + pte_t *ptep_m;
85994 +
85995 + vma_m = pax_find_mirror_vma(vma);
85996 + if (!vma_m)
85997 + return;
85998 +
85999 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86000 + address_m = address + SEGMEXEC_TASK_SIZE;
86001 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86002 + get_page(page_m);
86003 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86004 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86005 +}
86006 +#endif
86007 +
86008 /*
86009 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86010 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86011 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86012 make_huge_pte(vma, new_page, 1));
86013 page_remove_rmap(old_page);
86014 hugepage_add_new_anon_rmap(new_page, vma, address);
86015 +
86016 +#ifdef CONFIG_PAX_SEGMEXEC
86017 + pax_mirror_huge_pte(vma, address, new_page);
86018 +#endif
86019 +
86020 /* Make the old page be freed below */
86021 new_page = old_page;
86022 }
86023 @@ -2821,6 +2851,10 @@ retry:
86024 && (vma->vm_flags & VM_SHARED)));
86025 set_huge_pte_at(mm, address, ptep, new_pte);
86026
86027 +#ifdef CONFIG_PAX_SEGMEXEC
86028 + pax_mirror_huge_pte(vma, address, page);
86029 +#endif
86030 +
86031 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86032 /* Optimization, do the COW without a second fault */
86033 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86034 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86035 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86036 struct hstate *h = hstate_vma(vma);
86037
86038 +#ifdef CONFIG_PAX_SEGMEXEC
86039 + struct vm_area_struct *vma_m;
86040 +#endif
86041 +
86042 address &= huge_page_mask(h);
86043
86044 ptep = huge_pte_offset(mm, address);
86045 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86046 VM_FAULT_SET_HINDEX(hstate_index(h));
86047 }
86048
86049 +#ifdef CONFIG_PAX_SEGMEXEC
86050 + vma_m = pax_find_mirror_vma(vma);
86051 + if (vma_m) {
86052 + unsigned long address_m;
86053 +
86054 + if (vma->vm_start > vma_m->vm_start) {
86055 + address_m = address;
86056 + address -= SEGMEXEC_TASK_SIZE;
86057 + vma = vma_m;
86058 + h = hstate_vma(vma);
86059 + } else
86060 + address_m = address + SEGMEXEC_TASK_SIZE;
86061 +
86062 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86063 + return VM_FAULT_OOM;
86064 + address_m &= HPAGE_MASK;
86065 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86066 + }
86067 +#endif
86068 +
86069 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86070 if (!ptep)
86071 return VM_FAULT_OOM;
86072 diff --git a/mm/internal.h b/mm/internal.h
86073 index 4390ac6..fc60373c 100644
86074 --- a/mm/internal.h
86075 +++ b/mm/internal.h
86076 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86077 * in mm/page_alloc.c
86078 */
86079 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86080 +extern void free_compound_page(struct page *page);
86081 extern void prep_compound_page(struct page *page, unsigned long order);
86082 #ifdef CONFIG_MEMORY_FAILURE
86083 extern bool is_free_buddy_page(struct page *page);
86084 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86085
86086 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86087 unsigned long, unsigned long,
86088 - unsigned long, unsigned long);
86089 + unsigned long, unsigned long) __intentional_overflow(-1);
86090
86091 extern void set_pageblock_order(void);
86092 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86093 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86094 index c8d7f31..2dbeffd 100644
86095 --- a/mm/kmemleak.c
86096 +++ b/mm/kmemleak.c
86097 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86098
86099 for (i = 0; i < object->trace_len; i++) {
86100 void *ptr = (void *)object->trace[i];
86101 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86102 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86103 }
86104 }
86105
86106 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86107 return -ENOMEM;
86108 }
86109
86110 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86111 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86112 &kmemleak_fops);
86113 if (!dentry)
86114 pr_warning("Failed to create the debugfs kmemleak file\n");
86115 diff --git a/mm/maccess.c b/mm/maccess.c
86116 index d53adf9..03a24bf 100644
86117 --- a/mm/maccess.c
86118 +++ b/mm/maccess.c
86119 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86120 set_fs(KERNEL_DS);
86121 pagefault_disable();
86122 ret = __copy_from_user_inatomic(dst,
86123 - (__force const void __user *)src, size);
86124 + (const void __force_user *)src, size);
86125 pagefault_enable();
86126 set_fs(old_fs);
86127
86128 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86129
86130 set_fs(KERNEL_DS);
86131 pagefault_disable();
86132 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86133 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86134 pagefault_enable();
86135 set_fs(old_fs);
86136
86137 diff --git a/mm/madvise.c b/mm/madvise.c
86138 index 7055883..aafb1ed 100644
86139 --- a/mm/madvise.c
86140 +++ b/mm/madvise.c
86141 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86142 pgoff_t pgoff;
86143 unsigned long new_flags = vma->vm_flags;
86144
86145 +#ifdef CONFIG_PAX_SEGMEXEC
86146 + struct vm_area_struct *vma_m;
86147 +#endif
86148 +
86149 switch (behavior) {
86150 case MADV_NORMAL:
86151 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86152 @@ -126,6 +130,13 @@ success:
86153 /*
86154 * vm_flags is protected by the mmap_sem held in write mode.
86155 */
86156 +
86157 +#ifdef CONFIG_PAX_SEGMEXEC
86158 + vma_m = pax_find_mirror_vma(vma);
86159 + if (vma_m)
86160 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86161 +#endif
86162 +
86163 vma->vm_flags = new_flags;
86164
86165 out:
86166 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86167 struct vm_area_struct ** prev,
86168 unsigned long start, unsigned long end)
86169 {
86170 +
86171 +#ifdef CONFIG_PAX_SEGMEXEC
86172 + struct vm_area_struct *vma_m;
86173 +#endif
86174 +
86175 *prev = vma;
86176 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86177 return -EINVAL;
86178 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86179 zap_page_range(vma, start, end - start, &details);
86180 } else
86181 zap_page_range(vma, start, end - start, NULL);
86182 +
86183 +#ifdef CONFIG_PAX_SEGMEXEC
86184 + vma_m = pax_find_mirror_vma(vma);
86185 + if (vma_m) {
86186 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86187 + struct zap_details details = {
86188 + .nonlinear_vma = vma_m,
86189 + .last_index = ULONG_MAX,
86190 + };
86191 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86192 + } else
86193 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86194 + }
86195 +#endif
86196 +
86197 return 0;
86198 }
86199
86200 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86201 if (end < start)
86202 return error;
86203
86204 +#ifdef CONFIG_PAX_SEGMEXEC
86205 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86206 + if (end > SEGMEXEC_TASK_SIZE)
86207 + return error;
86208 + } else
86209 +#endif
86210 +
86211 + if (end > TASK_SIZE)
86212 + return error;
86213 +
86214 error = 0;
86215 if (end == start)
86216 return error;
86217 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86218 index 2c13aa7..64cbc3f 100644
86219 --- a/mm/memory-failure.c
86220 +++ b/mm/memory-failure.c
86221 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86222
86223 int sysctl_memory_failure_recovery __read_mostly = 1;
86224
86225 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86226 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86227
86228 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86229
86230 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86231 pfn, t->comm, t->pid);
86232 si.si_signo = SIGBUS;
86233 si.si_errno = 0;
86234 - si.si_addr = (void *)addr;
86235 + si.si_addr = (void __user *)addr;
86236 #ifdef __ARCH_SI_TRAPNO
86237 si.si_trapno = trapno;
86238 #endif
86239 @@ -760,7 +760,7 @@ static struct page_state {
86240 unsigned long res;
86241 char *msg;
86242 int (*action)(struct page *p, unsigned long pfn);
86243 -} error_states[] = {
86244 +} __do_const error_states[] = {
86245 { reserved, reserved, "reserved kernel", me_kernel },
86246 /*
86247 * free pages are specially detected outside this table:
86248 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86249 nr_pages = 1 << compound_order(hpage);
86250 else /* normal page or thp */
86251 nr_pages = 1;
86252 - atomic_long_add(nr_pages, &num_poisoned_pages);
86253 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86254
86255 /*
86256 * We need/can do nothing about count=0 pages.
86257 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86258 if (!PageHWPoison(hpage)
86259 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86260 || (p != hpage && TestSetPageHWPoison(hpage))) {
86261 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86262 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86263 return 0;
86264 }
86265 set_page_hwpoison_huge_page(hpage);
86266 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86267 }
86268 if (hwpoison_filter(p)) {
86269 if (TestClearPageHWPoison(p))
86270 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86271 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86272 unlock_page(hpage);
86273 put_page(hpage);
86274 return 0;
86275 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86276 return 0;
86277 }
86278 if (TestClearPageHWPoison(p))
86279 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86280 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86281 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86282 return 0;
86283 }
86284 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86285 */
86286 if (TestClearPageHWPoison(page)) {
86287 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86288 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86289 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86290 freeit = 1;
86291 if (PageHuge(page))
86292 clear_page_hwpoison_huge_page(page);
86293 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86294 } else {
86295 set_page_hwpoison_huge_page(hpage);
86296 dequeue_hwpoisoned_huge_page(hpage);
86297 - atomic_long_add(1 << compound_trans_order(hpage),
86298 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86299 &num_poisoned_pages);
86300 }
86301 return ret;
86302 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86303 if (PageHuge(page)) {
86304 set_page_hwpoison_huge_page(hpage);
86305 dequeue_hwpoisoned_huge_page(hpage);
86306 - atomic_long_add(1 << compound_trans_order(hpage),
86307 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86308 &num_poisoned_pages);
86309 } else {
86310 SetPageHWPoison(page);
86311 - atomic_long_inc(&num_poisoned_pages);
86312 + atomic_long_inc_unchecked(&num_poisoned_pages);
86313 }
86314 }
86315 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86316 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86317 put_page(page);
86318 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86319 SetPageHWPoison(page);
86320 - atomic_long_inc(&num_poisoned_pages);
86321 + atomic_long_inc_unchecked(&num_poisoned_pages);
86322 return 0;
86323 }
86324
86325 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86326 if (!is_free_buddy_page(page))
86327 pr_info("soft offline: %#lx: page leaked\n",
86328 pfn);
86329 - atomic_long_inc(&num_poisoned_pages);
86330 + atomic_long_inc_unchecked(&num_poisoned_pages);
86331 }
86332 } else {
86333 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86334 diff --git a/mm/memory.c b/mm/memory.c
86335 index af84bc0..2ed0816 100644
86336 --- a/mm/memory.c
86337 +++ b/mm/memory.c
86338 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86339 free_pte_range(tlb, pmd, addr);
86340 } while (pmd++, addr = next, addr != end);
86341
86342 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86343 start &= PUD_MASK;
86344 if (start < floor)
86345 return;
86346 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86347 pmd = pmd_offset(pud, start);
86348 pud_clear(pud);
86349 pmd_free_tlb(tlb, pmd, start);
86350 +#endif
86351 +
86352 }
86353
86354 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86355 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86356 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86357 } while (pud++, addr = next, addr != end);
86358
86359 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86360 start &= PGDIR_MASK;
86361 if (start < floor)
86362 return;
86363 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86364 pud = pud_offset(pgd, start);
86365 pgd_clear(pgd);
86366 pud_free_tlb(tlb, pud, start);
86367 +#endif
86368 +
86369 }
86370
86371 /*
86372 @@ -1645,12 +1651,6 @@ no_page_table:
86373 return page;
86374 }
86375
86376 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86377 -{
86378 - return stack_guard_page_start(vma, addr) ||
86379 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86380 -}
86381 -
86382 /**
86383 * __get_user_pages() - pin user pages in memory
86384 * @tsk: task_struct of target task
86385 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86386
86387 i = 0;
86388
86389 - do {
86390 + while (nr_pages) {
86391 struct vm_area_struct *vma;
86392
86393 - vma = find_extend_vma(mm, start);
86394 + vma = find_vma(mm, start);
86395 if (!vma && in_gate_area(mm, start)) {
86396 unsigned long pg = start & PAGE_MASK;
86397 pgd_t *pgd;
86398 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86399 goto next_page;
86400 }
86401
86402 - if (!vma ||
86403 + if (!vma || start < vma->vm_start ||
86404 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86405 !(vm_flags & vma->vm_flags))
86406 return i ? : -EFAULT;
86407 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86408 int ret;
86409 unsigned int fault_flags = 0;
86410
86411 - /* For mlock, just skip the stack guard page. */
86412 - if (foll_flags & FOLL_MLOCK) {
86413 - if (stack_guard_page(vma, start))
86414 - goto next_page;
86415 - }
86416 if (foll_flags & FOLL_WRITE)
86417 fault_flags |= FAULT_FLAG_WRITE;
86418 if (nonblocking)
86419 @@ -1902,7 +1897,7 @@ next_page:
86420 start += page_increm * PAGE_SIZE;
86421 nr_pages -= page_increm;
86422 } while (nr_pages && start < vma->vm_end);
86423 - } while (nr_pages);
86424 + }
86425 return i;
86426 }
86427 EXPORT_SYMBOL(__get_user_pages);
86428 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86429 page_add_file_rmap(page);
86430 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86431
86432 +#ifdef CONFIG_PAX_SEGMEXEC
86433 + pax_mirror_file_pte(vma, addr, page, ptl);
86434 +#endif
86435 +
86436 retval = 0;
86437 pte_unmap_unlock(pte, ptl);
86438 return retval;
86439 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86440 if (!page_count(page))
86441 return -EINVAL;
86442 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86443 +
86444 +#ifdef CONFIG_PAX_SEGMEXEC
86445 + struct vm_area_struct *vma_m;
86446 +#endif
86447 +
86448 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86449 BUG_ON(vma->vm_flags & VM_PFNMAP);
86450 vma->vm_flags |= VM_MIXEDMAP;
86451 +
86452 +#ifdef CONFIG_PAX_SEGMEXEC
86453 + vma_m = pax_find_mirror_vma(vma);
86454 + if (vma_m)
86455 + vma_m->vm_flags |= VM_MIXEDMAP;
86456 +#endif
86457 +
86458 }
86459 return insert_page(vma, addr, page, vma->vm_page_prot);
86460 }
86461 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86462 unsigned long pfn)
86463 {
86464 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86465 + BUG_ON(vma->vm_mirror);
86466
86467 if (addr < vma->vm_start || addr >= vma->vm_end)
86468 return -EFAULT;
86469 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86470
86471 BUG_ON(pud_huge(*pud));
86472
86473 - pmd = pmd_alloc(mm, pud, addr);
86474 + pmd = (mm == &init_mm) ?
86475 + pmd_alloc_kernel(mm, pud, addr) :
86476 + pmd_alloc(mm, pud, addr);
86477 if (!pmd)
86478 return -ENOMEM;
86479 do {
86480 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86481 unsigned long next;
86482 int err;
86483
86484 - pud = pud_alloc(mm, pgd, addr);
86485 + pud = (mm == &init_mm) ?
86486 + pud_alloc_kernel(mm, pgd, addr) :
86487 + pud_alloc(mm, pgd, addr);
86488 if (!pud)
86489 return -ENOMEM;
86490 do {
86491 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86492 copy_user_highpage(dst, src, va, vma);
86493 }
86494
86495 +#ifdef CONFIG_PAX_SEGMEXEC
86496 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86497 +{
86498 + struct mm_struct *mm = vma->vm_mm;
86499 + spinlock_t *ptl;
86500 + pte_t *pte, entry;
86501 +
86502 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86503 + entry = *pte;
86504 + if (!pte_present(entry)) {
86505 + if (!pte_none(entry)) {
86506 + BUG_ON(pte_file(entry));
86507 + free_swap_and_cache(pte_to_swp_entry(entry));
86508 + pte_clear_not_present_full(mm, address, pte, 0);
86509 + }
86510 + } else {
86511 + struct page *page;
86512 +
86513 + flush_cache_page(vma, address, pte_pfn(entry));
86514 + entry = ptep_clear_flush(vma, address, pte);
86515 + BUG_ON(pte_dirty(entry));
86516 + page = vm_normal_page(vma, address, entry);
86517 + if (page) {
86518 + update_hiwater_rss(mm);
86519 + if (PageAnon(page))
86520 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86521 + else
86522 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86523 + page_remove_rmap(page);
86524 + page_cache_release(page);
86525 + }
86526 + }
86527 + pte_unmap_unlock(pte, ptl);
86528 +}
86529 +
86530 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86531 + *
86532 + * the ptl of the lower mapped page is held on entry and is not released on exit
86533 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86534 + */
86535 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86536 +{
86537 + struct mm_struct *mm = vma->vm_mm;
86538 + unsigned long address_m;
86539 + spinlock_t *ptl_m;
86540 + struct vm_area_struct *vma_m;
86541 + pmd_t *pmd_m;
86542 + pte_t *pte_m, entry_m;
86543 +
86544 + BUG_ON(!page_m || !PageAnon(page_m));
86545 +
86546 + vma_m = pax_find_mirror_vma(vma);
86547 + if (!vma_m)
86548 + return;
86549 +
86550 + BUG_ON(!PageLocked(page_m));
86551 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86552 + address_m = address + SEGMEXEC_TASK_SIZE;
86553 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86554 + pte_m = pte_offset_map(pmd_m, address_m);
86555 + ptl_m = pte_lockptr(mm, pmd_m);
86556 + if (ptl != ptl_m) {
86557 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86558 + if (!pte_none(*pte_m))
86559 + goto out;
86560 + }
86561 +
86562 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86563 + page_cache_get(page_m);
86564 + page_add_anon_rmap(page_m, vma_m, address_m);
86565 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86566 + set_pte_at(mm, address_m, pte_m, entry_m);
86567 + update_mmu_cache(vma_m, address_m, pte_m);
86568 +out:
86569 + if (ptl != ptl_m)
86570 + spin_unlock(ptl_m);
86571 + pte_unmap(pte_m);
86572 + unlock_page(page_m);
86573 +}
86574 +
86575 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86576 +{
86577 + struct mm_struct *mm = vma->vm_mm;
86578 + unsigned long address_m;
86579 + spinlock_t *ptl_m;
86580 + struct vm_area_struct *vma_m;
86581 + pmd_t *pmd_m;
86582 + pte_t *pte_m, entry_m;
86583 +
86584 + BUG_ON(!page_m || PageAnon(page_m));
86585 +
86586 + vma_m = pax_find_mirror_vma(vma);
86587 + if (!vma_m)
86588 + return;
86589 +
86590 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86591 + address_m = address + SEGMEXEC_TASK_SIZE;
86592 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86593 + pte_m = pte_offset_map(pmd_m, address_m);
86594 + ptl_m = pte_lockptr(mm, pmd_m);
86595 + if (ptl != ptl_m) {
86596 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86597 + if (!pte_none(*pte_m))
86598 + goto out;
86599 + }
86600 +
86601 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86602 + page_cache_get(page_m);
86603 + page_add_file_rmap(page_m);
86604 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86605 + set_pte_at(mm, address_m, pte_m, entry_m);
86606 + update_mmu_cache(vma_m, address_m, pte_m);
86607 +out:
86608 + if (ptl != ptl_m)
86609 + spin_unlock(ptl_m);
86610 + pte_unmap(pte_m);
86611 +}
86612 +
86613 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86614 +{
86615 + struct mm_struct *mm = vma->vm_mm;
86616 + unsigned long address_m;
86617 + spinlock_t *ptl_m;
86618 + struct vm_area_struct *vma_m;
86619 + pmd_t *pmd_m;
86620 + pte_t *pte_m, entry_m;
86621 +
86622 + vma_m = pax_find_mirror_vma(vma);
86623 + if (!vma_m)
86624 + return;
86625 +
86626 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86627 + address_m = address + SEGMEXEC_TASK_SIZE;
86628 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86629 + pte_m = pte_offset_map(pmd_m, address_m);
86630 + ptl_m = pte_lockptr(mm, pmd_m);
86631 + if (ptl != ptl_m) {
86632 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86633 + if (!pte_none(*pte_m))
86634 + goto out;
86635 + }
86636 +
86637 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86638 + set_pte_at(mm, address_m, pte_m, entry_m);
86639 +out:
86640 + if (ptl != ptl_m)
86641 + spin_unlock(ptl_m);
86642 + pte_unmap(pte_m);
86643 +}
86644 +
86645 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86646 +{
86647 + struct page *page_m;
86648 + pte_t entry;
86649 +
86650 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86651 + goto out;
86652 +
86653 + entry = *pte;
86654 + page_m = vm_normal_page(vma, address, entry);
86655 + if (!page_m)
86656 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86657 + else if (PageAnon(page_m)) {
86658 + if (pax_find_mirror_vma(vma)) {
86659 + pte_unmap_unlock(pte, ptl);
86660 + lock_page(page_m);
86661 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86662 + if (pte_same(entry, *pte))
86663 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86664 + else
86665 + unlock_page(page_m);
86666 + }
86667 + } else
86668 + pax_mirror_file_pte(vma, address, page_m, ptl);
86669 +
86670 +out:
86671 + pte_unmap_unlock(pte, ptl);
86672 +}
86673 +#endif
86674 +
86675 /*
86676 * This routine handles present pages, when users try to write
86677 * to a shared page. It is done by copying the page to a new address
86678 @@ -2809,6 +3005,12 @@ gotten:
86679 */
86680 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86681 if (likely(pte_same(*page_table, orig_pte))) {
86682 +
86683 +#ifdef CONFIG_PAX_SEGMEXEC
86684 + if (pax_find_mirror_vma(vma))
86685 + BUG_ON(!trylock_page(new_page));
86686 +#endif
86687 +
86688 if (old_page) {
86689 if (!PageAnon(old_page)) {
86690 dec_mm_counter_fast(mm, MM_FILEPAGES);
86691 @@ -2860,6 +3062,10 @@ gotten:
86692 page_remove_rmap(old_page);
86693 }
86694
86695 +#ifdef CONFIG_PAX_SEGMEXEC
86696 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86697 +#endif
86698 +
86699 /* Free the old page.. */
86700 new_page = old_page;
86701 ret |= VM_FAULT_WRITE;
86702 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86703 swap_free(entry);
86704 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86705 try_to_free_swap(page);
86706 +
86707 +#ifdef CONFIG_PAX_SEGMEXEC
86708 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86709 +#endif
86710 +
86711 unlock_page(page);
86712 if (page != swapcache) {
86713 /*
86714 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86715
86716 /* No need to invalidate - it was non-present before */
86717 update_mmu_cache(vma, address, page_table);
86718 +
86719 +#ifdef CONFIG_PAX_SEGMEXEC
86720 + pax_mirror_anon_pte(vma, address, page, ptl);
86721 +#endif
86722 +
86723 unlock:
86724 pte_unmap_unlock(page_table, ptl);
86725 out:
86726 @@ -3179,40 +3395,6 @@ out_release:
86727 }
86728
86729 /*
86730 - * This is like a special single-page "expand_{down|up}wards()",
86731 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86732 - * doesn't hit another vma.
86733 - */
86734 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86735 -{
86736 - address &= PAGE_MASK;
86737 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86738 - struct vm_area_struct *prev = vma->vm_prev;
86739 -
86740 - /*
86741 - * Is there a mapping abutting this one below?
86742 - *
86743 - * That's only ok if it's the same stack mapping
86744 - * that has gotten split..
86745 - */
86746 - if (prev && prev->vm_end == address)
86747 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86748 -
86749 - expand_downwards(vma, address - PAGE_SIZE);
86750 - }
86751 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86752 - struct vm_area_struct *next = vma->vm_next;
86753 -
86754 - /* As VM_GROWSDOWN but s/below/above/ */
86755 - if (next && next->vm_start == address + PAGE_SIZE)
86756 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86757 -
86758 - expand_upwards(vma, address + PAGE_SIZE);
86759 - }
86760 - return 0;
86761 -}
86762 -
86763 -/*
86764 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86765 * but allow concurrent faults), and pte mapped but not yet locked.
86766 * We return with mmap_sem still held, but pte unmapped and unlocked.
86767 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86768 unsigned long address, pte_t *page_table, pmd_t *pmd,
86769 unsigned int flags)
86770 {
86771 - struct page *page;
86772 + struct page *page = NULL;
86773 spinlock_t *ptl;
86774 pte_t entry;
86775
86776 - pte_unmap(page_table);
86777 -
86778 - /* Check if we need to add a guard page to the stack */
86779 - if (check_stack_guard_page(vma, address) < 0)
86780 - return VM_FAULT_SIGBUS;
86781 -
86782 - /* Use the zero-page for reads */
86783 if (!(flags & FAULT_FLAG_WRITE)) {
86784 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86785 vma->vm_page_prot));
86786 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86787 + ptl = pte_lockptr(mm, pmd);
86788 + spin_lock(ptl);
86789 if (!pte_none(*page_table))
86790 goto unlock;
86791 goto setpte;
86792 }
86793
86794 /* Allocate our own private page. */
86795 + pte_unmap(page_table);
86796 +
86797 if (unlikely(anon_vma_prepare(vma)))
86798 goto oom;
86799 page = alloc_zeroed_user_highpage_movable(vma, address);
86800 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86801 if (!pte_none(*page_table))
86802 goto release;
86803
86804 +#ifdef CONFIG_PAX_SEGMEXEC
86805 + if (pax_find_mirror_vma(vma))
86806 + BUG_ON(!trylock_page(page));
86807 +#endif
86808 +
86809 inc_mm_counter_fast(mm, MM_ANONPAGES);
86810 page_add_new_anon_rmap(page, vma, address);
86811 setpte:
86812 @@ -3272,6 +3455,12 @@ setpte:
86813
86814 /* No need to invalidate - it was non-present before */
86815 update_mmu_cache(vma, address, page_table);
86816 +
86817 +#ifdef CONFIG_PAX_SEGMEXEC
86818 + if (page)
86819 + pax_mirror_anon_pte(vma, address, page, ptl);
86820 +#endif
86821 +
86822 unlock:
86823 pte_unmap_unlock(page_table, ptl);
86824 return 0;
86825 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86826 */
86827 /* Only go through if we didn't race with anybody else... */
86828 if (likely(pte_same(*page_table, orig_pte))) {
86829 +
86830 +#ifdef CONFIG_PAX_SEGMEXEC
86831 + if (anon && pax_find_mirror_vma(vma))
86832 + BUG_ON(!trylock_page(page));
86833 +#endif
86834 +
86835 flush_icache_page(vma, page);
86836 entry = mk_pte(page, vma->vm_page_prot);
86837 if (flags & FAULT_FLAG_WRITE)
86838 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86839
86840 /* no need to invalidate: a not-present page won't be cached */
86841 update_mmu_cache(vma, address, page_table);
86842 +
86843 +#ifdef CONFIG_PAX_SEGMEXEC
86844 + if (anon)
86845 + pax_mirror_anon_pte(vma, address, page, ptl);
86846 + else
86847 + pax_mirror_file_pte(vma, address, page, ptl);
86848 +#endif
86849 +
86850 } else {
86851 if (cow_page)
86852 mem_cgroup_uncharge_page(cow_page);
86853 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
86854 if (flags & FAULT_FLAG_WRITE)
86855 flush_tlb_fix_spurious_fault(vma, address);
86856 }
86857 +
86858 +#ifdef CONFIG_PAX_SEGMEXEC
86859 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86860 + return 0;
86861 +#endif
86862 +
86863 unlock:
86864 pte_unmap_unlock(pte, ptl);
86865 return 0;
86866 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86867 pmd_t *pmd;
86868 pte_t *pte;
86869
86870 +#ifdef CONFIG_PAX_SEGMEXEC
86871 + struct vm_area_struct *vma_m;
86872 +#endif
86873 +
86874 __set_current_state(TASK_RUNNING);
86875
86876 count_vm_event(PGFAULT);
86877 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86878 if (unlikely(is_vm_hugetlb_page(vma)))
86879 return hugetlb_fault(mm, vma, address, flags);
86880
86881 +#ifdef CONFIG_PAX_SEGMEXEC
86882 + vma_m = pax_find_mirror_vma(vma);
86883 + if (vma_m) {
86884 + unsigned long address_m;
86885 + pgd_t *pgd_m;
86886 + pud_t *pud_m;
86887 + pmd_t *pmd_m;
86888 +
86889 + if (vma->vm_start > vma_m->vm_start) {
86890 + address_m = address;
86891 + address -= SEGMEXEC_TASK_SIZE;
86892 + vma = vma_m;
86893 + } else
86894 + address_m = address + SEGMEXEC_TASK_SIZE;
86895 +
86896 + pgd_m = pgd_offset(mm, address_m);
86897 + pud_m = pud_alloc(mm, pgd_m, address_m);
86898 + if (!pud_m)
86899 + return VM_FAULT_OOM;
86900 + pmd_m = pmd_alloc(mm, pud_m, address_m);
86901 + if (!pmd_m)
86902 + return VM_FAULT_OOM;
86903 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
86904 + return VM_FAULT_OOM;
86905 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
86906 + }
86907 +#endif
86908 +
86909 retry:
86910 pgd = pgd_offset(mm, address);
86911 pud = pud_alloc(mm, pgd, address);
86912 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86913 spin_unlock(&mm->page_table_lock);
86914 return 0;
86915 }
86916 +
86917 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86918 +{
86919 + pud_t *new = pud_alloc_one(mm, address);
86920 + if (!new)
86921 + return -ENOMEM;
86922 +
86923 + smp_wmb(); /* See comment in __pte_alloc */
86924 +
86925 + spin_lock(&mm->page_table_lock);
86926 + if (pgd_present(*pgd)) /* Another has populated it */
86927 + pud_free(mm, new);
86928 + else
86929 + pgd_populate_kernel(mm, pgd, new);
86930 + spin_unlock(&mm->page_table_lock);
86931 + return 0;
86932 +}
86933 #endif /* __PAGETABLE_PUD_FOLDED */
86934
86935 #ifndef __PAGETABLE_PMD_FOLDED
86936 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
86937 spin_unlock(&mm->page_table_lock);
86938 return 0;
86939 }
86940 +
86941 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
86942 +{
86943 + pmd_t *new = pmd_alloc_one(mm, address);
86944 + if (!new)
86945 + return -ENOMEM;
86946 +
86947 + smp_wmb(); /* See comment in __pte_alloc */
86948 +
86949 + spin_lock(&mm->page_table_lock);
86950 +#ifndef __ARCH_HAS_4LEVEL_HACK
86951 + if (pud_present(*pud)) /* Another has populated it */
86952 + pmd_free(mm, new);
86953 + else
86954 + pud_populate_kernel(mm, pud, new);
86955 +#else
86956 + if (pgd_present(*pud)) /* Another has populated it */
86957 + pmd_free(mm, new);
86958 + else
86959 + pgd_populate_kernel(mm, pud, new);
86960 +#endif /* __ARCH_HAS_4LEVEL_HACK */
86961 + spin_unlock(&mm->page_table_lock);
86962 + return 0;
86963 +}
86964 #endif /* __PAGETABLE_PMD_FOLDED */
86965
86966 #if !defined(__HAVE_ARCH_GATE_AREA)
86967 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
86968 gate_vma.vm_start = FIXADDR_USER_START;
86969 gate_vma.vm_end = FIXADDR_USER_END;
86970 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
86971 - gate_vma.vm_page_prot = __P101;
86972 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
86973
86974 return 0;
86975 }
86976 @@ -4059,8 +4341,8 @@ out:
86977 return ret;
86978 }
86979
86980 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86981 - void *buf, int len, int write)
86982 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86983 + void *buf, size_t len, int write)
86984 {
86985 resource_size_t phys_addr;
86986 unsigned long prot = 0;
86987 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86988 * Access another process' address space as given in mm. If non-NULL, use the
86989 * given task for page fault accounting.
86990 */
86991 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86992 - unsigned long addr, void *buf, int len, int write)
86993 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86994 + unsigned long addr, void *buf, size_t len, int write)
86995 {
86996 struct vm_area_struct *vma;
86997 void *old_buf = buf;
86998 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86999 down_read(&mm->mmap_sem);
87000 /* ignore errors, just check how much was successfully transferred */
87001 while (len) {
87002 - int bytes, ret, offset;
87003 + ssize_t bytes, ret, offset;
87004 void *maddr;
87005 struct page *page = NULL;
87006
87007 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87008 *
87009 * The caller must hold a reference on @mm.
87010 */
87011 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87012 - void *buf, int len, int write)
87013 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87014 + void *buf, size_t len, int write)
87015 {
87016 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87017 }
87018 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87019 * Source/target buffer must be kernel space,
87020 * Do not walk the page table directly, use get_user_pages
87021 */
87022 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87023 - void *buf, int len, int write)
87024 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87025 + void *buf, size_t len, int write)
87026 {
87027 struct mm_struct *mm;
87028 - int ret;
87029 + ssize_t ret;
87030
87031 mm = get_task_mm(tsk);
87032 if (!mm)
87033 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87034 index 4baf12e..5497066 100644
87035 --- a/mm/mempolicy.c
87036 +++ b/mm/mempolicy.c
87037 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87038 unsigned long vmstart;
87039 unsigned long vmend;
87040
87041 +#ifdef CONFIG_PAX_SEGMEXEC
87042 + struct vm_area_struct *vma_m;
87043 +#endif
87044 +
87045 vma = find_vma(mm, start);
87046 if (!vma || vma->vm_start > start)
87047 return -EFAULT;
87048 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87049 err = vma_replace_policy(vma, new_pol);
87050 if (err)
87051 goto out;
87052 +
87053 +#ifdef CONFIG_PAX_SEGMEXEC
87054 + vma_m = pax_find_mirror_vma(vma);
87055 + if (vma_m) {
87056 + err = vma_replace_policy(vma_m, new_pol);
87057 + if (err)
87058 + goto out;
87059 + }
87060 +#endif
87061 +
87062 }
87063
87064 out:
87065 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87066
87067 if (end < start)
87068 return -EINVAL;
87069 +
87070 +#ifdef CONFIG_PAX_SEGMEXEC
87071 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87072 + if (end > SEGMEXEC_TASK_SIZE)
87073 + return -EINVAL;
87074 + } else
87075 +#endif
87076 +
87077 + if (end > TASK_SIZE)
87078 + return -EINVAL;
87079 +
87080 if (end == start)
87081 return 0;
87082
87083 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87084 */
87085 tcred = __task_cred(task);
87086 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87087 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87088 - !capable(CAP_SYS_NICE)) {
87089 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87090 rcu_read_unlock();
87091 err = -EPERM;
87092 goto out_put;
87093 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87094 goto out;
87095 }
87096
87097 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87098 + if (mm != current->mm &&
87099 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87100 + mmput(mm);
87101 + err = -EPERM;
87102 + goto out;
87103 + }
87104 +#endif
87105 +
87106 err = do_migrate_pages(mm, old, new,
87107 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87108
87109 diff --git a/mm/migrate.c b/mm/migrate.c
87110 index 6f0c244..6d1ae32 100644
87111 --- a/mm/migrate.c
87112 +++ b/mm/migrate.c
87113 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87114 */
87115 tcred = __task_cred(task);
87116 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87117 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87118 - !capable(CAP_SYS_NICE)) {
87119 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87120 rcu_read_unlock();
87121 err = -EPERM;
87122 goto out;
87123 diff --git a/mm/mlock.c b/mm/mlock.c
87124 index 79b7cf7..37472bf 100644
87125 --- a/mm/mlock.c
87126 +++ b/mm/mlock.c
87127 @@ -13,6 +13,7 @@
87128 #include <linux/pagemap.h>
87129 #include <linux/mempolicy.h>
87130 #include <linux/syscalls.h>
87131 +#include <linux/security.h>
87132 #include <linux/sched.h>
87133 #include <linux/export.h>
87134 #include <linux/rmap.h>
87135 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87136 {
87137 unsigned long nstart, end, tmp;
87138 struct vm_area_struct * vma, * prev;
87139 - int error;
87140 + int error = 0;
87141
87142 VM_BUG_ON(start & ~PAGE_MASK);
87143 VM_BUG_ON(len != PAGE_ALIGN(len));
87144 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87145 return -EINVAL;
87146 if (end == start)
87147 return 0;
87148 + if (end > TASK_SIZE)
87149 + return -EINVAL;
87150 +
87151 vma = find_vma(current->mm, start);
87152 if (!vma || vma->vm_start > start)
87153 return -ENOMEM;
87154 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87155 for (nstart = start ; ; ) {
87156 vm_flags_t newflags;
87157
87158 +#ifdef CONFIG_PAX_SEGMEXEC
87159 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87160 + break;
87161 +#endif
87162 +
87163 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87164
87165 newflags = vma->vm_flags & ~VM_LOCKED;
87166 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87167 lock_limit >>= PAGE_SHIFT;
87168
87169 /* check against resource limits */
87170 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87171 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87172 error = do_mlock(start, len, 1);
87173 up_write(&current->mm->mmap_sem);
87174 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87175 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87176 vm_flags_t newflags;
87177
87178 +#ifdef CONFIG_PAX_SEGMEXEC
87179 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87180 + break;
87181 +#endif
87182 +
87183 newflags = vma->vm_flags & ~VM_LOCKED;
87184 if (flags & MCL_CURRENT)
87185 newflags |= VM_LOCKED;
87186
87187 /* Ignore errors */
87188 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87189 + cond_resched();
87190 }
87191 out:
87192 return 0;
87193 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87194 lock_limit >>= PAGE_SHIFT;
87195
87196 ret = -ENOMEM;
87197 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87198 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87199 capable(CAP_IPC_LOCK))
87200 ret = do_mlockall(flags);
87201 diff --git a/mm/mmap.c b/mm/mmap.c
87202 index f9c97d1..3468d3b 100644
87203 --- a/mm/mmap.c
87204 +++ b/mm/mmap.c
87205 @@ -36,6 +36,7 @@
87206 #include <linux/sched/sysctl.h>
87207 #include <linux/notifier.h>
87208 #include <linux/memory.h>
87209 +#include <linux/random.h>
87210
87211 #include <asm/uaccess.h>
87212 #include <asm/cacheflush.h>
87213 @@ -52,6 +53,16 @@
87214 #define arch_rebalance_pgtables(addr, len) (addr)
87215 #endif
87216
87217 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87218 +{
87219 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87220 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87221 + up_read(&mm->mmap_sem);
87222 + BUG();
87223 + }
87224 +#endif
87225 +}
87226 +
87227 static void unmap_region(struct mm_struct *mm,
87228 struct vm_area_struct *vma, struct vm_area_struct *prev,
87229 unsigned long start, unsigned long end);
87230 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87231 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87232 *
87233 */
87234 -pgprot_t protection_map[16] = {
87235 +pgprot_t protection_map[16] __read_only = {
87236 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87237 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87238 };
87239
87240 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87241 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87242 {
87243 - return __pgprot(pgprot_val(protection_map[vm_flags &
87244 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87245 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87246 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87247 +
87248 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87249 + if (!(__supported_pte_mask & _PAGE_NX) &&
87250 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87251 + (vm_flags & (VM_READ | VM_WRITE)))
87252 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87253 +#endif
87254 +
87255 + return prot;
87256 }
87257 EXPORT_SYMBOL(vm_get_page_prot);
87258
87259 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87260 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87261 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87262 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87263 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87264 /*
87265 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87266 * other variables. It can be updated by several CPUs frequently.
87267 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87268 struct vm_area_struct *next = vma->vm_next;
87269
87270 might_sleep();
87271 + BUG_ON(vma->vm_mirror);
87272 if (vma->vm_ops && vma->vm_ops->close)
87273 vma->vm_ops->close(vma);
87274 if (vma->vm_file)
87275 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87276 * not page aligned -Ram Gupta
87277 */
87278 rlim = rlimit(RLIMIT_DATA);
87279 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87280 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87281 (mm->end_data - mm->start_data) > rlim)
87282 goto out;
87283 @@ -933,6 +956,12 @@ static int
87284 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87285 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87286 {
87287 +
87288 +#ifdef CONFIG_PAX_SEGMEXEC
87289 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87290 + return 0;
87291 +#endif
87292 +
87293 if (is_mergeable_vma(vma, file, vm_flags) &&
87294 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87295 if (vma->vm_pgoff == vm_pgoff)
87296 @@ -952,6 +981,12 @@ static int
87297 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87298 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87299 {
87300 +
87301 +#ifdef CONFIG_PAX_SEGMEXEC
87302 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87303 + return 0;
87304 +#endif
87305 +
87306 if (is_mergeable_vma(vma, file, vm_flags) &&
87307 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87308 pgoff_t vm_pglen;
87309 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87310 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87311 struct vm_area_struct *prev, unsigned long addr,
87312 unsigned long end, unsigned long vm_flags,
87313 - struct anon_vma *anon_vma, struct file *file,
87314 + struct anon_vma *anon_vma, struct file *file,
87315 pgoff_t pgoff, struct mempolicy *policy)
87316 {
87317 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87318 struct vm_area_struct *area, *next;
87319 int err;
87320
87321 +#ifdef CONFIG_PAX_SEGMEXEC
87322 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87323 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87324 +
87325 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87326 +#endif
87327 +
87328 /*
87329 * We later require that vma->vm_flags == vm_flags,
87330 * so this tests vma->vm_flags & VM_SPECIAL, too.
87331 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87332 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87333 next = next->vm_next;
87334
87335 +#ifdef CONFIG_PAX_SEGMEXEC
87336 + if (prev)
87337 + prev_m = pax_find_mirror_vma(prev);
87338 + if (area)
87339 + area_m = pax_find_mirror_vma(area);
87340 + if (next)
87341 + next_m = pax_find_mirror_vma(next);
87342 +#endif
87343 +
87344 /*
87345 * Can it merge with the predecessor?
87346 */
87347 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87348 /* cases 1, 6 */
87349 err = vma_adjust(prev, prev->vm_start,
87350 next->vm_end, prev->vm_pgoff, NULL);
87351 - } else /* cases 2, 5, 7 */
87352 +
87353 +#ifdef CONFIG_PAX_SEGMEXEC
87354 + if (!err && prev_m)
87355 + err = vma_adjust(prev_m, prev_m->vm_start,
87356 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87357 +#endif
87358 +
87359 + } else { /* cases 2, 5, 7 */
87360 err = vma_adjust(prev, prev->vm_start,
87361 end, prev->vm_pgoff, NULL);
87362 +
87363 +#ifdef CONFIG_PAX_SEGMEXEC
87364 + if (!err && prev_m)
87365 + err = vma_adjust(prev_m, prev_m->vm_start,
87366 + end_m, prev_m->vm_pgoff, NULL);
87367 +#endif
87368 +
87369 + }
87370 if (err)
87371 return NULL;
87372 khugepaged_enter_vma_merge(prev);
87373 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87374 mpol_equal(policy, vma_policy(next)) &&
87375 can_vma_merge_before(next, vm_flags,
87376 anon_vma, file, pgoff+pglen)) {
87377 - if (prev && addr < prev->vm_end) /* case 4 */
87378 + if (prev && addr < prev->vm_end) { /* case 4 */
87379 err = vma_adjust(prev, prev->vm_start,
87380 addr, prev->vm_pgoff, NULL);
87381 - else /* cases 3, 8 */
87382 +
87383 +#ifdef CONFIG_PAX_SEGMEXEC
87384 + if (!err && prev_m)
87385 + err = vma_adjust(prev_m, prev_m->vm_start,
87386 + addr_m, prev_m->vm_pgoff, NULL);
87387 +#endif
87388 +
87389 + } else { /* cases 3, 8 */
87390 err = vma_adjust(area, addr, next->vm_end,
87391 next->vm_pgoff - pglen, NULL);
87392 +
87393 +#ifdef CONFIG_PAX_SEGMEXEC
87394 + if (!err && area_m)
87395 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87396 + next_m->vm_pgoff - pglen, NULL);
87397 +#endif
87398 +
87399 + }
87400 if (err)
87401 return NULL;
87402 khugepaged_enter_vma_merge(area);
87403 @@ -1165,8 +1246,10 @@ none:
87404 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87405 struct file *file, long pages)
87406 {
87407 - const unsigned long stack_flags
87408 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87409 +
87410 +#ifdef CONFIG_PAX_RANDMMAP
87411 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87412 +#endif
87413
87414 mm->total_vm += pages;
87415
87416 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87417 mm->shared_vm += pages;
87418 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87419 mm->exec_vm += pages;
87420 - } else if (flags & stack_flags)
87421 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87422 mm->stack_vm += pages;
87423 }
87424 #endif /* CONFIG_PROC_FS */
87425 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87426 * (the exception is when the underlying filesystem is noexec
87427 * mounted, in which case we dont add PROT_EXEC.)
87428 */
87429 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87430 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87431 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87432 prot |= PROT_EXEC;
87433
87434 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87435 /* Obtain the address to map to. we verify (or select) it and ensure
87436 * that it represents a valid section of the address space.
87437 */
87438 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87439 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87440 if (addr & ~PAGE_MASK)
87441 return addr;
87442
87443 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87444 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87445 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87446
87447 +#ifdef CONFIG_PAX_MPROTECT
87448 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87449 +
87450 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87451 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87452 + mm->binfmt->handle_mmap)
87453 + mm->binfmt->handle_mmap(file);
87454 +#endif
87455 +
87456 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87457 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87458 + gr_log_rwxmmap(file);
87459 +
87460 +#ifdef CONFIG_PAX_EMUPLT
87461 + vm_flags &= ~VM_EXEC;
87462 +#else
87463 + return -EPERM;
87464 +#endif
87465 +
87466 + }
87467 +
87468 + if (!(vm_flags & VM_EXEC))
87469 + vm_flags &= ~VM_MAYEXEC;
87470 +#else
87471 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87472 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87473 +#endif
87474 + else
87475 + vm_flags &= ~VM_MAYWRITE;
87476 + }
87477 +#endif
87478 +
87479 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87480 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87481 + vm_flags &= ~VM_PAGEEXEC;
87482 +#endif
87483 +
87484 if (flags & MAP_LOCKED)
87485 if (!can_do_mlock())
87486 return -EPERM;
87487 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87488 locked += mm->locked_vm;
87489 lock_limit = rlimit(RLIMIT_MEMLOCK);
87490 lock_limit >>= PAGE_SHIFT;
87491 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87492 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87493 return -EAGAIN;
87494 }
87495 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87496 vm_flags |= VM_NORESERVE;
87497 }
87498
87499 + if (!gr_acl_handle_mmap(file, prot))
87500 + return -EACCES;
87501 +
87502 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87503 if (!IS_ERR_VALUE(addr) &&
87504 ((vm_flags & VM_LOCKED) ||
87505 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87506 vm_flags_t vm_flags = vma->vm_flags;
87507
87508 /* If it was private or non-writable, the write bit is already clear */
87509 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87510 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87511 return 0;
87512
87513 /* The backer wishes to know when pages are first written to? */
87514 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87515 unsigned long charged = 0;
87516 struct inode *inode = file ? file_inode(file) : NULL;
87517
87518 +#ifdef CONFIG_PAX_SEGMEXEC
87519 + struct vm_area_struct *vma_m = NULL;
87520 +#endif
87521 +
87522 + /*
87523 + * mm->mmap_sem is required to protect against another thread
87524 + * changing the mappings in case we sleep.
87525 + */
87526 + verify_mm_writelocked(mm);
87527 +
87528 /* Check against address space limit. */
87529 +
87530 +#ifdef CONFIG_PAX_RANDMMAP
87531 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87532 +#endif
87533 +
87534 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87535 unsigned long nr_pages;
87536
87537 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87538
87539 /* Clear old maps */
87540 error = -ENOMEM;
87541 -munmap_back:
87542 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87543 if (do_munmap(mm, addr, len))
87544 return -ENOMEM;
87545 - goto munmap_back;
87546 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87547 }
87548
87549 /*
87550 @@ -1536,6 +1674,16 @@ munmap_back:
87551 goto unacct_error;
87552 }
87553
87554 +#ifdef CONFIG_PAX_SEGMEXEC
87555 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87556 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87557 + if (!vma_m) {
87558 + error = -ENOMEM;
87559 + goto free_vma;
87560 + }
87561 + }
87562 +#endif
87563 +
87564 vma->vm_mm = mm;
87565 vma->vm_start = addr;
87566 vma->vm_end = addr + len;
87567 @@ -1560,6 +1708,13 @@ munmap_back:
87568 if (error)
87569 goto unmap_and_free_vma;
87570
87571 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87572 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87573 + vma->vm_flags |= VM_PAGEEXEC;
87574 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87575 + }
87576 +#endif
87577 +
87578 /* Can addr have changed??
87579 *
87580 * Answer: Yes, several device drivers can do it in their
87581 @@ -1598,6 +1753,11 @@ munmap_back:
87582 vma_link(mm, vma, prev, rb_link, rb_parent);
87583 file = vma->vm_file;
87584
87585 +#ifdef CONFIG_PAX_SEGMEXEC
87586 + if (vma_m)
87587 + BUG_ON(pax_mirror_vma(vma_m, vma));
87588 +#endif
87589 +
87590 /* Once vma denies write, undo our temporary denial count */
87591 if (correct_wcount)
87592 atomic_inc(&inode->i_writecount);
87593 @@ -1605,6 +1765,7 @@ out:
87594 perf_event_mmap(vma);
87595
87596 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87597 + track_exec_limit(mm, addr, addr + len, vm_flags);
87598 if (vm_flags & VM_LOCKED) {
87599 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87600 vma == get_gate_vma(current->mm)))
87601 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87602 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87603 charged = 0;
87604 free_vma:
87605 +
87606 +#ifdef CONFIG_PAX_SEGMEXEC
87607 + if (vma_m)
87608 + kmem_cache_free(vm_area_cachep, vma_m);
87609 +#endif
87610 +
87611 kmem_cache_free(vm_area_cachep, vma);
87612 unacct_error:
87613 if (charged)
87614 @@ -1635,7 +1802,63 @@ unacct_error:
87615 return error;
87616 }
87617
87618 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87619 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87620 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87621 +{
87622 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87623 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87624 +
87625 + return 0;
87626 +}
87627 +#endif
87628 +
87629 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87630 +{
87631 + if (!vma) {
87632 +#ifdef CONFIG_STACK_GROWSUP
87633 + if (addr > sysctl_heap_stack_gap)
87634 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87635 + else
87636 + vma = find_vma(current->mm, 0);
87637 + if (vma && (vma->vm_flags & VM_GROWSUP))
87638 + return false;
87639 +#endif
87640 + return true;
87641 + }
87642 +
87643 + if (addr + len > vma->vm_start)
87644 + return false;
87645 +
87646 + if (vma->vm_flags & VM_GROWSDOWN)
87647 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87648 +#ifdef CONFIG_STACK_GROWSUP
87649 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87650 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87651 +#endif
87652 + else if (offset)
87653 + return offset <= vma->vm_start - addr - len;
87654 +
87655 + return true;
87656 +}
87657 +
87658 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87659 +{
87660 + if (vma->vm_start < len)
87661 + return -ENOMEM;
87662 +
87663 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87664 + if (offset <= vma->vm_start - len)
87665 + return vma->vm_start - len - offset;
87666 + else
87667 + return -ENOMEM;
87668 + }
87669 +
87670 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87671 + return vma->vm_start - len - sysctl_heap_stack_gap;
87672 + return -ENOMEM;
87673 +}
87674 +
87675 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87676 {
87677 /*
87678 * We implement the search by looking for an rbtree node that
87679 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87680 }
87681 }
87682
87683 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87684 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87685 check_current:
87686 /* Check if current node has a suitable gap */
87687 if (gap_start > high_limit)
87688 return -ENOMEM;
87689 +
87690 + if (gap_end - gap_start > info->threadstack_offset)
87691 + gap_start += info->threadstack_offset;
87692 + else
87693 + gap_start = gap_end;
87694 +
87695 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87696 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87697 + gap_start += sysctl_heap_stack_gap;
87698 + else
87699 + gap_start = gap_end;
87700 + }
87701 + if (vma->vm_flags & VM_GROWSDOWN) {
87702 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87703 + gap_end -= sysctl_heap_stack_gap;
87704 + else
87705 + gap_end = gap_start;
87706 + }
87707 if (gap_end >= low_limit && gap_end - gap_start >= length)
87708 goto found;
87709
87710 @@ -1737,7 +1978,7 @@ found:
87711 return gap_start;
87712 }
87713
87714 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87715 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87716 {
87717 struct mm_struct *mm = current->mm;
87718 struct vm_area_struct *vma;
87719 @@ -1791,6 +2032,24 @@ check_current:
87720 gap_end = vma->vm_start;
87721 if (gap_end < low_limit)
87722 return -ENOMEM;
87723 +
87724 + if (gap_end - gap_start > info->threadstack_offset)
87725 + gap_end -= info->threadstack_offset;
87726 + else
87727 + gap_end = gap_start;
87728 +
87729 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87730 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87731 + gap_start += sysctl_heap_stack_gap;
87732 + else
87733 + gap_start = gap_end;
87734 + }
87735 + if (vma->vm_flags & VM_GROWSDOWN) {
87736 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87737 + gap_end -= sysctl_heap_stack_gap;
87738 + else
87739 + gap_end = gap_start;
87740 + }
87741 if (gap_start <= high_limit && gap_end - gap_start >= length)
87742 goto found;
87743
87744 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87745 struct mm_struct *mm = current->mm;
87746 struct vm_area_struct *vma;
87747 struct vm_unmapped_area_info info;
87748 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87749
87750 if (len > TASK_SIZE)
87751 return -ENOMEM;
87752 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87753 if (flags & MAP_FIXED)
87754 return addr;
87755
87756 +#ifdef CONFIG_PAX_RANDMMAP
87757 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87758 +#endif
87759 +
87760 if (addr) {
87761 addr = PAGE_ALIGN(addr);
87762 vma = find_vma(mm, addr);
87763 - if (TASK_SIZE - len >= addr &&
87764 - (!vma || addr + len <= vma->vm_start))
87765 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87766 return addr;
87767 }
87768
87769 info.flags = 0;
87770 info.length = len;
87771 info.low_limit = TASK_UNMAPPED_BASE;
87772 +
87773 +#ifdef CONFIG_PAX_RANDMMAP
87774 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87775 + info.low_limit += mm->delta_mmap;
87776 +#endif
87777 +
87778 info.high_limit = TASK_SIZE;
87779 info.align_mask = 0;
87780 + info.threadstack_offset = offset;
87781 return vm_unmapped_area(&info);
87782 }
87783 #endif
87784 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87785 struct mm_struct *mm = current->mm;
87786 unsigned long addr = addr0;
87787 struct vm_unmapped_area_info info;
87788 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87789
87790 /* requested length too big for entire address space */
87791 if (len > TASK_SIZE)
87792 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87793 if (flags & MAP_FIXED)
87794 return addr;
87795
87796 +#ifdef CONFIG_PAX_RANDMMAP
87797 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87798 +#endif
87799 +
87800 /* requesting a specific address */
87801 if (addr) {
87802 addr = PAGE_ALIGN(addr);
87803 vma = find_vma(mm, addr);
87804 - if (TASK_SIZE - len >= addr &&
87805 - (!vma || addr + len <= vma->vm_start))
87806 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87807 return addr;
87808 }
87809
87810 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87811 info.low_limit = PAGE_SIZE;
87812 info.high_limit = mm->mmap_base;
87813 info.align_mask = 0;
87814 + info.threadstack_offset = offset;
87815 addr = vm_unmapped_area(&info);
87816
87817 /*
87818 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87819 VM_BUG_ON(addr != -ENOMEM);
87820 info.flags = 0;
87821 info.low_limit = TASK_UNMAPPED_BASE;
87822 +
87823 +#ifdef CONFIG_PAX_RANDMMAP
87824 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87825 + info.low_limit += mm->delta_mmap;
87826 +#endif
87827 +
87828 info.high_limit = TASK_SIZE;
87829 addr = vm_unmapped_area(&info);
87830 }
87831 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87832 return vma;
87833 }
87834
87835 +#ifdef CONFIG_PAX_SEGMEXEC
87836 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87837 +{
87838 + struct vm_area_struct *vma_m;
87839 +
87840 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87841 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87842 + BUG_ON(vma->vm_mirror);
87843 + return NULL;
87844 + }
87845 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87846 + vma_m = vma->vm_mirror;
87847 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87848 + BUG_ON(vma->vm_file != vma_m->vm_file);
87849 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87850 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87851 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87852 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87853 + return vma_m;
87854 +}
87855 +#endif
87856 +
87857 /*
87858 * Verify that the stack growth is acceptable and
87859 * update accounting. This is shared with both the
87860 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87861 return -ENOMEM;
87862
87863 /* Stack limit test */
87864 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
87865 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
87866 return -ENOMEM;
87867
87868 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87869 locked = mm->locked_vm + grow;
87870 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
87871 limit >>= PAGE_SHIFT;
87872 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87873 if (locked > limit && !capable(CAP_IPC_LOCK))
87874 return -ENOMEM;
87875 }
87876 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87877 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
87878 * vma is the last one with address > vma->vm_end. Have to extend vma.
87879 */
87880 +#ifndef CONFIG_IA64
87881 +static
87882 +#endif
87883 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87884 {
87885 int error;
87886 + bool locknext;
87887
87888 if (!(vma->vm_flags & VM_GROWSUP))
87889 return -EFAULT;
87890
87891 + /* Also guard against wrapping around to address 0. */
87892 + if (address < PAGE_ALIGN(address+1))
87893 + address = PAGE_ALIGN(address+1);
87894 + else
87895 + return -ENOMEM;
87896 +
87897 /*
87898 * We must make sure the anon_vma is allocated
87899 * so that the anon_vma locking is not a noop.
87900 */
87901 if (unlikely(anon_vma_prepare(vma)))
87902 return -ENOMEM;
87903 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
87904 + if (locknext && anon_vma_prepare(vma->vm_next))
87905 + return -ENOMEM;
87906 vma_lock_anon_vma(vma);
87907 + if (locknext)
87908 + vma_lock_anon_vma(vma->vm_next);
87909
87910 /*
87911 * vma->vm_start/vm_end cannot change under us because the caller
87912 * is required to hold the mmap_sem in read mode. We need the
87913 - * anon_vma lock to serialize against concurrent expand_stacks.
87914 - * Also guard against wrapping around to address 0.
87915 + * anon_vma locks to serialize against concurrent expand_stacks
87916 + * and expand_upwards.
87917 */
87918 - if (address < PAGE_ALIGN(address+4))
87919 - address = PAGE_ALIGN(address+4);
87920 - else {
87921 - vma_unlock_anon_vma(vma);
87922 - return -ENOMEM;
87923 - }
87924 error = 0;
87925
87926 /* Somebody else might have raced and expanded it already */
87927 - if (address > vma->vm_end) {
87928 + 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)
87929 + error = -ENOMEM;
87930 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
87931 unsigned long size, grow;
87932
87933 size = address - vma->vm_start;
87934 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87935 }
87936 }
87937 }
87938 + if (locknext)
87939 + vma_unlock_anon_vma(vma->vm_next);
87940 vma_unlock_anon_vma(vma);
87941 khugepaged_enter_vma_merge(vma);
87942 validate_mm(vma->vm_mm);
87943 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
87944 unsigned long address)
87945 {
87946 int error;
87947 + bool lockprev = false;
87948 + struct vm_area_struct *prev;
87949
87950 /*
87951 * We must make sure the anon_vma is allocated
87952 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
87953 if (error)
87954 return error;
87955
87956 + prev = vma->vm_prev;
87957 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
87958 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
87959 +#endif
87960 + if (lockprev && anon_vma_prepare(prev))
87961 + return -ENOMEM;
87962 + if (lockprev)
87963 + vma_lock_anon_vma(prev);
87964 +
87965 vma_lock_anon_vma(vma);
87966
87967 /*
87968 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
87969 */
87970
87971 /* Somebody else might have raced and expanded it already */
87972 - if (address < vma->vm_start) {
87973 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
87974 + error = -ENOMEM;
87975 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
87976 unsigned long size, grow;
87977
87978 +#ifdef CONFIG_PAX_SEGMEXEC
87979 + struct vm_area_struct *vma_m;
87980 +
87981 + vma_m = pax_find_mirror_vma(vma);
87982 +#endif
87983 +
87984 size = vma->vm_end - address;
87985 grow = (vma->vm_start - address) >> PAGE_SHIFT;
87986
87987 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
87988 vma->vm_pgoff -= grow;
87989 anon_vma_interval_tree_post_update_vma(vma);
87990 vma_gap_update(vma);
87991 +
87992 +#ifdef CONFIG_PAX_SEGMEXEC
87993 + if (vma_m) {
87994 + anon_vma_interval_tree_pre_update_vma(vma_m);
87995 + vma_m->vm_start -= grow << PAGE_SHIFT;
87996 + vma_m->vm_pgoff -= grow;
87997 + anon_vma_interval_tree_post_update_vma(vma_m);
87998 + vma_gap_update(vma_m);
87999 + }
88000 +#endif
88001 +
88002 spin_unlock(&vma->vm_mm->page_table_lock);
88003
88004 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88005 perf_event_mmap(vma);
88006 }
88007 }
88008 }
88009 vma_unlock_anon_vma(vma);
88010 + if (lockprev)
88011 + vma_unlock_anon_vma(prev);
88012 khugepaged_enter_vma_merge(vma);
88013 validate_mm(vma->vm_mm);
88014 return error;
88015 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88016 do {
88017 long nrpages = vma_pages(vma);
88018
88019 +#ifdef CONFIG_PAX_SEGMEXEC
88020 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88021 + vma = remove_vma(vma);
88022 + continue;
88023 + }
88024 +#endif
88025 +
88026 if (vma->vm_flags & VM_ACCOUNT)
88027 nr_accounted += nrpages;
88028 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88029 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88030 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88031 vma->vm_prev = NULL;
88032 do {
88033 +
88034 +#ifdef CONFIG_PAX_SEGMEXEC
88035 + if (vma->vm_mirror) {
88036 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88037 + vma->vm_mirror->vm_mirror = NULL;
88038 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88039 + vma->vm_mirror = NULL;
88040 + }
88041 +#endif
88042 +
88043 vma_rb_erase(vma, &mm->mm_rb);
88044 mm->map_count--;
88045 tail_vma = vma;
88046 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88047 struct vm_area_struct *new;
88048 int err = -ENOMEM;
88049
88050 +#ifdef CONFIG_PAX_SEGMEXEC
88051 + struct vm_area_struct *vma_m, *new_m = NULL;
88052 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88053 +#endif
88054 +
88055 if (is_vm_hugetlb_page(vma) && (addr &
88056 ~(huge_page_mask(hstate_vma(vma)))))
88057 return -EINVAL;
88058
88059 +#ifdef CONFIG_PAX_SEGMEXEC
88060 + vma_m = pax_find_mirror_vma(vma);
88061 +#endif
88062 +
88063 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88064 if (!new)
88065 goto out_err;
88066
88067 +#ifdef CONFIG_PAX_SEGMEXEC
88068 + if (vma_m) {
88069 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88070 + if (!new_m) {
88071 + kmem_cache_free(vm_area_cachep, new);
88072 + goto out_err;
88073 + }
88074 + }
88075 +#endif
88076 +
88077 /* most fields are the same, copy all, and then fixup */
88078 *new = *vma;
88079
88080 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88081 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88082 }
88083
88084 +#ifdef CONFIG_PAX_SEGMEXEC
88085 + if (vma_m) {
88086 + *new_m = *vma_m;
88087 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88088 + new_m->vm_mirror = new;
88089 + new->vm_mirror = new_m;
88090 +
88091 + if (new_below)
88092 + new_m->vm_end = addr_m;
88093 + else {
88094 + new_m->vm_start = addr_m;
88095 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88096 + }
88097 + }
88098 +#endif
88099 +
88100 pol = mpol_dup(vma_policy(vma));
88101 if (IS_ERR(pol)) {
88102 err = PTR_ERR(pol);
88103 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88104 else
88105 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88106
88107 +#ifdef CONFIG_PAX_SEGMEXEC
88108 + if (!err && vma_m) {
88109 + if (anon_vma_clone(new_m, vma_m))
88110 + goto out_free_mpol;
88111 +
88112 + mpol_get(pol);
88113 + vma_set_policy(new_m, pol);
88114 +
88115 + if (new_m->vm_file)
88116 + get_file(new_m->vm_file);
88117 +
88118 + if (new_m->vm_ops && new_m->vm_ops->open)
88119 + new_m->vm_ops->open(new_m);
88120 +
88121 + if (new_below)
88122 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88123 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88124 + else
88125 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88126 +
88127 + if (err) {
88128 + if (new_m->vm_ops && new_m->vm_ops->close)
88129 + new_m->vm_ops->close(new_m);
88130 + if (new_m->vm_file)
88131 + fput(new_m->vm_file);
88132 + mpol_put(pol);
88133 + }
88134 + }
88135 +#endif
88136 +
88137 /* Success. */
88138 if (!err)
88139 return 0;
88140 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88141 new->vm_ops->close(new);
88142 if (new->vm_file)
88143 fput(new->vm_file);
88144 - unlink_anon_vmas(new);
88145 out_free_mpol:
88146 mpol_put(pol);
88147 out_free_vma:
88148 +
88149 +#ifdef CONFIG_PAX_SEGMEXEC
88150 + if (new_m) {
88151 + unlink_anon_vmas(new_m);
88152 + kmem_cache_free(vm_area_cachep, new_m);
88153 + }
88154 +#endif
88155 +
88156 + unlink_anon_vmas(new);
88157 kmem_cache_free(vm_area_cachep, new);
88158 out_err:
88159 return err;
88160 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88161 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88162 unsigned long addr, int new_below)
88163 {
88164 +
88165 +#ifdef CONFIG_PAX_SEGMEXEC
88166 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88167 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88168 + if (mm->map_count >= sysctl_max_map_count-1)
88169 + return -ENOMEM;
88170 + } else
88171 +#endif
88172 +
88173 if (mm->map_count >= sysctl_max_map_count)
88174 return -ENOMEM;
88175
88176 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88177 * work. This now handles partial unmappings.
88178 * Jeremy Fitzhardinge <jeremy@goop.org>
88179 */
88180 +#ifdef CONFIG_PAX_SEGMEXEC
88181 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88182 {
88183 + int ret = __do_munmap(mm, start, len);
88184 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88185 + return ret;
88186 +
88187 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88188 +}
88189 +
88190 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88191 +#else
88192 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88193 +#endif
88194 +{
88195 unsigned long end;
88196 struct vm_area_struct *vma, *prev, *last;
88197
88198 + /*
88199 + * mm->mmap_sem is required to protect against another thread
88200 + * changing the mappings in case we sleep.
88201 + */
88202 + verify_mm_writelocked(mm);
88203 +
88204 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88205 return -EINVAL;
88206
88207 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88208 /* Fix up all other VM information */
88209 remove_vma_list(mm, vma);
88210
88211 + track_exec_limit(mm, start, end, 0UL);
88212 +
88213 return 0;
88214 }
88215
88216 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88217 int ret;
88218 struct mm_struct *mm = current->mm;
88219
88220 +
88221 +#ifdef CONFIG_PAX_SEGMEXEC
88222 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88223 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88224 + return -EINVAL;
88225 +#endif
88226 +
88227 down_write(&mm->mmap_sem);
88228 ret = do_munmap(mm, start, len);
88229 up_write(&mm->mmap_sem);
88230 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88231 return vm_munmap(addr, len);
88232 }
88233
88234 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88235 -{
88236 -#ifdef CONFIG_DEBUG_VM
88237 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88238 - WARN_ON(1);
88239 - up_read(&mm->mmap_sem);
88240 - }
88241 -#endif
88242 -}
88243 -
88244 /*
88245 * this is really a simplified "do_mmap". it only handles
88246 * anonymous maps. eventually we may be able to do some
88247 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88248 struct rb_node ** rb_link, * rb_parent;
88249 pgoff_t pgoff = addr >> PAGE_SHIFT;
88250 int error;
88251 + unsigned long charged;
88252
88253 len = PAGE_ALIGN(len);
88254 if (!len)
88255 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88256
88257 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88258
88259 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88260 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88261 + flags &= ~VM_EXEC;
88262 +
88263 +#ifdef CONFIG_PAX_MPROTECT
88264 + if (mm->pax_flags & MF_PAX_MPROTECT)
88265 + flags &= ~VM_MAYEXEC;
88266 +#endif
88267 +
88268 + }
88269 +#endif
88270 +
88271 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88272 if (error & ~PAGE_MASK)
88273 return error;
88274
88275 + charged = len >> PAGE_SHIFT;
88276 +
88277 /*
88278 * mlock MCL_FUTURE?
88279 */
88280 if (mm->def_flags & VM_LOCKED) {
88281 unsigned long locked, lock_limit;
88282 - locked = len >> PAGE_SHIFT;
88283 + locked = charged;
88284 locked += mm->locked_vm;
88285 lock_limit = rlimit(RLIMIT_MEMLOCK);
88286 lock_limit >>= PAGE_SHIFT;
88287 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88288 /*
88289 * Clear old maps. this also does some error checking for us
88290 */
88291 - munmap_back:
88292 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88293 if (do_munmap(mm, addr, len))
88294 return -ENOMEM;
88295 - goto munmap_back;
88296 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88297 }
88298
88299 /* Check against address space limits *after* clearing old maps... */
88300 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88301 + if (!may_expand_vm(mm, charged))
88302 return -ENOMEM;
88303
88304 if (mm->map_count > sysctl_max_map_count)
88305 return -ENOMEM;
88306
88307 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88308 + if (security_vm_enough_memory_mm(mm, charged))
88309 return -ENOMEM;
88310
88311 /* Can we just expand an old private anonymous mapping? */
88312 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88313 */
88314 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88315 if (!vma) {
88316 - vm_unacct_memory(len >> PAGE_SHIFT);
88317 + vm_unacct_memory(charged);
88318 return -ENOMEM;
88319 }
88320
88321 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88322 vma_link(mm, vma, prev, rb_link, rb_parent);
88323 out:
88324 perf_event_mmap(vma);
88325 - mm->total_vm += len >> PAGE_SHIFT;
88326 + mm->total_vm += charged;
88327 if (flags & VM_LOCKED)
88328 - mm->locked_vm += (len >> PAGE_SHIFT);
88329 + mm->locked_vm += charged;
88330 + track_exec_limit(mm, addr, addr + len, flags);
88331 return addr;
88332 }
88333
88334 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88335 while (vma) {
88336 if (vma->vm_flags & VM_ACCOUNT)
88337 nr_accounted += vma_pages(vma);
88338 + vma->vm_mirror = NULL;
88339 vma = remove_vma(vma);
88340 }
88341 vm_unacct_memory(nr_accounted);
88342 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88343 struct vm_area_struct *prev;
88344 struct rb_node **rb_link, *rb_parent;
88345
88346 +#ifdef CONFIG_PAX_SEGMEXEC
88347 + struct vm_area_struct *vma_m = NULL;
88348 +#endif
88349 +
88350 + if (security_mmap_addr(vma->vm_start))
88351 + return -EPERM;
88352 +
88353 /*
88354 * The vm_pgoff of a purely anonymous vma should be irrelevant
88355 * until its first write fault, when page's anon_vma and index
88356 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88357 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88358 return -ENOMEM;
88359
88360 +#ifdef CONFIG_PAX_SEGMEXEC
88361 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88362 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88363 + if (!vma_m)
88364 + return -ENOMEM;
88365 + }
88366 +#endif
88367 +
88368 vma_link(mm, vma, prev, rb_link, rb_parent);
88369 +
88370 +#ifdef CONFIG_PAX_SEGMEXEC
88371 + if (vma_m)
88372 + BUG_ON(pax_mirror_vma(vma_m, vma));
88373 +#endif
88374 +
88375 return 0;
88376 }
88377
88378 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88379 struct mempolicy *pol;
88380 bool faulted_in_anon_vma = true;
88381
88382 + BUG_ON(vma->vm_mirror);
88383 +
88384 /*
88385 * If anonymous vma has not yet been faulted, update new pgoff
88386 * to match new location, to increase its chance of merging.
88387 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88388 return NULL;
88389 }
88390
88391 +#ifdef CONFIG_PAX_SEGMEXEC
88392 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88393 +{
88394 + struct vm_area_struct *prev_m;
88395 + struct rb_node **rb_link_m, *rb_parent_m;
88396 + struct mempolicy *pol_m;
88397 +
88398 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88399 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88400 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88401 + *vma_m = *vma;
88402 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88403 + if (anon_vma_clone(vma_m, vma))
88404 + return -ENOMEM;
88405 + pol_m = vma_policy(vma_m);
88406 + mpol_get(pol_m);
88407 + vma_set_policy(vma_m, pol_m);
88408 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88409 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88410 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88411 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88412 + if (vma_m->vm_file)
88413 + get_file(vma_m->vm_file);
88414 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88415 + vma_m->vm_ops->open(vma_m);
88416 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88417 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88418 + vma_m->vm_mirror = vma;
88419 + vma->vm_mirror = vma_m;
88420 + return 0;
88421 +}
88422 +#endif
88423 +
88424 /*
88425 * Return true if the calling process may expand its vm space by the passed
88426 * number of pages
88427 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88428
88429 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88430
88431 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88432 if (cur + npages > lim)
88433 return 0;
88434 return 1;
88435 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88436 vma->vm_start = addr;
88437 vma->vm_end = addr + len;
88438
88439 +#ifdef CONFIG_PAX_MPROTECT
88440 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88441 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88442 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88443 + return -EPERM;
88444 + if (!(vm_flags & VM_EXEC))
88445 + vm_flags &= ~VM_MAYEXEC;
88446 +#else
88447 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88448 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88449 +#endif
88450 + else
88451 + vm_flags &= ~VM_MAYWRITE;
88452 + }
88453 +#endif
88454 +
88455 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88456 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88457
88458 diff --git a/mm/mprotect.c b/mm/mprotect.c
88459 index 94722a4..e661e29 100644
88460 --- a/mm/mprotect.c
88461 +++ b/mm/mprotect.c
88462 @@ -23,10 +23,18 @@
88463 #include <linux/mmu_notifier.h>
88464 #include <linux/migrate.h>
88465 #include <linux/perf_event.h>
88466 +#include <linux/sched/sysctl.h>
88467 +
88468 +#ifdef CONFIG_PAX_MPROTECT
88469 +#include <linux/elf.h>
88470 +#include <linux/binfmts.h>
88471 +#endif
88472 +
88473 #include <asm/uaccess.h>
88474 #include <asm/pgtable.h>
88475 #include <asm/cacheflush.h>
88476 #include <asm/tlbflush.h>
88477 +#include <asm/mmu_context.h>
88478
88479 #ifndef pgprot_modify
88480 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88481 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88482 return pages;
88483 }
88484
88485 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88486 +/* called while holding the mmap semaphor for writing except stack expansion */
88487 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88488 +{
88489 + unsigned long oldlimit, newlimit = 0UL;
88490 +
88491 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88492 + return;
88493 +
88494 + spin_lock(&mm->page_table_lock);
88495 + oldlimit = mm->context.user_cs_limit;
88496 + if ((prot & VM_EXEC) && oldlimit < end)
88497 + /* USER_CS limit moved up */
88498 + newlimit = end;
88499 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88500 + /* USER_CS limit moved down */
88501 + newlimit = start;
88502 +
88503 + if (newlimit) {
88504 + mm->context.user_cs_limit = newlimit;
88505 +
88506 +#ifdef CONFIG_SMP
88507 + wmb();
88508 + cpus_clear(mm->context.cpu_user_cs_mask);
88509 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88510 +#endif
88511 +
88512 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88513 + }
88514 + spin_unlock(&mm->page_table_lock);
88515 + if (newlimit == end) {
88516 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88517 +
88518 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88519 + if (is_vm_hugetlb_page(vma))
88520 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88521 + else
88522 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88523 + }
88524 +}
88525 +#endif
88526 +
88527 int
88528 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88529 unsigned long start, unsigned long end, unsigned long newflags)
88530 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88531 int error;
88532 int dirty_accountable = 0;
88533
88534 +#ifdef CONFIG_PAX_SEGMEXEC
88535 + struct vm_area_struct *vma_m = NULL;
88536 + unsigned long start_m, end_m;
88537 +
88538 + start_m = start + SEGMEXEC_TASK_SIZE;
88539 + end_m = end + SEGMEXEC_TASK_SIZE;
88540 +#endif
88541 +
88542 if (newflags == oldflags) {
88543 *pprev = vma;
88544 return 0;
88545 }
88546
88547 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88548 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88549 +
88550 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88551 + return -ENOMEM;
88552 +
88553 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88554 + return -ENOMEM;
88555 + }
88556 +
88557 /*
88558 * If we make a private mapping writable we increase our commit;
88559 * but (without finer accounting) cannot reduce our commit if we
88560 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88561 }
88562 }
88563
88564 +#ifdef CONFIG_PAX_SEGMEXEC
88565 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88566 + if (start != vma->vm_start) {
88567 + error = split_vma(mm, vma, start, 1);
88568 + if (error)
88569 + goto fail;
88570 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88571 + *pprev = (*pprev)->vm_next;
88572 + }
88573 +
88574 + if (end != vma->vm_end) {
88575 + error = split_vma(mm, vma, end, 0);
88576 + if (error)
88577 + goto fail;
88578 + }
88579 +
88580 + if (pax_find_mirror_vma(vma)) {
88581 + error = __do_munmap(mm, start_m, end_m - start_m);
88582 + if (error)
88583 + goto fail;
88584 + } else {
88585 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88586 + if (!vma_m) {
88587 + error = -ENOMEM;
88588 + goto fail;
88589 + }
88590 + vma->vm_flags = newflags;
88591 + error = pax_mirror_vma(vma_m, vma);
88592 + if (error) {
88593 + vma->vm_flags = oldflags;
88594 + goto fail;
88595 + }
88596 + }
88597 + }
88598 +#endif
88599 +
88600 /*
88601 * First try to merge with previous and/or next vma.
88602 */
88603 @@ -296,9 +400,21 @@ success:
88604 * vm_flags and vm_page_prot are protected by the mmap_sem
88605 * held in write mode.
88606 */
88607 +
88608 +#ifdef CONFIG_PAX_SEGMEXEC
88609 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88610 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88611 +#endif
88612 +
88613 vma->vm_flags = newflags;
88614 +
88615 +#ifdef CONFIG_PAX_MPROTECT
88616 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88617 + mm->binfmt->handle_mprotect(vma, newflags);
88618 +#endif
88619 +
88620 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88621 - vm_get_page_prot(newflags));
88622 + vm_get_page_prot(vma->vm_flags));
88623
88624 if (vma_wants_writenotify(vma)) {
88625 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88626 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88627 end = start + len;
88628 if (end <= start)
88629 return -ENOMEM;
88630 +
88631 +#ifdef CONFIG_PAX_SEGMEXEC
88632 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88633 + if (end > SEGMEXEC_TASK_SIZE)
88634 + return -EINVAL;
88635 + } else
88636 +#endif
88637 +
88638 + if (end > TASK_SIZE)
88639 + return -EINVAL;
88640 +
88641 if (!arch_validate_prot(prot))
88642 return -EINVAL;
88643
88644 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88645 /*
88646 * Does the application expect PROT_READ to imply PROT_EXEC:
88647 */
88648 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88649 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88650 prot |= PROT_EXEC;
88651
88652 vm_flags = calc_vm_prot_bits(prot);
88653 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88654 if (start > vma->vm_start)
88655 prev = vma;
88656
88657 +#ifdef CONFIG_PAX_MPROTECT
88658 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88659 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88660 +#endif
88661 +
88662 for (nstart = start ; ; ) {
88663 unsigned long newflags;
88664
88665 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88666
88667 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88668 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88669 + if (prot & (PROT_WRITE | PROT_EXEC))
88670 + gr_log_rwxmprotect(vma);
88671 +
88672 + error = -EACCES;
88673 + goto out;
88674 + }
88675 +
88676 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88677 error = -EACCES;
88678 goto out;
88679 }
88680 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88681 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88682 if (error)
88683 goto out;
88684 +
88685 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88686 +
88687 nstart = tmp;
88688
88689 if (nstart < prev->vm_end)
88690 diff --git a/mm/mremap.c b/mm/mremap.c
88691 index 0843feb..5607f47 100644
88692 --- a/mm/mremap.c
88693 +++ b/mm/mremap.c
88694 @@ -25,6 +25,7 @@
88695 #include <asm/uaccess.h>
88696 #include <asm/cacheflush.h>
88697 #include <asm/tlbflush.h>
88698 +#include <asm/pgalloc.h>
88699
88700 #include "internal.h"
88701
88702 @@ -62,8 +63,10 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
88703 return NULL;
88704
88705 pmd = pmd_alloc(mm, pud, addr);
88706 - if (!pmd)
88707 + if (!pmd) {
88708 + pud_free(mm, pud);
88709 return NULL;
88710 + }
88711
88712 VM_BUG_ON(pmd_trans_huge(*pmd));
88713
88714 @@ -144,6 +147,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88715 continue;
88716 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88717 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88718 +
88719 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88720 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88721 + pte = pte_exprotect(pte);
88722 +#endif
88723 +
88724 pte = move_soft_dirty_pte(pte);
88725 set_pte_at(mm, new_addr, new_pte, pte);
88726 }
88727 @@ -337,6 +346,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88728 if (is_vm_hugetlb_page(vma))
88729 goto Einval;
88730
88731 +#ifdef CONFIG_PAX_SEGMEXEC
88732 + if (pax_find_mirror_vma(vma))
88733 + goto Einval;
88734 +#endif
88735 +
88736 /* We can't remap across vm area boundaries */
88737 if (old_len > vma->vm_end - addr)
88738 goto Efault;
88739 @@ -392,20 +406,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88740 unsigned long ret = -EINVAL;
88741 unsigned long charged = 0;
88742 unsigned long map_flags;
88743 + unsigned long pax_task_size = TASK_SIZE;
88744
88745 if (new_addr & ~PAGE_MASK)
88746 goto out;
88747
88748 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88749 +#ifdef CONFIG_PAX_SEGMEXEC
88750 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88751 + pax_task_size = SEGMEXEC_TASK_SIZE;
88752 +#endif
88753 +
88754 + pax_task_size -= PAGE_SIZE;
88755 +
88756 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88757 goto out;
88758
88759 /* Check if the location we're moving into overlaps the
88760 * old location at all, and fail if it does.
88761 */
88762 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88763 - goto out;
88764 -
88765 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88766 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88767 goto out;
88768
88769 ret = do_munmap(mm, new_addr, new_len);
88770 @@ -474,6 +493,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88771 unsigned long ret = -EINVAL;
88772 unsigned long charged = 0;
88773 bool locked = false;
88774 + unsigned long pax_task_size = TASK_SIZE;
88775
88776 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88777 return ret;
88778 @@ -495,6 +515,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88779 if (!new_len)
88780 return ret;
88781
88782 +#ifdef CONFIG_PAX_SEGMEXEC
88783 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88784 + pax_task_size = SEGMEXEC_TASK_SIZE;
88785 +#endif
88786 +
88787 + pax_task_size -= PAGE_SIZE;
88788 +
88789 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88790 + old_len > pax_task_size || addr > pax_task_size-old_len)
88791 + return ret;
88792 +
88793 down_write(&current->mm->mmap_sem);
88794
88795 if (flags & MREMAP_FIXED) {
88796 @@ -545,6 +576,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88797 new_addr = addr;
88798 }
88799 ret = addr;
88800 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88801 goto out;
88802 }
88803 }
88804 @@ -568,7 +600,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88805 goto out;
88806 }
88807
88808 + map_flags = vma->vm_flags;
88809 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88810 + if (!(ret & ~PAGE_MASK)) {
88811 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88812 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88813 + }
88814 }
88815 out:
88816 if (ret & ~PAGE_MASK)
88817 diff --git a/mm/nommu.c b/mm/nommu.c
88818 index ecd1f15..77039bd 100644
88819 --- a/mm/nommu.c
88820 +++ b/mm/nommu.c
88821 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88822 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88823 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88824 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88825 -int heap_stack_gap = 0;
88826
88827 atomic_long_t mmap_pages_allocated;
88828
88829 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88830 EXPORT_SYMBOL(find_vma);
88831
88832 /*
88833 - * find a VMA
88834 - * - we don't extend stack VMAs under NOMMU conditions
88835 - */
88836 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88837 -{
88838 - return find_vma(mm, addr);
88839 -}
88840 -
88841 -/*
88842 * expand a stack to a given address
88843 * - not supported under NOMMU conditions
88844 */
88845 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88846
88847 /* most fields are the same, copy all, and then fixup */
88848 *new = *vma;
88849 + INIT_LIST_HEAD(&new->anon_vma_chain);
88850 *region = *vma->vm_region;
88851 new->vm_region = region;
88852
88853 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88854 }
88855 EXPORT_SYMBOL(generic_file_remap_pages);
88856
88857 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88858 - unsigned long addr, void *buf, int len, int write)
88859 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88860 + unsigned long addr, void *buf, size_t len, int write)
88861 {
88862 struct vm_area_struct *vma;
88863
88864 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88865 *
88866 * The caller must hold a reference on @mm.
88867 */
88868 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88869 - void *buf, int len, int write)
88870 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88871 + void *buf, size_t len, int write)
88872 {
88873 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88874 }
88875 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88876 * Access another process' address space.
88877 * - source/target buffer must be kernel space
88878 */
88879 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88880 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
88881 {
88882 struct mm_struct *mm;
88883
88884 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
88885 index 3f0c895..60cd104 100644
88886 --- a/mm/page-writeback.c
88887 +++ b/mm/page-writeback.c
88888 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
88889 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
88890 * - the bdi dirty thresh drops quickly due to change of JBOD workload
88891 */
88892 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
88893 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
88894 unsigned long thresh,
88895 unsigned long bg_thresh,
88896 unsigned long dirty,
88897 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
88898 index b100255..fba1254 100644
88899 --- a/mm/page_alloc.c
88900 +++ b/mm/page_alloc.c
88901 @@ -60,6 +60,7 @@
88902 #include <linux/page-debug-flags.h>
88903 #include <linux/hugetlb.h>
88904 #include <linux/sched/rt.h>
88905 +#include <linux/random.h>
88906
88907 #include <asm/sections.h>
88908 #include <asm/tlbflush.h>
88909 @@ -353,7 +354,7 @@ out:
88910 * This usage means that zero-order pages may not be compound.
88911 */
88912
88913 -static void free_compound_page(struct page *page)
88914 +void free_compound_page(struct page *page)
88915 {
88916 __free_pages_ok(page, compound_order(page));
88917 }
88918 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88919 int i;
88920 int bad = 0;
88921
88922 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88923 + unsigned long index = 1UL << order;
88924 +#endif
88925 +
88926 trace_mm_page_free(page, order);
88927 kmemcheck_free_shadow(page, order);
88928
88929 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88930 debug_check_no_obj_freed(page_address(page),
88931 PAGE_SIZE << order);
88932 }
88933 +
88934 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88935 + for (; index; --index)
88936 + sanitize_highpage(page + index - 1);
88937 +#endif
88938 +
88939 arch_free_page(page, order);
88940 kernel_map_pages(page, 1 << order, 0);
88941
88942 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
88943 local_irq_restore(flags);
88944 }
88945
88946 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88947 +bool __meminitdata extra_latent_entropy;
88948 +
88949 +static int __init setup_pax_extra_latent_entropy(char *str)
88950 +{
88951 + extra_latent_entropy = true;
88952 + return 0;
88953 +}
88954 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
88955 +
88956 +volatile u64 latent_entropy;
88957 +EXPORT_SYMBOL(latent_entropy);
88958 +#endif
88959 +
88960 void __init __free_pages_bootmem(struct page *page, unsigned int order)
88961 {
88962 unsigned int nr_pages = 1 << order;
88963 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
88964 set_page_count(p, 0);
88965 }
88966
88967 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88968 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
88969 + u64 hash = 0;
88970 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
88971 + const u64 *data = lowmem_page_address(page);
88972 +
88973 + for (index = 0; index < end; index++)
88974 + hash ^= hash + data[index];
88975 + latent_entropy ^= hash;
88976 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
88977 + }
88978 +#endif
88979 +
88980 page_zone(page)->managed_pages += 1 << order;
88981 set_page_refcounted(page);
88982 __free_pages(page, order);
88983 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
88984 arch_alloc_page(page, order);
88985 kernel_map_pages(page, 1 << order, 1);
88986
88987 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
88988 if (gfp_flags & __GFP_ZERO)
88989 prep_zero_page(page, order, gfp_flags);
88990 +#endif
88991
88992 if (order && (gfp_flags & __GFP_COMP))
88993 prep_compound_page(page, order);
88994 diff --git a/mm/page_io.c b/mm/page_io.c
88995 index ba05b64..ef2f314 100644
88996 --- a/mm/page_io.c
88997 +++ b/mm/page_io.c
88998 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
88999 struct file *swap_file = sis->swap_file;
89000 struct address_space *mapping = swap_file->f_mapping;
89001 struct iovec iov = {
89002 - .iov_base = kmap(page),
89003 + .iov_base = (void __force_user *)kmap(page),
89004 .iov_len = PAGE_SIZE,
89005 };
89006
89007 diff --git a/mm/percpu.c b/mm/percpu.c
89008 index 8c8e08f..73a5cda 100644
89009 --- a/mm/percpu.c
89010 +++ b/mm/percpu.c
89011 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89012 static unsigned int pcpu_high_unit_cpu __read_mostly;
89013
89014 /* the address of the first chunk which starts with the kernel static area */
89015 -void *pcpu_base_addr __read_mostly;
89016 +void *pcpu_base_addr __read_only;
89017 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89018
89019 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89020 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89021 index fd26d04..0cea1b0 100644
89022 --- a/mm/process_vm_access.c
89023 +++ b/mm/process_vm_access.c
89024 @@ -13,6 +13,7 @@
89025 #include <linux/uio.h>
89026 #include <linux/sched.h>
89027 #include <linux/highmem.h>
89028 +#include <linux/security.h>
89029 #include <linux/ptrace.h>
89030 #include <linux/slab.h>
89031 #include <linux/syscalls.h>
89032 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89033 size_t iov_l_curr_offset = 0;
89034 ssize_t iov_len;
89035
89036 + return -ENOSYS; // PaX: until properly audited
89037 +
89038 /*
89039 * Work out how many pages of struct pages we're going to need
89040 * when eventually calling get_user_pages
89041 */
89042 for (i = 0; i < riovcnt; i++) {
89043 iov_len = rvec[i].iov_len;
89044 - if (iov_len > 0) {
89045 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89046 - + iov_len)
89047 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89048 - / PAGE_SIZE + 1;
89049 - nr_pages = max(nr_pages, nr_pages_iov);
89050 - }
89051 + if (iov_len <= 0)
89052 + continue;
89053 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89054 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89055 + nr_pages = max(nr_pages, nr_pages_iov);
89056 }
89057
89058 if (nr_pages == 0)
89059 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89060 goto free_proc_pages;
89061 }
89062
89063 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89064 + rc = -EPERM;
89065 + goto put_task_struct;
89066 + }
89067 +
89068 mm = mm_access(task, PTRACE_MODE_ATTACH);
89069 if (!mm || IS_ERR(mm)) {
89070 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89071 diff --git a/mm/rmap.c b/mm/rmap.c
89072 index b2e29ac..4168491 100644
89073 --- a/mm/rmap.c
89074 +++ b/mm/rmap.c
89075 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89076 struct anon_vma *anon_vma = vma->anon_vma;
89077 struct anon_vma_chain *avc;
89078
89079 +#ifdef CONFIG_PAX_SEGMEXEC
89080 + struct anon_vma_chain *avc_m = NULL;
89081 +#endif
89082 +
89083 might_sleep();
89084 if (unlikely(!anon_vma)) {
89085 struct mm_struct *mm = vma->vm_mm;
89086 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89087 if (!avc)
89088 goto out_enomem;
89089
89090 +#ifdef CONFIG_PAX_SEGMEXEC
89091 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89092 + if (!avc_m)
89093 + goto out_enomem_free_avc;
89094 +#endif
89095 +
89096 anon_vma = find_mergeable_anon_vma(vma);
89097 allocated = NULL;
89098 if (!anon_vma) {
89099 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89100 /* page_table_lock to protect against threads */
89101 spin_lock(&mm->page_table_lock);
89102 if (likely(!vma->anon_vma)) {
89103 +
89104 +#ifdef CONFIG_PAX_SEGMEXEC
89105 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89106 +
89107 + if (vma_m) {
89108 + BUG_ON(vma_m->anon_vma);
89109 + vma_m->anon_vma = anon_vma;
89110 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89111 + avc_m = NULL;
89112 + }
89113 +#endif
89114 +
89115 vma->anon_vma = anon_vma;
89116 anon_vma_chain_link(vma, avc, anon_vma);
89117 allocated = NULL;
89118 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89119
89120 if (unlikely(allocated))
89121 put_anon_vma(allocated);
89122 +
89123 +#ifdef CONFIG_PAX_SEGMEXEC
89124 + if (unlikely(avc_m))
89125 + anon_vma_chain_free(avc_m);
89126 +#endif
89127 +
89128 if (unlikely(avc))
89129 anon_vma_chain_free(avc);
89130 }
89131 return 0;
89132
89133 out_enomem_free_avc:
89134 +
89135 +#ifdef CONFIG_PAX_SEGMEXEC
89136 + if (avc_m)
89137 + anon_vma_chain_free(avc_m);
89138 +#endif
89139 +
89140 anon_vma_chain_free(avc);
89141 out_enomem:
89142 return -ENOMEM;
89143 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89144 * Attach the anon_vmas from src to dst.
89145 * Returns 0 on success, -ENOMEM on failure.
89146 */
89147 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89148 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89149 {
89150 struct anon_vma_chain *avc, *pavc;
89151 struct anon_vma *root = NULL;
89152 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89153 * the corresponding VMA in the parent process is attached to.
89154 * Returns 0 on success, non-zero on failure.
89155 */
89156 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89157 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89158 {
89159 struct anon_vma_chain *avc;
89160 struct anon_vma *anon_vma;
89161 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89162 void __init anon_vma_init(void)
89163 {
89164 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89165 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89166 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89167 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89168 + anon_vma_ctor);
89169 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89170 + SLAB_PANIC|SLAB_NO_SANITIZE);
89171 }
89172
89173 /*
89174 diff --git a/mm/shmem.c b/mm/shmem.c
89175 index e43dc55..930e3a2 100644
89176 --- a/mm/shmem.c
89177 +++ b/mm/shmem.c
89178 @@ -33,7 +33,7 @@
89179 #include <linux/swap.h>
89180 #include <linux/aio.h>
89181
89182 -static struct vfsmount *shm_mnt;
89183 +struct vfsmount *shm_mnt;
89184
89185 #ifdef CONFIG_SHMEM
89186 /*
89187 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89188 #define BOGO_DIRENT_SIZE 20
89189
89190 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89191 -#define SHORT_SYMLINK_LEN 128
89192 +#define SHORT_SYMLINK_LEN 64
89193
89194 /*
89195 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89196 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89197 static int shmem_xattr_validate(const char *name)
89198 {
89199 struct { const char *prefix; size_t len; } arr[] = {
89200 +
89201 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89202 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89203 +#endif
89204 +
89205 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89206 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89207 };
89208 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89209 if (err)
89210 return err;
89211
89212 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89213 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89214 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89215 + return -EOPNOTSUPP;
89216 + if (size > 8)
89217 + return -EINVAL;
89218 + }
89219 +#endif
89220 +
89221 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89222 }
89223
89224 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89225 int err = -ENOMEM;
89226
89227 /* Round up to L1_CACHE_BYTES to resist false sharing */
89228 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89229 - L1_CACHE_BYTES), GFP_KERNEL);
89230 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89231 if (!sbinfo)
89232 return -ENOMEM;
89233
89234 diff --git a/mm/slab.c b/mm/slab.c
89235 index 2580db0..0523956 100644
89236 --- a/mm/slab.c
89237 +++ b/mm/slab.c
89238 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89239 if ((x)->max_freeable < i) \
89240 (x)->max_freeable = i; \
89241 } while (0)
89242 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89243 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89244 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89245 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89246 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89247 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89248 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89249 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89250 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89251 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89252 #else
89253 #define STATS_INC_ACTIVE(x) do { } while (0)
89254 #define STATS_DEC_ACTIVE(x) do { } while (0)
89255 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89256 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89257 #define STATS_INC_FREEHIT(x) do { } while (0)
89258 #define STATS_INC_FREEMISS(x) do { } while (0)
89259 +#define STATS_INC_SANITIZED(x) do { } while (0)
89260 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89261 #endif
89262
89263 #if DEBUG
89264 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89265 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89266 */
89267 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89268 - const struct slab *slab, void *obj)
89269 + const struct slab *slab, const void *obj)
89270 {
89271 u32 offset = (obj - slab->s_mem);
89272 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89273 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89274 */
89275
89276 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89277 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89278 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89279
89280 if (INDEX_AC != INDEX_NODE)
89281 kmalloc_caches[INDEX_NODE] =
89282 create_kmalloc_cache("kmalloc-node",
89283 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89284 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89285
89286 slab_early_init = 0;
89287
89288 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89289 struct array_cache *ac = cpu_cache_get(cachep);
89290
89291 check_irq_off();
89292 +
89293 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89294 + if (pax_sanitize_slab) {
89295 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89296 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89297 +
89298 + if (cachep->ctor)
89299 + cachep->ctor(objp);
89300 +
89301 + STATS_INC_SANITIZED(cachep);
89302 + } else
89303 + STATS_INC_NOT_SANITIZED(cachep);
89304 + }
89305 +#endif
89306 +
89307 kmemleak_free_recursive(objp, cachep->flags);
89308 objp = cache_free_debugcheck(cachep, objp, caller);
89309
89310 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89311
89312 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89313 return;
89314 + VM_BUG_ON(!virt_addr_valid(objp));
89315 local_irq_save(flags);
89316 kfree_debugcheck(objp);
89317 c = virt_to_cache(objp);
89318 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89319 }
89320 /* cpu stats */
89321 {
89322 - unsigned long allochit = atomic_read(&cachep->allochit);
89323 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89324 - unsigned long freehit = atomic_read(&cachep->freehit);
89325 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89326 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89327 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89328 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89329 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89330
89331 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89332 allochit, allocmiss, freehit, freemiss);
89333 }
89334 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89335 + {
89336 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89337 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89338 +
89339 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89340 + }
89341 +#endif
89342 #endif
89343 }
89344
89345 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89346 static int __init slab_proc_init(void)
89347 {
89348 #ifdef CONFIG_DEBUG_SLAB_LEAK
89349 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89350 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89351 #endif
89352 return 0;
89353 }
89354 module_init(slab_proc_init);
89355 #endif
89356
89357 +bool is_usercopy_object(const void *ptr)
89358 +{
89359 + struct page *page;
89360 + struct kmem_cache *cachep;
89361 +
89362 + if (ZERO_OR_NULL_PTR(ptr))
89363 + return false;
89364 +
89365 + if (!slab_is_available())
89366 + return false;
89367 +
89368 + if (!virt_addr_valid(ptr))
89369 + return false;
89370 +
89371 + page = virt_to_head_page(ptr);
89372 +
89373 + if (!PageSlab(page))
89374 + return false;
89375 +
89376 + cachep = page->slab_cache;
89377 + return cachep->flags & SLAB_USERCOPY;
89378 +}
89379 +
89380 +#ifdef CONFIG_PAX_USERCOPY
89381 +const char *check_heap_object(const void *ptr, unsigned long n)
89382 +{
89383 + struct page *page;
89384 + struct kmem_cache *cachep;
89385 + struct slab *slabp;
89386 + unsigned int objnr;
89387 + unsigned long offset;
89388 +
89389 + if (ZERO_OR_NULL_PTR(ptr))
89390 + return "<null>";
89391 +
89392 + if (!virt_addr_valid(ptr))
89393 + return NULL;
89394 +
89395 + page = virt_to_head_page(ptr);
89396 +
89397 + if (!PageSlab(page))
89398 + return NULL;
89399 +
89400 + cachep = page->slab_cache;
89401 + if (!(cachep->flags & SLAB_USERCOPY))
89402 + return cachep->name;
89403 +
89404 + slabp = page->slab_page;
89405 + objnr = obj_to_index(cachep, slabp, ptr);
89406 + BUG_ON(objnr >= cachep->num);
89407 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89408 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89409 + return NULL;
89410 +
89411 + return cachep->name;
89412 +}
89413 +#endif
89414 +
89415 /**
89416 * ksize - get the actual amount of memory allocated for a given object
89417 * @objp: Pointer to the object
89418 diff --git a/mm/slab.h b/mm/slab.h
89419 index a535033..2f98fe5 100644
89420 --- a/mm/slab.h
89421 +++ b/mm/slab.h
89422 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89423 /* The slab cache that manages slab cache information */
89424 extern struct kmem_cache *kmem_cache;
89425
89426 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89427 +#ifdef CONFIG_X86_64
89428 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89429 +#else
89430 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89431 +#endif
89432 +extern bool pax_sanitize_slab;
89433 +#endif
89434 +
89435 unsigned long calculate_alignment(unsigned long flags,
89436 unsigned long align, unsigned long size);
89437
89438 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89439
89440 /* Legal flag mask for kmem_cache_create(), for various configurations */
89441 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89442 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89443 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89444 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89445
89446 #if defined(CONFIG_DEBUG_SLAB)
89447 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89448 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89449 return s;
89450
89451 page = virt_to_head_page(x);
89452 +
89453 + BUG_ON(!PageSlab(page));
89454 +
89455 cachep = page->slab_cache;
89456 if (slab_equal_or_root(cachep, s))
89457 return cachep;
89458 diff --git a/mm/slab_common.c b/mm/slab_common.c
89459 index 538bade..36fed99 100644
89460 --- a/mm/slab_common.c
89461 +++ b/mm/slab_common.c
89462 @@ -22,11 +22,22 @@
89463
89464 #include "slab.h"
89465
89466 -enum slab_state slab_state;
89467 +enum slab_state slab_state __read_only;
89468 LIST_HEAD(slab_caches);
89469 DEFINE_MUTEX(slab_mutex);
89470 struct kmem_cache *kmem_cache;
89471
89472 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89473 +bool pax_sanitize_slab __read_only = true;
89474 +static int __init pax_sanitize_slab_setup(char *str)
89475 +{
89476 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89477 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89478 + return 1;
89479 +}
89480 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89481 +#endif
89482 +
89483 #ifdef CONFIG_DEBUG_VM
89484 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89485 size_t size)
89486 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89487
89488 err = __kmem_cache_create(s, flags);
89489 if (!err) {
89490 - s->refcount = 1;
89491 + atomic_set(&s->refcount, 1);
89492 list_add(&s->list, &slab_caches);
89493 memcg_cache_list_add(memcg, s);
89494 } else {
89495 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89496
89497 get_online_cpus();
89498 mutex_lock(&slab_mutex);
89499 - s->refcount--;
89500 - if (!s->refcount) {
89501 + if (atomic_dec_and_test(&s->refcount)) {
89502 list_del(&s->list);
89503
89504 if (!__kmem_cache_shutdown(s)) {
89505 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89506 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89507 name, size, err);
89508
89509 - s->refcount = -1; /* Exempt from merging for now */
89510 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89511 }
89512
89513 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89514 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89515
89516 create_boot_cache(s, name, size, flags);
89517 list_add(&s->list, &slab_caches);
89518 - s->refcount = 1;
89519 + atomic_set(&s->refcount, 1);
89520 return s;
89521 }
89522
89523 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89524 EXPORT_SYMBOL(kmalloc_dma_caches);
89525 #endif
89526
89527 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89528 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89529 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89530 +#endif
89531 +
89532 /*
89533 * Conversion table for small slabs sizes / 8 to the index in the
89534 * kmalloc array. This is necessary for slabs < 192 since we have non power
89535 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89536 return kmalloc_dma_caches[index];
89537
89538 #endif
89539 +
89540 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89541 + if (unlikely((flags & GFP_USERCOPY)))
89542 + return kmalloc_usercopy_caches[index];
89543 +
89544 +#endif
89545 +
89546 return kmalloc_caches[index];
89547 }
89548
89549 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89550 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89551 if (!kmalloc_caches[i]) {
89552 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89553 - 1 << i, flags);
89554 + 1 << i, SLAB_USERCOPY | flags);
89555 }
89556
89557 /*
89558 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89559 * earlier power of two caches
89560 */
89561 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89562 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89563 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89564
89565 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89566 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89567 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89568 }
89569
89570 /* Kmalloc array is now usable */
89571 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89572 }
89573 }
89574 #endif
89575 +
89576 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89577 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89578 + struct kmem_cache *s = kmalloc_caches[i];
89579 +
89580 + if (s) {
89581 + int size = kmalloc_size(i);
89582 + char *n = kasprintf(GFP_NOWAIT,
89583 + "usercopy-kmalloc-%d", size);
89584 +
89585 + BUG_ON(!n);
89586 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89587 + size, SLAB_USERCOPY | flags);
89588 + }
89589 + }
89590 +#endif
89591 +
89592 }
89593 #endif /* !CONFIG_SLOB */
89594
89595 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89596 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89597 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89598 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89599 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89600 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89601 +#endif
89602 #endif
89603 seq_putc(m, '\n');
89604 }
89605 diff --git a/mm/slob.c b/mm/slob.c
89606 index 91bd3f2..e2f549e 100644
89607 --- a/mm/slob.c
89608 +++ b/mm/slob.c
89609 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89610 /*
89611 * Return the size of a slob block.
89612 */
89613 -static slobidx_t slob_units(slob_t *s)
89614 +static slobidx_t slob_units(const slob_t *s)
89615 {
89616 if (s->units > 0)
89617 return s->units;
89618 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89619 /*
89620 * Return the next free slob block pointer after this one.
89621 */
89622 -static slob_t *slob_next(slob_t *s)
89623 +static slob_t *slob_next(const slob_t *s)
89624 {
89625 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89626 slobidx_t next;
89627 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89628 /*
89629 * Returns true if s is the last free block in its page.
89630 */
89631 -static int slob_last(slob_t *s)
89632 +static int slob_last(const slob_t *s)
89633 {
89634 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89635 }
89636
89637 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89638 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89639 {
89640 - void *page;
89641 + struct page *page;
89642
89643 #ifdef CONFIG_NUMA
89644 if (node != NUMA_NO_NODE)
89645 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89646 if (!page)
89647 return NULL;
89648
89649 - return page_address(page);
89650 + __SetPageSlab(page);
89651 + return page;
89652 }
89653
89654 -static void slob_free_pages(void *b, int order)
89655 +static void slob_free_pages(struct page *sp, int order)
89656 {
89657 if (current->reclaim_state)
89658 current->reclaim_state->reclaimed_slab += 1 << order;
89659 - free_pages((unsigned long)b, order);
89660 + __ClearPageSlab(sp);
89661 + page_mapcount_reset(sp);
89662 + sp->private = 0;
89663 + __free_pages(sp, order);
89664 }
89665
89666 /*
89667 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89668
89669 /* Not enough space: must allocate a new page */
89670 if (!b) {
89671 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89672 - if (!b)
89673 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89674 + if (!sp)
89675 return NULL;
89676 - sp = virt_to_page(b);
89677 - __SetPageSlab(sp);
89678 + b = page_address(sp);
89679
89680 spin_lock_irqsave(&slob_lock, flags);
89681 sp->units = SLOB_UNITS(PAGE_SIZE);
89682 sp->freelist = b;
89683 + sp->private = 0;
89684 INIT_LIST_HEAD(&sp->list);
89685 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89686 set_slob_page_free(sp, slob_list);
89687 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89688 if (slob_page_free(sp))
89689 clear_slob_page_free(sp);
89690 spin_unlock_irqrestore(&slob_lock, flags);
89691 - __ClearPageSlab(sp);
89692 - page_mapcount_reset(sp);
89693 - slob_free_pages(b, 0);
89694 + slob_free_pages(sp, 0);
89695 return;
89696 }
89697
89698 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89699 + if (pax_sanitize_slab)
89700 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89701 +#endif
89702 +
89703 if (!slob_page_free(sp)) {
89704 /* This slob page is about to become partially free. Easy! */
89705 sp->units = units;
89706 @@ -424,11 +431,10 @@ out:
89707 */
89708
89709 static __always_inline void *
89710 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89711 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89712 {
89713 - unsigned int *m;
89714 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89715 - void *ret;
89716 + slob_t *m;
89717 + void *ret = NULL;
89718
89719 gfp &= gfp_allowed_mask;
89720
89721 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89722
89723 if (!m)
89724 return NULL;
89725 - *m = size;
89726 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89727 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89728 + m[0].units = size;
89729 + m[1].units = align;
89730 ret = (void *)m + align;
89731
89732 trace_kmalloc_node(caller, ret,
89733 size, size + align, gfp, node);
89734 } else {
89735 unsigned int order = get_order(size);
89736 + struct page *page;
89737
89738 if (likely(order))
89739 gfp |= __GFP_COMP;
89740 - ret = slob_new_pages(gfp, order, node);
89741 + page = slob_new_pages(gfp, order, node);
89742 + if (page) {
89743 + ret = page_address(page);
89744 + page->private = size;
89745 + }
89746
89747 trace_kmalloc_node(caller, ret,
89748 size, PAGE_SIZE << order, gfp, node);
89749 }
89750
89751 - kmemleak_alloc(ret, size, 1, gfp);
89752 + return ret;
89753 +}
89754 +
89755 +static __always_inline void *
89756 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89757 +{
89758 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89759 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89760 +
89761 + if (!ZERO_OR_NULL_PTR(ret))
89762 + kmemleak_alloc(ret, size, 1, gfp);
89763 return ret;
89764 }
89765
89766 @@ -493,34 +517,112 @@ void kfree(const void *block)
89767 return;
89768 kmemleak_free(block);
89769
89770 + VM_BUG_ON(!virt_addr_valid(block));
89771 sp = virt_to_page(block);
89772 - if (PageSlab(sp)) {
89773 + VM_BUG_ON(!PageSlab(sp));
89774 + if (!sp->private) {
89775 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89776 - unsigned int *m = (unsigned int *)(block - align);
89777 - slob_free(m, *m + align);
89778 - } else
89779 + slob_t *m = (slob_t *)(block - align);
89780 + slob_free(m, m[0].units + align);
89781 + } else {
89782 + __ClearPageSlab(sp);
89783 + page_mapcount_reset(sp);
89784 + sp->private = 0;
89785 __free_pages(sp, compound_order(sp));
89786 + }
89787 }
89788 EXPORT_SYMBOL(kfree);
89789
89790 +bool is_usercopy_object(const void *ptr)
89791 +{
89792 + if (!slab_is_available())
89793 + return false;
89794 +
89795 + // PAX: TODO
89796 +
89797 + return false;
89798 +}
89799 +
89800 +#ifdef CONFIG_PAX_USERCOPY
89801 +const char *check_heap_object(const void *ptr, unsigned long n)
89802 +{
89803 + struct page *page;
89804 + const slob_t *free;
89805 + const void *base;
89806 + unsigned long flags;
89807 +
89808 + if (ZERO_OR_NULL_PTR(ptr))
89809 + return "<null>";
89810 +
89811 + if (!virt_addr_valid(ptr))
89812 + return NULL;
89813 +
89814 + page = virt_to_head_page(ptr);
89815 + if (!PageSlab(page))
89816 + return NULL;
89817 +
89818 + if (page->private) {
89819 + base = page;
89820 + if (base <= ptr && n <= page->private - (ptr - base))
89821 + return NULL;
89822 + return "<slob>";
89823 + }
89824 +
89825 + /* some tricky double walking to find the chunk */
89826 + spin_lock_irqsave(&slob_lock, flags);
89827 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89828 + free = page->freelist;
89829 +
89830 + while (!slob_last(free) && (void *)free <= ptr) {
89831 + base = free + slob_units(free);
89832 + free = slob_next(free);
89833 + }
89834 +
89835 + while (base < (void *)free) {
89836 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89837 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89838 + int offset;
89839 +
89840 + if (ptr < base + align)
89841 + break;
89842 +
89843 + offset = ptr - base - align;
89844 + if (offset >= m) {
89845 + base += size;
89846 + continue;
89847 + }
89848 +
89849 + if (n > m - offset)
89850 + break;
89851 +
89852 + spin_unlock_irqrestore(&slob_lock, flags);
89853 + return NULL;
89854 + }
89855 +
89856 + spin_unlock_irqrestore(&slob_lock, flags);
89857 + return "<slob>";
89858 +}
89859 +#endif
89860 +
89861 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89862 size_t ksize(const void *block)
89863 {
89864 struct page *sp;
89865 int align;
89866 - unsigned int *m;
89867 + slob_t *m;
89868
89869 BUG_ON(!block);
89870 if (unlikely(block == ZERO_SIZE_PTR))
89871 return 0;
89872
89873 sp = virt_to_page(block);
89874 - if (unlikely(!PageSlab(sp)))
89875 - return PAGE_SIZE << compound_order(sp);
89876 + VM_BUG_ON(!PageSlab(sp));
89877 + if (sp->private)
89878 + return sp->private;
89879
89880 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89881 - m = (unsigned int *)(block - align);
89882 - return SLOB_UNITS(*m) * SLOB_UNIT;
89883 + m = (slob_t *)(block - align);
89884 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
89885 }
89886 EXPORT_SYMBOL(ksize);
89887
89888 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
89889
89890 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
89891 {
89892 - void *b;
89893 + void *b = NULL;
89894
89895 flags &= gfp_allowed_mask;
89896
89897 lockdep_trace_alloc(flags);
89898
89899 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89900 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
89901 +#else
89902 if (c->size < PAGE_SIZE) {
89903 b = slob_alloc(c->size, flags, c->align, node);
89904 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89905 SLOB_UNITS(c->size) * SLOB_UNIT,
89906 flags, node);
89907 } else {
89908 - b = slob_new_pages(flags, get_order(c->size), node);
89909 + struct page *sp;
89910 +
89911 + sp = slob_new_pages(flags, get_order(c->size), node);
89912 + if (sp) {
89913 + b = page_address(sp);
89914 + sp->private = c->size;
89915 + }
89916 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89917 PAGE_SIZE << get_order(c->size),
89918 flags, node);
89919 }
89920 +#endif
89921
89922 if (b && c->ctor)
89923 c->ctor(b);
89924 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
89925
89926 static void __kmem_cache_free(void *b, int size)
89927 {
89928 - if (size < PAGE_SIZE)
89929 + struct page *sp;
89930 +
89931 + sp = virt_to_page(b);
89932 + BUG_ON(!PageSlab(sp));
89933 + if (!sp->private)
89934 slob_free(b, size);
89935 else
89936 - slob_free_pages(b, get_order(size));
89937 + slob_free_pages(sp, get_order(size));
89938 }
89939
89940 static void kmem_rcu_free(struct rcu_head *head)
89941 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
89942
89943 void kmem_cache_free(struct kmem_cache *c, void *b)
89944 {
89945 + int size = c->size;
89946 +
89947 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89948 + if (size + c->align < PAGE_SIZE) {
89949 + size += c->align;
89950 + b -= c->align;
89951 + }
89952 +#endif
89953 +
89954 kmemleak_free_recursive(b, c->flags);
89955 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
89956 struct slob_rcu *slob_rcu;
89957 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
89958 - slob_rcu->size = c->size;
89959 + slob_rcu = b + (size - sizeof(struct slob_rcu));
89960 + slob_rcu->size = size;
89961 call_rcu(&slob_rcu->head, kmem_rcu_free);
89962 } else {
89963 - __kmem_cache_free(b, c->size);
89964 + __kmem_cache_free(b, size);
89965 }
89966
89967 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89968 + trace_kfree(_RET_IP_, b);
89969 +#else
89970 trace_kmem_cache_free(_RET_IP_, b);
89971 +#endif
89972 +
89973 }
89974 EXPORT_SYMBOL(kmem_cache_free);
89975
89976 diff --git a/mm/slub.c b/mm/slub.c
89977 index e3ba1f2..bd45dac 100644
89978 --- a/mm/slub.c
89979 +++ b/mm/slub.c
89980 @@ -207,7 +207,7 @@ struct track {
89981
89982 enum track_item { TRACK_ALLOC, TRACK_FREE };
89983
89984 -#ifdef CONFIG_SYSFS
89985 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89986 static int sysfs_slab_add(struct kmem_cache *);
89987 static int sysfs_slab_alias(struct kmem_cache *, const char *);
89988 static void sysfs_slab_remove(struct kmem_cache *);
89989 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
89990 if (!t->addr)
89991 return;
89992
89993 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
89994 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
89995 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
89996 #ifdef CONFIG_STACKTRACE
89997 {
89998 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
89999
90000 slab_free_hook(s, x);
90001
90002 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90003 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90004 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90005 + if (s->ctor)
90006 + s->ctor(x);
90007 + }
90008 +#endif
90009 +
90010 redo:
90011 /*
90012 * Determine the currently cpus per cpu slab.
90013 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90014 * Merge control. If this is set then no merging of slab caches will occur.
90015 * (Could be removed. This was introduced to pacify the merge skeptics.)
90016 */
90017 -static int slub_nomerge;
90018 +static int slub_nomerge = 1;
90019
90020 /*
90021 * Calculate the order of allocation given an slab object size.
90022 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90023 s->inuse = size;
90024
90025 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90026 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90027 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90028 +#endif
90029 s->ctor)) {
90030 /*
90031 * Relocate free pointer after the object if it is not
90032 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90033 EXPORT_SYMBOL(__kmalloc_node);
90034 #endif
90035
90036 +bool is_usercopy_object(const void *ptr)
90037 +{
90038 + struct page *page;
90039 + struct kmem_cache *s;
90040 +
90041 + if (ZERO_OR_NULL_PTR(ptr))
90042 + return false;
90043 +
90044 + if (!slab_is_available())
90045 + return false;
90046 +
90047 + if (!virt_addr_valid(ptr))
90048 + return false;
90049 +
90050 + page = virt_to_head_page(ptr);
90051 +
90052 + if (!PageSlab(page))
90053 + return false;
90054 +
90055 + s = page->slab_cache;
90056 + return s->flags & SLAB_USERCOPY;
90057 +}
90058 +
90059 +#ifdef CONFIG_PAX_USERCOPY
90060 +const char *check_heap_object(const void *ptr, unsigned long n)
90061 +{
90062 + struct page *page;
90063 + struct kmem_cache *s;
90064 + unsigned long offset;
90065 +
90066 + if (ZERO_OR_NULL_PTR(ptr))
90067 + return "<null>";
90068 +
90069 + if (!virt_addr_valid(ptr))
90070 + return NULL;
90071 +
90072 + page = virt_to_head_page(ptr);
90073 +
90074 + if (!PageSlab(page))
90075 + return NULL;
90076 +
90077 + s = page->slab_cache;
90078 + if (!(s->flags & SLAB_USERCOPY))
90079 + return s->name;
90080 +
90081 + offset = (ptr - page_address(page)) % s->size;
90082 + if (offset <= s->object_size && n <= s->object_size - offset)
90083 + return NULL;
90084 +
90085 + return s->name;
90086 +}
90087 +#endif
90088 +
90089 size_t ksize(const void *object)
90090 {
90091 struct page *page;
90092 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90093 if (unlikely(ZERO_OR_NULL_PTR(x)))
90094 return;
90095
90096 + VM_BUG_ON(!virt_addr_valid(x));
90097 page = virt_to_head_page(x);
90098 if (unlikely(!PageSlab(page))) {
90099 BUG_ON(!PageCompound(page));
90100 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90101 /*
90102 * We may have set a slab to be unmergeable during bootstrap.
90103 */
90104 - if (s->refcount < 0)
90105 + if (atomic_read(&s->refcount) < 0)
90106 return 1;
90107
90108 return 0;
90109 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90110
90111 s = find_mergeable(memcg, size, align, flags, name, ctor);
90112 if (s) {
90113 - s->refcount++;
90114 + atomic_inc(&s->refcount);
90115 /*
90116 * Adjust the object sizes so that we clear
90117 * the complete object on kzalloc.
90118 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90119 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90120
90121 if (sysfs_slab_alias(s, name)) {
90122 - s->refcount--;
90123 + atomic_dec(&s->refcount);
90124 s = NULL;
90125 }
90126 }
90127 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90128 }
90129 #endif
90130
90131 -#ifdef CONFIG_SYSFS
90132 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90133 static int count_inuse(struct page *page)
90134 {
90135 return page->inuse;
90136 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90137 validate_slab_cache(kmalloc_caches[9]);
90138 }
90139 #else
90140 -#ifdef CONFIG_SYSFS
90141 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90142 static void resiliency_test(void) {};
90143 #endif
90144 #endif
90145
90146 -#ifdef CONFIG_SYSFS
90147 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90148 enum slab_stat_type {
90149 SL_ALL, /* All slabs */
90150 SL_PARTIAL, /* Only partially allocated slabs */
90151 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90152
90153 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90154 {
90155 - return sprintf(buf, "%d\n", s->refcount - 1);
90156 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90157 }
90158 SLAB_ATTR_RO(aliases);
90159
90160 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90161 SLAB_ATTR_RO(cache_dma);
90162 #endif
90163
90164 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90165 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90166 +{
90167 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90168 +}
90169 +SLAB_ATTR_RO(usercopy);
90170 +#endif
90171 +
90172 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90173 {
90174 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90175 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90176 #ifdef CONFIG_ZONE_DMA
90177 &cache_dma_attr.attr,
90178 #endif
90179 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90180 + &usercopy_attr.attr,
90181 +#endif
90182 #ifdef CONFIG_NUMA
90183 &remote_node_defrag_ratio_attr.attr,
90184 #endif
90185 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90186 return name;
90187 }
90188
90189 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90190 static int sysfs_slab_add(struct kmem_cache *s)
90191 {
90192 int err;
90193 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90194 }
90195
90196 s->kobj.kset = slab_kset;
90197 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90198 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90199 if (err) {
90200 kobject_put(&s->kobj);
90201 return err;
90202 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90203 kobject_del(&s->kobj);
90204 kobject_put(&s->kobj);
90205 }
90206 +#endif
90207
90208 /*
90209 * Need to buffer aliases during bootup until sysfs becomes
90210 @@ -5213,6 +5291,7 @@ struct saved_alias {
90211
90212 static struct saved_alias *alias_list;
90213
90214 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90215 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90216 {
90217 struct saved_alias *al;
90218 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90219 alias_list = al;
90220 return 0;
90221 }
90222 +#endif
90223
90224 static int __init slab_sysfs_init(void)
90225 {
90226 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90227 index 27eeab3..7c3f7f2 100644
90228 --- a/mm/sparse-vmemmap.c
90229 +++ b/mm/sparse-vmemmap.c
90230 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90231 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90232 if (!p)
90233 return NULL;
90234 - pud_populate(&init_mm, pud, p);
90235 + pud_populate_kernel(&init_mm, pud, p);
90236 }
90237 return pud;
90238 }
90239 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90240 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90241 if (!p)
90242 return NULL;
90243 - pgd_populate(&init_mm, pgd, p);
90244 + pgd_populate_kernel(&init_mm, pgd, p);
90245 }
90246 return pgd;
90247 }
90248 diff --git a/mm/sparse.c b/mm/sparse.c
90249 index 308d503..3dbbd04 100644
90250 --- a/mm/sparse.c
90251 +++ b/mm/sparse.c
90252 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90253
90254 for (i = 0; i < PAGES_PER_SECTION; i++) {
90255 if (PageHWPoison(&memmap[i])) {
90256 - atomic_long_sub(1, &num_poisoned_pages);
90257 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90258 ClearPageHWPoison(&memmap[i]);
90259 }
90260 }
90261 diff --git a/mm/swap.c b/mm/swap.c
90262 index 62b78a6..0bcf28f 100644
90263 --- a/mm/swap.c
90264 +++ b/mm/swap.c
90265 @@ -31,6 +31,7 @@
90266 #include <linux/memcontrol.h>
90267 #include <linux/gfp.h>
90268 #include <linux/uio.h>
90269 +#include <linux/hugetlb.h>
90270
90271 #include "internal.h"
90272
90273 @@ -76,6 +77,8 @@ static void __put_compound_page(struct page *page)
90274
90275 __page_cache_release(page);
90276 dtor = get_compound_page_dtor(page);
90277 + if (!PageHuge(page))
90278 + BUG_ON(dtor != free_compound_page);
90279 (*dtor)(page);
90280 }
90281
90282 diff --git a/mm/swapfile.c b/mm/swapfile.c
90283 index 6cf2e60..d204b3e 100644
90284 --- a/mm/swapfile.c
90285 +++ b/mm/swapfile.c
90286 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90287
90288 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90289 /* Activity counter to indicate that a swapon or swapoff has occurred */
90290 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90291 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90292
90293 static inline unsigned char swap_count(unsigned char ent)
90294 {
90295 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90296 }
90297 filp_close(swap_file, NULL);
90298 err = 0;
90299 - atomic_inc(&proc_poll_event);
90300 + atomic_inc_unchecked(&proc_poll_event);
90301 wake_up_interruptible(&proc_poll_wait);
90302
90303 out_dput:
90304 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90305
90306 poll_wait(file, &proc_poll_wait, wait);
90307
90308 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90309 - seq->poll_event = atomic_read(&proc_poll_event);
90310 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90311 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90312 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90313 }
90314
90315 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90316 return ret;
90317
90318 seq = file->private_data;
90319 - seq->poll_event = atomic_read(&proc_poll_event);
90320 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90321 return 0;
90322 }
90323
90324 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90325 (frontswap_map) ? "FS" : "");
90326
90327 mutex_unlock(&swapon_mutex);
90328 - atomic_inc(&proc_poll_event);
90329 + atomic_inc_unchecked(&proc_poll_event);
90330 wake_up_interruptible(&proc_poll_wait);
90331
90332 if (S_ISREG(inode->i_mode))
90333 diff --git a/mm/util.c b/mm/util.c
90334 index 7441c41..c3de793 100644
90335 --- a/mm/util.c
90336 +++ b/mm/util.c
90337 @@ -294,6 +294,12 @@ done:
90338 void arch_pick_mmap_layout(struct mm_struct *mm)
90339 {
90340 mm->mmap_base = TASK_UNMAPPED_BASE;
90341 +
90342 +#ifdef CONFIG_PAX_RANDMMAP
90343 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90344 + mm->mmap_base += mm->delta_mmap;
90345 +#endif
90346 +
90347 mm->get_unmapped_area = arch_get_unmapped_area;
90348 }
90349 #endif
90350 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90351 index 13a5495..6707d97 100644
90352 --- a/mm/vmalloc.c
90353 +++ b/mm/vmalloc.c
90354 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90355
90356 pte = pte_offset_kernel(pmd, addr);
90357 do {
90358 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90359 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90360 +
90361 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90362 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90363 + BUG_ON(!pte_exec(*pte));
90364 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90365 + continue;
90366 + }
90367 +#endif
90368 +
90369 + {
90370 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90371 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90372 + }
90373 } while (pte++, addr += PAGE_SIZE, addr != end);
90374 }
90375
90376 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90377 pte = pte_alloc_kernel(pmd, addr);
90378 if (!pte)
90379 return -ENOMEM;
90380 +
90381 + pax_open_kernel();
90382 do {
90383 struct page *page = pages[*nr];
90384
90385 - if (WARN_ON(!pte_none(*pte)))
90386 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90387 + if (pgprot_val(prot) & _PAGE_NX)
90388 +#endif
90389 +
90390 + if (!pte_none(*pte)) {
90391 + pax_close_kernel();
90392 + WARN_ON(1);
90393 return -EBUSY;
90394 - if (WARN_ON(!page))
90395 + }
90396 + if (!page) {
90397 + pax_close_kernel();
90398 + WARN_ON(1);
90399 return -ENOMEM;
90400 + }
90401 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90402 (*nr)++;
90403 } while (pte++, addr += PAGE_SIZE, addr != end);
90404 + pax_close_kernel();
90405 return 0;
90406 }
90407
90408 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90409 pmd_t *pmd;
90410 unsigned long next;
90411
90412 - pmd = pmd_alloc(&init_mm, pud, addr);
90413 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90414 if (!pmd)
90415 return -ENOMEM;
90416 do {
90417 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90418 pud_t *pud;
90419 unsigned long next;
90420
90421 - pud = pud_alloc(&init_mm, pgd, addr);
90422 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90423 if (!pud)
90424 return -ENOMEM;
90425 do {
90426 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90427 if (addr >= MODULES_VADDR && addr < MODULES_END)
90428 return 1;
90429 #endif
90430 +
90431 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90432 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90433 + return 1;
90434 +#endif
90435 +
90436 return is_vmalloc_addr(x);
90437 }
90438
90439 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90440
90441 if (!pgd_none(*pgd)) {
90442 pud_t *pud = pud_offset(pgd, addr);
90443 +#ifdef CONFIG_X86
90444 + if (!pud_large(*pud))
90445 +#endif
90446 if (!pud_none(*pud)) {
90447 pmd_t *pmd = pmd_offset(pud, addr);
90448 +#ifdef CONFIG_X86
90449 + if (!pmd_large(*pmd))
90450 +#endif
90451 if (!pmd_none(*pmd)) {
90452 pte_t *ptep, pte;
90453
90454 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90455 * Allocate a region of KVA of the specified size and alignment, within the
90456 * vstart and vend.
90457 */
90458 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90459 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90460 unsigned long align,
90461 unsigned long vstart, unsigned long vend,
90462 int node, gfp_t gfp_mask)
90463 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90464 struct vm_struct *area;
90465
90466 BUG_ON(in_interrupt());
90467 +
90468 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90469 + if (flags & VM_KERNEXEC) {
90470 + if (start != VMALLOC_START || end != VMALLOC_END)
90471 + return NULL;
90472 + start = (unsigned long)MODULES_EXEC_VADDR;
90473 + end = (unsigned long)MODULES_EXEC_END;
90474 + }
90475 +#endif
90476 +
90477 if (flags & VM_IOREMAP)
90478 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90479
90480 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90481 if (count > totalram_pages)
90482 return NULL;
90483
90484 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90485 + if (!(pgprot_val(prot) & _PAGE_NX))
90486 + flags |= VM_KERNEXEC;
90487 +#endif
90488 +
90489 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90490 __builtin_return_address(0));
90491 if (!area)
90492 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90493 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90494 goto fail;
90495
90496 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90497 + if (!(pgprot_val(prot) & _PAGE_NX))
90498 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90499 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90500 + else
90501 +#endif
90502 +
90503 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90504 start, end, node, gfp_mask, caller);
90505 if (!area)
90506 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90507 * For tight control over page level allocator and protection flags
90508 * use __vmalloc() instead.
90509 */
90510 -
90511 void *vmalloc_exec(unsigned long size)
90512 {
90513 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90514 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90515 NUMA_NO_NODE, __builtin_return_address(0));
90516 }
90517
90518 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90519 {
90520 struct vm_struct *area;
90521
90522 + BUG_ON(vma->vm_mirror);
90523 +
90524 size = PAGE_ALIGN(size);
90525
90526 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90527 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90528 v->addr, v->addr + v->size, v->size);
90529
90530 if (v->caller)
90531 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90532 + seq_printf(m, " %pK", v->caller);
90533 +#else
90534 seq_printf(m, " %pS", v->caller);
90535 +#endif
90536
90537 if (v->nr_pages)
90538 seq_printf(m, " pages=%d", v->nr_pages);
90539 diff --git a/mm/vmstat.c b/mm/vmstat.c
90540 index 20c2ef4..15e7ab7 100644
90541 --- a/mm/vmstat.c
90542 +++ b/mm/vmstat.c
90543 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90544 *
90545 * vm_stat contains the global counters
90546 */
90547 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90548 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90549 EXPORT_SYMBOL(vm_stat);
90550
90551 #ifdef CONFIG_SMP
90552 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90553 v = p->vm_stat_diff[i];
90554 p->vm_stat_diff[i] = 0;
90555 local_irq_restore(flags);
90556 - atomic_long_add(v, &zone->vm_stat[i]);
90557 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90558 global_diff[i] += v;
90559 #ifdef CONFIG_NUMA
90560 /* 3 seconds idle till flush */
90561 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90562
90563 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90564 if (global_diff[i])
90565 - atomic_long_add(global_diff[i], &vm_stat[i]);
90566 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90567 }
90568
90569 /*
90570 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90571 if (pset->vm_stat_diff[i]) {
90572 int v = pset->vm_stat_diff[i];
90573 pset->vm_stat_diff[i] = 0;
90574 - atomic_long_add(v, &zone->vm_stat[i]);
90575 - atomic_long_add(v, &vm_stat[i]);
90576 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90577 + atomic_long_add_unchecked(v, &vm_stat[i]);
90578 }
90579 }
90580 #endif
90581 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90582 start_cpu_timer(cpu);
90583 #endif
90584 #ifdef CONFIG_PROC_FS
90585 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90586 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90587 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90588 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90589 + {
90590 + mode_t gr_mode = S_IRUGO;
90591 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90592 + gr_mode = S_IRUSR;
90593 +#endif
90594 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90595 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90596 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90597 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90598 +#else
90599 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90600 +#endif
90601 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90602 + }
90603 #endif
90604 return 0;
90605 }
90606 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90607 index 2fb2d88..8c06e40 100644
90608 --- a/net/8021q/vlan.c
90609 +++ b/net/8021q/vlan.c
90610 @@ -469,7 +469,7 @@ out:
90611 return NOTIFY_DONE;
90612 }
90613
90614 -static struct notifier_block vlan_notifier_block __read_mostly = {
90615 +static struct notifier_block vlan_notifier_block = {
90616 .notifier_call = vlan_device_event,
90617 };
90618
90619 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90620 err = -EPERM;
90621 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90622 break;
90623 - if ((args.u.name_type >= 0) &&
90624 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90625 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90626 struct vlan_net *vn;
90627
90628 vn = net_generic(net, vlan_net_id);
90629 diff --git a/net/9p/mod.c b/net/9p/mod.c
90630 index 6ab36ae..6f1841b 100644
90631 --- a/net/9p/mod.c
90632 +++ b/net/9p/mod.c
90633 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90634 void v9fs_register_trans(struct p9_trans_module *m)
90635 {
90636 spin_lock(&v9fs_trans_lock);
90637 - list_add_tail(&m->list, &v9fs_trans_list);
90638 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90639 spin_unlock(&v9fs_trans_lock);
90640 }
90641 EXPORT_SYMBOL(v9fs_register_trans);
90642 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90643 void v9fs_unregister_trans(struct p9_trans_module *m)
90644 {
90645 spin_lock(&v9fs_trans_lock);
90646 - list_del_init(&m->list);
90647 + pax_list_del_init((struct list_head *)&m->list);
90648 spin_unlock(&v9fs_trans_lock);
90649 }
90650 EXPORT_SYMBOL(v9fs_unregister_trans);
90651 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90652 index 3ffda1b..fceac96 100644
90653 --- a/net/9p/trans_fd.c
90654 +++ b/net/9p/trans_fd.c
90655 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90656 oldfs = get_fs();
90657 set_fs(get_ds());
90658 /* The cast to a user pointer is valid due to the set_fs() */
90659 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90660 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90661 set_fs(oldfs);
90662
90663 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90664 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90665 index 876fbe8..8bbea9f 100644
90666 --- a/net/atm/atm_misc.c
90667 +++ b/net/atm/atm_misc.c
90668 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90669 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90670 return 1;
90671 atm_return(vcc, truesize);
90672 - atomic_inc(&vcc->stats->rx_drop);
90673 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90674 return 0;
90675 }
90676 EXPORT_SYMBOL(atm_charge);
90677 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90678 }
90679 }
90680 atm_return(vcc, guess);
90681 - atomic_inc(&vcc->stats->rx_drop);
90682 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90683 return NULL;
90684 }
90685 EXPORT_SYMBOL(atm_alloc_charge);
90686 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90687
90688 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90689 {
90690 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90691 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90692 __SONET_ITEMS
90693 #undef __HANDLE_ITEM
90694 }
90695 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90696
90697 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90698 {
90699 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90700 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90701 __SONET_ITEMS
90702 #undef __HANDLE_ITEM
90703 }
90704 diff --git a/net/atm/lec.h b/net/atm/lec.h
90705 index 4149db1..f2ab682 100644
90706 --- a/net/atm/lec.h
90707 +++ b/net/atm/lec.h
90708 @@ -48,7 +48,7 @@ struct lane2_ops {
90709 const u8 *tlvs, u32 sizeoftlvs);
90710 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90711 const u8 *tlvs, u32 sizeoftlvs);
90712 -};
90713 +} __no_const;
90714
90715 /*
90716 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90717 diff --git a/net/atm/proc.c b/net/atm/proc.c
90718 index bbb6461..cf04016 100644
90719 --- a/net/atm/proc.c
90720 +++ b/net/atm/proc.c
90721 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90722 const struct k_atm_aal_stats *stats)
90723 {
90724 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90725 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90726 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90727 - atomic_read(&stats->rx_drop));
90728 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90729 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90730 + atomic_read_unchecked(&stats->rx_drop));
90731 }
90732
90733 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90734 diff --git a/net/atm/resources.c b/net/atm/resources.c
90735 index 0447d5d..3cf4728 100644
90736 --- a/net/atm/resources.c
90737 +++ b/net/atm/resources.c
90738 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90739 static void copy_aal_stats(struct k_atm_aal_stats *from,
90740 struct atm_aal_stats *to)
90741 {
90742 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90743 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90744 __AAL_STAT_ITEMS
90745 #undef __HANDLE_ITEM
90746 }
90747 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90748 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90749 struct atm_aal_stats *to)
90750 {
90751 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90752 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90753 __AAL_STAT_ITEMS
90754 #undef __HANDLE_ITEM
90755 }
90756 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90757 index 919a5ce..cc6b444 100644
90758 --- a/net/ax25/sysctl_net_ax25.c
90759 +++ b/net/ax25/sysctl_net_ax25.c
90760 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90761 {
90762 char path[sizeof("net/ax25/") + IFNAMSIZ];
90763 int k;
90764 - struct ctl_table *table;
90765 + ctl_table_no_const *table;
90766
90767 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90768 if (!table)
90769 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90770 index 62da527..aa27535 100644
90771 --- a/net/batman-adv/bat_iv_ogm.c
90772 +++ b/net/batman-adv/bat_iv_ogm.c
90773 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90774
90775 /* randomize initial seqno to avoid collision */
90776 get_random_bytes(&random_seqno, sizeof(random_seqno));
90777 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90778 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90779
90780 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90781 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90782 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90783 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90784
90785 /* change sequence number to network order */
90786 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90787 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90788 batadv_ogm_packet->seqno = htonl(seqno);
90789 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90790 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90791
90792 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90793 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90794 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90795 return;
90796
90797 /* could be changed by schedule_own_packet() */
90798 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90799 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90800
90801 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90802 has_directlink_flag = 1;
90803 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90804 index c478e6b..469fd2f 100644
90805 --- a/net/batman-adv/hard-interface.c
90806 +++ b/net/batman-adv/hard-interface.c
90807 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90808 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90809 dev_add_pack(&hard_iface->batman_adv_ptype);
90810
90811 - atomic_set(&hard_iface->frag_seqno, 1);
90812 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90813 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90814 hard_iface->net_dev->name);
90815
90816 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90817 index 0f04e1c..9c0ac11 100644
90818 --- a/net/batman-adv/soft-interface.c
90819 +++ b/net/batman-adv/soft-interface.c
90820 @@ -260,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90821 primary_if->net_dev->dev_addr, ETH_ALEN);
90822
90823 /* set broadcast sequence number */
90824 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90825 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90826 bcast_packet->seqno = htonl(seqno);
90827
90828 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90829 @@ -479,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90830 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90831
90832 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90833 - atomic_set(&bat_priv->bcast_seqno, 1);
90834 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90835 atomic_set(&bat_priv->tt.vn, 0);
90836 atomic_set(&bat_priv->tt.local_changes, 0);
90837 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90838 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90839 index b2c94e1..3d47e07 100644
90840 --- a/net/batman-adv/types.h
90841 +++ b/net/batman-adv/types.h
90842 @@ -51,7 +51,7 @@
90843 struct batadv_hard_iface_bat_iv {
90844 unsigned char *ogm_buff;
90845 int ogm_buff_len;
90846 - atomic_t ogm_seqno;
90847 + atomic_unchecked_t ogm_seqno;
90848 };
90849
90850 /**
90851 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90852 int16_t if_num;
90853 char if_status;
90854 struct net_device *net_dev;
90855 - atomic_t frag_seqno;
90856 + atomic_unchecked_t frag_seqno;
90857 uint8_t num_bcasts;
90858 struct kobject *hardif_obj;
90859 atomic_t refcount;
90860 @@ -560,7 +560,7 @@ struct batadv_priv {
90861 #ifdef CONFIG_BATMAN_ADV_DEBUG
90862 atomic_t log_level;
90863 #endif
90864 - atomic_t bcast_seqno;
90865 + atomic_unchecked_t bcast_seqno;
90866 atomic_t bcast_queue_left;
90867 atomic_t batman_queue_left;
90868 char num_ifaces;
90869 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90870 index 857e1b8..5ad07b2 100644
90871 --- a/net/batman-adv/unicast.c
90872 +++ b/net/batman-adv/unicast.c
90873 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90874 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90875 frag2->flags = large_tail;
90876
90877 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
90878 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
90879 frag1->seqno = htons(seqno - 1);
90880 frag2->seqno = htons(seqno);
90881
90882 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
90883 index 9bd7d95..6c4884f 100644
90884 --- a/net/bluetooth/hci_sock.c
90885 +++ b/net/bluetooth/hci_sock.c
90886 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
90887 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
90888 }
90889
90890 - len = min_t(unsigned int, len, sizeof(uf));
90891 + len = min((size_t)len, sizeof(uf));
90892 if (copy_from_user(&uf, optval, len)) {
90893 err = -EFAULT;
90894 break;
90895 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
90896 index 8c3499b..2661c6a 100644
90897 --- a/net/bluetooth/l2cap_core.c
90898 +++ b/net/bluetooth/l2cap_core.c
90899 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
90900 break;
90901
90902 case L2CAP_CONF_RFC:
90903 - if (olen == sizeof(rfc))
90904 - memcpy(&rfc, (void *)val, olen);
90905 + if (olen != sizeof(rfc))
90906 + break;
90907 +
90908 + memcpy(&rfc, (void *)val, olen);
90909
90910 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
90911 rfc.mode != chan->mode)
90912 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
90913 index 0098af8..fb5a31f 100644
90914 --- a/net/bluetooth/l2cap_sock.c
90915 +++ b/net/bluetooth/l2cap_sock.c
90916 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90917 struct sock *sk = sock->sk;
90918 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
90919 struct l2cap_options opts;
90920 - int len, err = 0;
90921 + int err = 0;
90922 + size_t len = optlen;
90923 u32 opt;
90924
90925 BT_DBG("sk %p", sk);
90926 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90927 opts.max_tx = chan->max_tx;
90928 opts.txwin_size = chan->tx_win;
90929
90930 - len = min_t(unsigned int, sizeof(opts), optlen);
90931 + len = min(sizeof(opts), len);
90932 if (copy_from_user((char *) &opts, optval, len)) {
90933 err = -EFAULT;
90934 break;
90935 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90936 struct bt_security sec;
90937 struct bt_power pwr;
90938 struct l2cap_conn *conn;
90939 - int len, err = 0;
90940 + int err = 0;
90941 + size_t len = optlen;
90942 u32 opt;
90943
90944 BT_DBG("sk %p", sk);
90945 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90946
90947 sec.level = BT_SECURITY_LOW;
90948
90949 - len = min_t(unsigned int, sizeof(sec), optlen);
90950 + len = min(sizeof(sec), len);
90951 if (copy_from_user((char *) &sec, optval, len)) {
90952 err = -EFAULT;
90953 break;
90954 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90955
90956 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
90957
90958 - len = min_t(unsigned int, sizeof(pwr), optlen);
90959 + len = min(sizeof(pwr), len);
90960 if (copy_from_user((char *) &pwr, optval, len)) {
90961 err = -EFAULT;
90962 break;
90963 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
90964 index 30b3721..c1bd0a0 100644
90965 --- a/net/bluetooth/rfcomm/sock.c
90966 +++ b/net/bluetooth/rfcomm/sock.c
90967 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90968 struct sock *sk = sock->sk;
90969 struct bt_security sec;
90970 int err = 0;
90971 - size_t len;
90972 + size_t len = optlen;
90973 u32 opt;
90974
90975 BT_DBG("sk %p", sk);
90976 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90977
90978 sec.level = BT_SECURITY_LOW;
90979
90980 - len = min_t(unsigned int, sizeof(sec), optlen);
90981 + len = min(sizeof(sec), len);
90982 if (copy_from_user((char *) &sec, optval, len)) {
90983 err = -EFAULT;
90984 break;
90985 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
90986 index b6e44ad..5b0d514 100644
90987 --- a/net/bluetooth/rfcomm/tty.c
90988 +++ b/net/bluetooth/rfcomm/tty.c
90989 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
90990 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
90991
90992 spin_lock_irqsave(&dev->port.lock, flags);
90993 - if (dev->port.count > 0) {
90994 + if (atomic_read(&dev->port.count) > 0) {
90995 spin_unlock_irqrestore(&dev->port.lock, flags);
90996 return;
90997 }
90998 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
90999 return -ENODEV;
91000
91001 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91002 - dev->channel, dev->port.count);
91003 + dev->channel, atomic_read(&dev->port.count));
91004
91005 spin_lock_irqsave(&dev->port.lock, flags);
91006 - if (++dev->port.count > 1) {
91007 + if (atomic_inc_return(&dev->port.count) > 1) {
91008 spin_unlock_irqrestore(&dev->port.lock, flags);
91009 return 0;
91010 }
91011 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91012 return;
91013
91014 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91015 - dev->port.count);
91016 + atomic_read(&dev->port.count));
91017
91018 spin_lock_irqsave(&dev->port.lock, flags);
91019 - if (!--dev->port.count) {
91020 + if (!atomic_dec_return(&dev->port.count)) {
91021 spin_unlock_irqrestore(&dev->port.lock, flags);
91022 if (dev->tty_dev->parent)
91023 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91024 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91025 index ac78024..161a80c 100644
91026 --- a/net/bridge/netfilter/ebtables.c
91027 +++ b/net/bridge/netfilter/ebtables.c
91028 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91029 tmp.valid_hooks = t->table->valid_hooks;
91030 }
91031 mutex_unlock(&ebt_mutex);
91032 - if (copy_to_user(user, &tmp, *len) != 0){
91033 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91034 BUGPRINT("c2u Didn't work\n");
91035 ret = -EFAULT;
91036 break;
91037 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91038 goto out;
91039 tmp.valid_hooks = t->valid_hooks;
91040
91041 - if (copy_to_user(user, &tmp, *len) != 0) {
91042 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91043 ret = -EFAULT;
91044 break;
91045 }
91046 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91047 tmp.entries_size = t->table->entries_size;
91048 tmp.valid_hooks = t->table->valid_hooks;
91049
91050 - if (copy_to_user(user, &tmp, *len) != 0) {
91051 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91052 ret = -EFAULT;
91053 break;
91054 }
91055 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91056 index 2bd4b58..0dc30a1 100644
91057 --- a/net/caif/cfctrl.c
91058 +++ b/net/caif/cfctrl.c
91059 @@ -10,6 +10,7 @@
91060 #include <linux/spinlock.h>
91061 #include <linux/slab.h>
91062 #include <linux/pkt_sched.h>
91063 +#include <linux/sched.h>
91064 #include <net/caif/caif_layer.h>
91065 #include <net/caif/cfpkt.h>
91066 #include <net/caif/cfctrl.h>
91067 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91068 memset(&dev_info, 0, sizeof(dev_info));
91069 dev_info.id = 0xff;
91070 cfsrvl_init(&this->serv, 0, &dev_info, false);
91071 - atomic_set(&this->req_seq_no, 1);
91072 - atomic_set(&this->rsp_seq_no, 1);
91073 + atomic_set_unchecked(&this->req_seq_no, 1);
91074 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91075 this->serv.layer.receive = cfctrl_recv;
91076 sprintf(this->serv.layer.name, "ctrl");
91077 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91078 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91079 struct cfctrl_request_info *req)
91080 {
91081 spin_lock_bh(&ctrl->info_list_lock);
91082 - atomic_inc(&ctrl->req_seq_no);
91083 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91084 + atomic_inc_unchecked(&ctrl->req_seq_no);
91085 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91086 list_add_tail(&req->list, &ctrl->list);
91087 spin_unlock_bh(&ctrl->info_list_lock);
91088 }
91089 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91090 if (p != first)
91091 pr_warn("Requests are not received in order\n");
91092
91093 - atomic_set(&ctrl->rsp_seq_no,
91094 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91095 p->sequence_no);
91096 list_del(&p->list);
91097 goto out;
91098 diff --git a/net/can/af_can.c b/net/can/af_can.c
91099 index 3ab8dd2..b9aef13 100644
91100 --- a/net/can/af_can.c
91101 +++ b/net/can/af_can.c
91102 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91103 };
91104
91105 /* notifier block for netdevice event */
91106 -static struct notifier_block can_netdev_notifier __read_mostly = {
91107 +static struct notifier_block can_netdev_notifier = {
91108 .notifier_call = can_notifier,
91109 };
91110
91111 diff --git a/net/can/gw.c b/net/can/gw.c
91112 index 2f291f9..98c986a 100644
91113 --- a/net/can/gw.c
91114 +++ b/net/can/gw.c
91115 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91116 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91117
91118 static HLIST_HEAD(cgw_list);
91119 -static struct notifier_block notifier;
91120
91121 static struct kmem_cache *cgw_cache __read_mostly;
91122
91123 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91124 return err;
91125 }
91126
91127 +static struct notifier_block notifier = {
91128 + .notifier_call = cgw_notifier
91129 +};
91130 +
91131 static __init int cgw_module_init(void)
91132 {
91133 /* sanitize given module parameter */
91134 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91135 return -ENOMEM;
91136
91137 /* set notifier */
91138 - notifier.notifier_call = cgw_notifier;
91139 register_netdevice_notifier(&notifier);
91140
91141 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91142 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91143 index eb0a46a..5f3bae8 100644
91144 --- a/net/ceph/messenger.c
91145 +++ b/net/ceph/messenger.c
91146 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91147 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91148
91149 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91150 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91151 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91152
91153 static struct page *zero_page; /* used in certain error cases */
91154
91155 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91156 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91157 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91158
91159 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91160 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91161 s = addr_str[i];
91162
91163 switch (ss->ss_family) {
91164 diff --git a/net/compat.c b/net/compat.c
91165 index f0a1ba6..0541331 100644
91166 --- a/net/compat.c
91167 +++ b/net/compat.c
91168 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91169 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
91170 __get_user(kmsg->msg_flags, &umsg->msg_flags))
91171 return -EFAULT;
91172 - kmsg->msg_name = compat_ptr(tmp1);
91173 - kmsg->msg_iov = compat_ptr(tmp2);
91174 - kmsg->msg_control = compat_ptr(tmp3);
91175 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91176 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91177 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91178 return 0;
91179 }
91180
91181 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91182
91183 if (kern_msg->msg_namelen) {
91184 if (mode == VERIFY_READ) {
91185 - int err = move_addr_to_kernel(kern_msg->msg_name,
91186 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91187 kern_msg->msg_namelen,
91188 kern_address);
91189 if (err < 0)
91190 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91191 kern_msg->msg_name = NULL;
91192
91193 tot_len = iov_from_user_compat_to_kern(kern_iov,
91194 - (struct compat_iovec __user *)kern_msg->msg_iov,
91195 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91196 kern_msg->msg_iovlen);
91197 if (tot_len >= 0)
91198 kern_msg->msg_iov = kern_iov;
91199 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91200
91201 #define CMSG_COMPAT_FIRSTHDR(msg) \
91202 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91203 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91204 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91205 (struct compat_cmsghdr __user *)NULL)
91206
91207 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91208 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91209 (ucmlen) <= (unsigned long) \
91210 ((mhdr)->msg_controllen - \
91211 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91212 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91213
91214 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91215 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91216 {
91217 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91218 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91219 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91220 msg->msg_controllen)
91221 return NULL;
91222 return (struct compat_cmsghdr __user *)ptr;
91223 @@ -219,7 +219,7 @@ Efault:
91224
91225 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91226 {
91227 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91228 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91229 struct compat_cmsghdr cmhdr;
91230 struct compat_timeval ctv;
91231 struct compat_timespec cts[3];
91232 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91233
91234 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91235 {
91236 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91237 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91238 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91239 int fdnum = scm->fp->count;
91240 struct file **fp = scm->fp->fp;
91241 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91242 return -EFAULT;
91243 old_fs = get_fs();
91244 set_fs(KERNEL_DS);
91245 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91246 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91247 set_fs(old_fs);
91248
91249 return err;
91250 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91251 len = sizeof(ktime);
91252 old_fs = get_fs();
91253 set_fs(KERNEL_DS);
91254 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91255 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91256 set_fs(old_fs);
91257
91258 if (!err) {
91259 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91260 case MCAST_JOIN_GROUP:
91261 case MCAST_LEAVE_GROUP:
91262 {
91263 - struct compat_group_req __user *gr32 = (void *)optval;
91264 + struct compat_group_req __user *gr32 = (void __user *)optval;
91265 struct group_req __user *kgr =
91266 compat_alloc_user_space(sizeof(struct group_req));
91267 u32 interface;
91268 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91269 case MCAST_BLOCK_SOURCE:
91270 case MCAST_UNBLOCK_SOURCE:
91271 {
91272 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91273 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91274 struct group_source_req __user *kgsr = compat_alloc_user_space(
91275 sizeof(struct group_source_req));
91276 u32 interface;
91277 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91278 }
91279 case MCAST_MSFILTER:
91280 {
91281 - struct compat_group_filter __user *gf32 = (void *)optval;
91282 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91283 struct group_filter __user *kgf;
91284 u32 interface, fmode, numsrc;
91285
91286 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91287 char __user *optval, int __user *optlen,
91288 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91289 {
91290 - struct compat_group_filter __user *gf32 = (void *)optval;
91291 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91292 struct group_filter __user *kgf;
91293 int __user *koptlen;
91294 u32 interface, fmode, numsrc;
91295 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91296
91297 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91298 return -EINVAL;
91299 - if (copy_from_user(a, args, nas[call]))
91300 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91301 return -EFAULT;
91302 a0 = a[0];
91303 a1 = a[1];
91304 diff --git a/net/core/datagram.c b/net/core/datagram.c
91305 index 8ab48cd..57b1a80 100644
91306 --- a/net/core/datagram.c
91307 +++ b/net/core/datagram.c
91308 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91309 }
91310
91311 kfree_skb(skb);
91312 - atomic_inc(&sk->sk_drops);
91313 + atomic_inc_unchecked(&sk->sk_drops);
91314 sk_mem_reclaim_partial(sk);
91315
91316 return err;
91317 diff --git a/net/core/dev.c b/net/core/dev.c
91318 index 26755dd..2a232de 100644
91319 --- a/net/core/dev.c
91320 +++ b/net/core/dev.c
91321 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91322 {
91323 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91324 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91325 - atomic_long_inc(&dev->rx_dropped);
91326 + atomic_long_inc_unchecked(&dev->rx_dropped);
91327 kfree_skb(skb);
91328 return NET_RX_DROP;
91329 }
91330 }
91331
91332 if (unlikely(!is_skb_forwardable(dev, skb))) {
91333 - atomic_long_inc(&dev->rx_dropped);
91334 + atomic_long_inc_unchecked(&dev->rx_dropped);
91335 kfree_skb(skb);
91336 return NET_RX_DROP;
91337 }
91338 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91339
91340 struct dev_gso_cb {
91341 void (*destructor)(struct sk_buff *skb);
91342 -};
91343 +} __no_const;
91344
91345 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91346
91347 @@ -3206,7 +3206,7 @@ enqueue:
91348
91349 local_irq_restore(flags);
91350
91351 - atomic_long_inc(&skb->dev->rx_dropped);
91352 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91353 kfree_skb(skb);
91354 return NET_RX_DROP;
91355 }
91356 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91357 }
91358 EXPORT_SYMBOL(netif_rx_ni);
91359
91360 -static void net_tx_action(struct softirq_action *h)
91361 +static __latent_entropy void net_tx_action(void)
91362 {
91363 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91364
91365 @@ -3612,7 +3612,7 @@ ncls:
91366 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91367 } else {
91368 drop:
91369 - atomic_long_inc(&skb->dev->rx_dropped);
91370 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91371 kfree_skb(skb);
91372 /* Jamal, now you will not able to escape explaining
91373 * me how you were going to use this. :-)
91374 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91375 }
91376 EXPORT_SYMBOL(netif_napi_del);
91377
91378 -static void net_rx_action(struct softirq_action *h)
91379 +static __latent_entropy void net_rx_action(void)
91380 {
91381 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91382 unsigned long time_limit = jiffies + 2;
91383 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91384 } else {
91385 netdev_stats_to_stats64(storage, &dev->stats);
91386 }
91387 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91388 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91389 return storage;
91390 }
91391 EXPORT_SYMBOL(dev_get_stats);
91392 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91393 index 5b7d0e1..cb960fc 100644
91394 --- a/net/core/dev_ioctl.c
91395 +++ b/net/core/dev_ioctl.c
91396 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91397 if (no_module && capable(CAP_NET_ADMIN))
91398 no_module = request_module("netdev-%s", name);
91399 if (no_module && capable(CAP_SYS_MODULE)) {
91400 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91401 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91402 +#else
91403 if (!request_module("%s", name))
91404 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91405 name);
91406 +#endif
91407 }
91408 }
91409 EXPORT_SYMBOL(dev_load);
91410 diff --git a/net/core/flow.c b/net/core/flow.c
91411 index dfa602c..3103d88 100644
91412 --- a/net/core/flow.c
91413 +++ b/net/core/flow.c
91414 @@ -61,7 +61,7 @@ struct flow_cache {
91415 struct timer_list rnd_timer;
91416 };
91417
91418 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91419 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91420 EXPORT_SYMBOL(flow_cache_genid);
91421 static struct flow_cache flow_cache_global;
91422 static struct kmem_cache *flow_cachep __read_mostly;
91423 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91424
91425 static int flow_entry_valid(struct flow_cache_entry *fle)
91426 {
91427 - if (atomic_read(&flow_cache_genid) != fle->genid)
91428 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91429 return 0;
91430 if (fle->object && !fle->object->ops->check(fle->object))
91431 return 0;
91432 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91433 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91434 fcp->hash_count++;
91435 }
91436 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91437 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91438 flo = fle->object;
91439 if (!flo)
91440 goto ret_object;
91441 @@ -279,7 +279,7 @@ nocache:
91442 }
91443 flo = resolver(net, key, family, dir, flo, ctx);
91444 if (fle) {
91445 - fle->genid = atomic_read(&flow_cache_genid);
91446 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91447 if (!IS_ERR(flo))
91448 fle->object = flo;
91449 else
91450 diff --git a/net/core/iovec.c b/net/core/iovec.c
91451 index de178e4..1dabd8b 100644
91452 --- a/net/core/iovec.c
91453 +++ b/net/core/iovec.c
91454 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91455 if (m->msg_namelen) {
91456 if (mode == VERIFY_READ) {
91457 void __user *namep;
91458 - namep = (void __user __force *) m->msg_name;
91459 + namep = (void __force_user *) m->msg_name;
91460 err = move_addr_to_kernel(namep, m->msg_namelen,
91461 address);
91462 if (err < 0)
91463 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91464 }
91465
91466 size = m->msg_iovlen * sizeof(struct iovec);
91467 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91468 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91469 return -EFAULT;
91470
91471 m->msg_iov = iov;
91472 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91473 index 60533db..14842cc 100644
91474 --- a/net/core/neighbour.c
91475 +++ b/net/core/neighbour.c
91476 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91477 void __user *buffer, size_t *lenp, loff_t *ppos)
91478 {
91479 int size, ret;
91480 - struct ctl_table tmp = *ctl;
91481 + ctl_table_no_const tmp = *ctl;
91482
91483 tmp.extra1 = &zero;
91484 tmp.extra2 = &unres_qlen_max;
91485 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91486 index 2bf8329..7960607 100644
91487 --- a/net/core/net-procfs.c
91488 +++ b/net/core/net-procfs.c
91489 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91490 else
91491 seq_printf(seq, "%04x", ntohs(pt->type));
91492
91493 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91494 + seq_printf(seq, " %-8s %pf\n",
91495 + pt->dev ? pt->dev->name : "", NULL);
91496 +#else
91497 seq_printf(seq, " %-8s %pf\n",
91498 pt->dev ? pt->dev->name : "", pt->func);
91499 +#endif
91500 }
91501
91502 return 0;
91503 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91504 index 981fed3..536af34 100644
91505 --- a/net/core/net-sysfs.c
91506 +++ b/net/core/net-sysfs.c
91507 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91508 }
91509 EXPORT_SYMBOL(netdev_class_remove_file);
91510
91511 -int netdev_kobject_init(void)
91512 +int __init netdev_kobject_init(void)
91513 {
91514 kobj_ns_type_register(&net_ns_type_operations);
91515 return class_register(&net_class);
91516 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91517 index f9765203..9feaef8 100644
91518 --- a/net/core/net_namespace.c
91519 +++ b/net/core/net_namespace.c
91520 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91521 int error;
91522 LIST_HEAD(net_exit_list);
91523
91524 - list_add_tail(&ops->list, list);
91525 + pax_list_add_tail((struct list_head *)&ops->list, list);
91526 if (ops->init || (ops->id && ops->size)) {
91527 for_each_net(net) {
91528 error = ops_init(ops, net);
91529 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91530
91531 out_undo:
91532 /* If I have an error cleanup all namespaces I initialized */
91533 - list_del(&ops->list);
91534 + pax_list_del((struct list_head *)&ops->list);
91535 ops_exit_list(ops, &net_exit_list);
91536 ops_free_list(ops, &net_exit_list);
91537 return error;
91538 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91539 struct net *net;
91540 LIST_HEAD(net_exit_list);
91541
91542 - list_del(&ops->list);
91543 + pax_list_del((struct list_head *)&ops->list);
91544 for_each_net(net)
91545 list_add_tail(&net->exit_list, &net_exit_list);
91546 ops_exit_list(ops, &net_exit_list);
91547 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91548 mutex_lock(&net_mutex);
91549 error = register_pernet_operations(&pernet_list, ops);
91550 if (!error && (first_device == &pernet_list))
91551 - first_device = &ops->list;
91552 + first_device = (struct list_head *)&ops->list;
91553 mutex_unlock(&net_mutex);
91554 return error;
91555 }
91556 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91557 index 2c637e9..68c9087 100644
91558 --- a/net/core/netpoll.c
91559 +++ b/net/core/netpoll.c
91560 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91561 struct udphdr *udph;
91562 struct iphdr *iph;
91563 struct ethhdr *eth;
91564 - static atomic_t ip_ident;
91565 + static atomic_unchecked_t ip_ident;
91566 struct ipv6hdr *ip6h;
91567
91568 udp_len = len + sizeof(*udph);
91569 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91570 put_unaligned(0x45, (unsigned char *)iph);
91571 iph->tos = 0;
91572 put_unaligned(htons(ip_len), &(iph->tot_len));
91573 - iph->id = htons(atomic_inc_return(&ip_ident));
91574 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91575 iph->frag_off = 0;
91576 iph->ttl = 64;
91577 iph->protocol = IPPROTO_UDP;
91578 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91579 index ca198c1d1..125372f 100644
91580 --- a/net/core/rtnetlink.c
91581 +++ b/net/core/rtnetlink.c
91582 @@ -58,7 +58,7 @@ struct rtnl_link {
91583 rtnl_doit_func doit;
91584 rtnl_dumpit_func dumpit;
91585 rtnl_calcit_func calcit;
91586 -};
91587 +} __no_const;
91588
91589 static DEFINE_MUTEX(rtnl_mutex);
91590
91591 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91592 if (rtnl_link_ops_get(ops->kind))
91593 return -EEXIST;
91594
91595 - if (!ops->dellink)
91596 - ops->dellink = unregister_netdevice_queue;
91597 + if (!ops->dellink) {
91598 + pax_open_kernel();
91599 + *(void **)&ops->dellink = unregister_netdevice_queue;
91600 + pax_close_kernel();
91601 + }
91602
91603 - list_add_tail(&ops->list, &link_ops);
91604 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91605 return 0;
91606 }
91607 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91608 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91609 for_each_net(net) {
91610 __rtnl_kill_links(net, ops);
91611 }
91612 - list_del(&ops->list);
91613 + pax_list_del((struct list_head *)&ops->list);
91614 }
91615 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91616
91617 diff --git a/net/core/scm.c b/net/core/scm.c
91618 index b4da80b..98d6bdb 100644
91619 --- a/net/core/scm.c
91620 +++ b/net/core/scm.c
91621 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91622 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91623 {
91624 struct cmsghdr __user *cm
91625 - = (__force struct cmsghdr __user *)msg->msg_control;
91626 + = (struct cmsghdr __force_user *)msg->msg_control;
91627 struct cmsghdr cmhdr;
91628 int cmlen = CMSG_LEN(len);
91629 int err;
91630 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91631 err = -EFAULT;
91632 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91633 goto out;
91634 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91635 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91636 goto out;
91637 cmlen = CMSG_SPACE(len);
91638 if (msg->msg_controllen < cmlen)
91639 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91640 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91641 {
91642 struct cmsghdr __user *cm
91643 - = (__force struct cmsghdr __user*)msg->msg_control;
91644 + = (struct cmsghdr __force_user *)msg->msg_control;
91645
91646 int fdmax = 0;
91647 int fdnum = scm->fp->count;
91648 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91649 if (fdnum < fdmax)
91650 fdmax = fdnum;
91651
91652 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91653 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91654 i++, cmfptr++)
91655 {
91656 struct socket *sock;
91657 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91658 index 2c3d0f5..f5a326f 100644
91659 --- a/net/core/skbuff.c
91660 +++ b/net/core/skbuff.c
91661 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91662 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91663 sizeof(struct sk_buff),
91664 0,
91665 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91666 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91667 + SLAB_NO_SANITIZE,
91668 NULL);
91669 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91670 (2*sizeof(struct sk_buff)) +
91671 sizeof(atomic_t),
91672 0,
91673 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91674 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91675 + SLAB_NO_SANITIZE,
91676 NULL);
91677 }
91678
91679 diff --git a/net/core/sock.c b/net/core/sock.c
91680 index 2c097c5..bf72858 100644
91681 --- a/net/core/sock.c
91682 +++ b/net/core/sock.c
91683 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91684 struct sk_buff_head *list = &sk->sk_receive_queue;
91685
91686 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91687 - atomic_inc(&sk->sk_drops);
91688 + atomic_inc_unchecked(&sk->sk_drops);
91689 trace_sock_rcvqueue_full(sk, skb);
91690 return -ENOMEM;
91691 }
91692 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91693 return err;
91694
91695 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91696 - atomic_inc(&sk->sk_drops);
91697 + atomic_inc_unchecked(&sk->sk_drops);
91698 return -ENOBUFS;
91699 }
91700
91701 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91702 skb_dst_force(skb);
91703
91704 spin_lock_irqsave(&list->lock, flags);
91705 - skb->dropcount = atomic_read(&sk->sk_drops);
91706 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91707 __skb_queue_tail(list, skb);
91708 spin_unlock_irqrestore(&list->lock, flags);
91709
91710 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91711 skb->dev = NULL;
91712
91713 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91714 - atomic_inc(&sk->sk_drops);
91715 + atomic_inc_unchecked(&sk->sk_drops);
91716 goto discard_and_relse;
91717 }
91718 if (nested)
91719 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91720 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91721 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91722 bh_unlock_sock(sk);
91723 - atomic_inc(&sk->sk_drops);
91724 + atomic_inc_unchecked(&sk->sk_drops);
91725 goto discard_and_relse;
91726 }
91727
91728 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91729 struct timeval tm;
91730 } v;
91731
91732 - int lv = sizeof(int);
91733 - int len;
91734 + unsigned int lv = sizeof(int);
91735 + unsigned int len;
91736
91737 if (get_user(len, optlen))
91738 return -EFAULT;
91739 - if (len < 0)
91740 + if (len > INT_MAX)
91741 return -EINVAL;
91742
91743 memset(&v, 0, sizeof(v));
91744 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91745
91746 case SO_PEERNAME:
91747 {
91748 - char address[128];
91749 + char address[_K_SS_MAXSIZE];
91750
91751 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91752 return -ENOTCONN;
91753 - if (lv < len)
91754 + if (lv < len || sizeof address < len)
91755 return -EINVAL;
91756 if (copy_to_user(optval, address, len))
91757 return -EFAULT;
91758 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91759
91760 if (len > lv)
91761 len = lv;
91762 - if (copy_to_user(optval, &v, len))
91763 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91764 return -EFAULT;
91765 lenout:
91766 if (put_user(len, optlen))
91767 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91768 */
91769 smp_wmb();
91770 atomic_set(&sk->sk_refcnt, 1);
91771 - atomic_set(&sk->sk_drops, 0);
91772 + atomic_set_unchecked(&sk->sk_drops, 0);
91773 }
91774 EXPORT_SYMBOL(sock_init_data);
91775
91776 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91777 index a0e9cf6..ef7f9ed 100644
91778 --- a/net/core/sock_diag.c
91779 +++ b/net/core/sock_diag.c
91780 @@ -9,26 +9,33 @@
91781 #include <linux/inet_diag.h>
91782 #include <linux/sock_diag.h>
91783
91784 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91785 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91786 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91787 static DEFINE_MUTEX(sock_diag_table_mutex);
91788
91789 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91790 {
91791 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91792 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91793 cookie[1] != INET_DIAG_NOCOOKIE) &&
91794 ((u32)(unsigned long)sk != cookie[0] ||
91795 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91796 return -ESTALE;
91797 else
91798 +#endif
91799 return 0;
91800 }
91801 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91802
91803 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91804 {
91805 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91806 + cookie[0] = 0;
91807 + cookie[1] = 0;
91808 +#else
91809 cookie[0] = (u32)(unsigned long)sk;
91810 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91811 +#endif
91812 }
91813 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91814
91815 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91816 mutex_lock(&sock_diag_table_mutex);
91817 if (sock_diag_handlers[hndl->family])
91818 err = -EBUSY;
91819 - else
91820 + else {
91821 + pax_open_kernel();
91822 sock_diag_handlers[hndl->family] = hndl;
91823 + pax_close_kernel();
91824 + }
91825 mutex_unlock(&sock_diag_table_mutex);
91826
91827 return err;
91828 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91829
91830 mutex_lock(&sock_diag_table_mutex);
91831 BUG_ON(sock_diag_handlers[family] != hnld);
91832 + pax_open_kernel();
91833 sock_diag_handlers[family] = NULL;
91834 + pax_close_kernel();
91835 mutex_unlock(&sock_diag_table_mutex);
91836 }
91837 EXPORT_SYMBOL_GPL(sock_diag_unregister);
91838 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
91839 index 31107ab..ae03d5a 100644
91840 --- a/net/core/sysctl_net_core.c
91841 +++ b/net/core/sysctl_net_core.c
91842 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
91843 {
91844 unsigned int orig_size, size;
91845 int ret, i;
91846 - struct ctl_table tmp = {
91847 + ctl_table_no_const tmp = {
91848 .data = &size,
91849 .maxlen = sizeof(size),
91850 .mode = table->mode
91851 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
91852
91853 static __net_init int sysctl_core_net_init(struct net *net)
91854 {
91855 - struct ctl_table *tbl;
91856 + ctl_table_no_const *tbl = NULL;
91857
91858 net->core.sysctl_somaxconn = SOMAXCONN;
91859
91860 - tbl = netns_core_table;
91861 if (!net_eq(net, &init_net)) {
91862 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
91863 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
91864 if (tbl == NULL)
91865 goto err_dup;
91866
91867 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
91868 if (net->user_ns != &init_user_ns) {
91869 tbl[0].procname = NULL;
91870 }
91871 - }
91872 -
91873 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91874 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91875 + } else
91876 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
91877 if (net->core.sysctl_hdr == NULL)
91878 goto err_reg;
91879
91880 return 0;
91881
91882 err_reg:
91883 - if (tbl != netns_core_table)
91884 - kfree(tbl);
91885 + kfree(tbl);
91886 err_dup:
91887 return -ENOMEM;
91888 }
91889 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
91890 kfree(tbl);
91891 }
91892
91893 -static __net_initdata struct pernet_operations sysctl_core_ops = {
91894 +static __net_initconst struct pernet_operations sysctl_core_ops = {
91895 .init = sysctl_core_net_init,
91896 .exit = sysctl_core_net_exit,
91897 };
91898 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
91899 index dd4d506..fb2fb87 100644
91900 --- a/net/decnet/af_decnet.c
91901 +++ b/net/decnet/af_decnet.c
91902 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
91903 .sysctl_rmem = sysctl_decnet_rmem,
91904 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
91905 .obj_size = sizeof(struct dn_sock),
91906 + .slab_flags = SLAB_USERCOPY,
91907 };
91908
91909 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
91910 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
91911 index 5325b54..a0d4d69 100644
91912 --- a/net/decnet/sysctl_net_decnet.c
91913 +++ b/net/decnet/sysctl_net_decnet.c
91914 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
91915
91916 if (len > *lenp) len = *lenp;
91917
91918 - if (copy_to_user(buffer, addr, len))
91919 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
91920 return -EFAULT;
91921
91922 *lenp = len;
91923 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
91924
91925 if (len > *lenp) len = *lenp;
91926
91927 - if (copy_to_user(buffer, devname, len))
91928 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
91929 return -EFAULT;
91930
91931 *lenp = len;
91932 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
91933 index 3b9d5f2..d7015c6 100644
91934 --- a/net/ieee802154/6lowpan.c
91935 +++ b/net/ieee802154/6lowpan.c
91936 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
91937 hc06_ptr += 3;
91938 } else {
91939 /* compress nothing */
91940 - memcpy(hc06_ptr, &hdr, 4);
91941 + memcpy(hc06_ptr, hdr, 4);
91942 /* replace the top byte with new ECN | DSCP format */
91943 *hc06_ptr = tmp;
91944 hc06_ptr += 4;
91945 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
91946 index b4d0be2..443d0f0 100644
91947 --- a/net/ipv4/af_inet.c
91948 +++ b/net/ipv4/af_inet.c
91949 @@ -1689,13 +1689,9 @@ static int __init inet_init(void)
91950
91951 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
91952
91953 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
91954 - if (!sysctl_local_reserved_ports)
91955 - goto out;
91956 -
91957 rc = proto_register(&tcp_prot, 1);
91958 if (rc)
91959 - goto out_free_reserved_ports;
91960 + goto out;
91961
91962 rc = proto_register(&udp_prot, 1);
91963 if (rc)
91964 @@ -1804,8 +1800,6 @@ out_unregister_udp_proto:
91965 proto_unregister(&udp_prot);
91966 out_unregister_tcp_proto:
91967 proto_unregister(&tcp_prot);
91968 -out_free_reserved_ports:
91969 - kfree(sysctl_local_reserved_ports);
91970 goto out;
91971 }
91972
91973 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
91974 index 34ca6d5..b6421e8 100644
91975 --- a/net/ipv4/devinet.c
91976 +++ b/net/ipv4/devinet.c
91977 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
91978 idx = 0;
91979 head = &net->dev_index_head[h];
91980 rcu_read_lock();
91981 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91982 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91983 net->dev_base_seq;
91984 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91985 if (idx < s_idx)
91986 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
91987 idx = 0;
91988 head = &net->dev_index_head[h];
91989 rcu_read_lock();
91990 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91991 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91992 net->dev_base_seq;
91993 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91994 if (idx < s_idx)
91995 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
91996 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
91997 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
91998
91999 -static struct devinet_sysctl_table {
92000 +static const struct devinet_sysctl_table {
92001 struct ctl_table_header *sysctl_header;
92002 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92003 } devinet_sysctl = {
92004 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92005 int err;
92006 struct ipv4_devconf *all, *dflt;
92007 #ifdef CONFIG_SYSCTL
92008 - struct ctl_table *tbl = ctl_forward_entry;
92009 + ctl_table_no_const *tbl = NULL;
92010 struct ctl_table_header *forw_hdr;
92011 #endif
92012
92013 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92014 goto err_alloc_dflt;
92015
92016 #ifdef CONFIG_SYSCTL
92017 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92018 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92019 if (tbl == NULL)
92020 goto err_alloc_ctl;
92021
92022 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92023 goto err_reg_dflt;
92024
92025 err = -ENOMEM;
92026 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92027 + if (!net_eq(net, &init_net))
92028 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92029 + else
92030 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92031 if (forw_hdr == NULL)
92032 goto err_reg_ctl;
92033 net->ipv4.forw_hdr = forw_hdr;
92034 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92035 err_reg_dflt:
92036 __devinet_sysctl_unregister(all);
92037 err_reg_all:
92038 - if (tbl != ctl_forward_entry)
92039 - kfree(tbl);
92040 + kfree(tbl);
92041 err_alloc_ctl:
92042 #endif
92043 if (dflt != &ipv4_devconf_dflt)
92044 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92045 index b3f627a..b0f3e99 100644
92046 --- a/net/ipv4/fib_frontend.c
92047 +++ b/net/ipv4/fib_frontend.c
92048 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92049 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92050 fib_sync_up(dev);
92051 #endif
92052 - atomic_inc(&net->ipv4.dev_addr_genid);
92053 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92054 rt_cache_flush(dev_net(dev));
92055 break;
92056 case NETDEV_DOWN:
92057 fib_del_ifaddr(ifa, NULL);
92058 - atomic_inc(&net->ipv4.dev_addr_genid);
92059 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92060 if (ifa->ifa_dev->ifa_list == NULL) {
92061 /* Last address was deleted from this interface.
92062 * Disable IP.
92063 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92064 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92065 fib_sync_up(dev);
92066 #endif
92067 - atomic_inc(&net->ipv4.dev_addr_genid);
92068 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92069 rt_cache_flush(net);
92070 break;
92071 case NETDEV_DOWN:
92072 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92073 index d5dbca5..6251d5f 100644
92074 --- a/net/ipv4/fib_semantics.c
92075 +++ b/net/ipv4/fib_semantics.c
92076 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92077 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92078 nh->nh_gw,
92079 nh->nh_parent->fib_scope);
92080 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92081 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92082
92083 return nh->nh_saddr;
92084 }
92085 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92086 index 6acb541..9ea617d 100644
92087 --- a/net/ipv4/inet_connection_sock.c
92088 +++ b/net/ipv4/inet_connection_sock.c
92089 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92090 .range = { 32768, 61000 },
92091 };
92092
92093 -unsigned long *sysctl_local_reserved_ports;
92094 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92095 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92096
92097 void inet_get_local_port_range(int *low, int *high)
92098 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92099 index 7bd8983..3abdcf6 100644
92100 --- a/net/ipv4/inet_hashtables.c
92101 +++ b/net/ipv4/inet_hashtables.c
92102 @@ -18,12 +18,15 @@
92103 #include <linux/sched.h>
92104 #include <linux/slab.h>
92105 #include <linux/wait.h>
92106 +#include <linux/security.h>
92107
92108 #include <net/inet_connection_sock.h>
92109 #include <net/inet_hashtables.h>
92110 #include <net/secure_seq.h>
92111 #include <net/ip.h>
92112
92113 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92114 +
92115 /*
92116 * Allocate and initialize a new local port bind bucket.
92117 * The bindhash mutex for snum's hash chain must be held here.
92118 @@ -554,6 +557,8 @@ ok:
92119 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92120 spin_unlock(&head->lock);
92121
92122 + gr_update_task_in_ip_table(current, inet_sk(sk));
92123 +
92124 if (tw) {
92125 inet_twsk_deschedule(tw, death_row);
92126 while (twrefcnt) {
92127 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92128 index 000e3d2..5472da3 100644
92129 --- a/net/ipv4/inetpeer.c
92130 +++ b/net/ipv4/inetpeer.c
92131 @@ -503,8 +503,8 @@ relookup:
92132 if (p) {
92133 p->daddr = *daddr;
92134 atomic_set(&p->refcnt, 1);
92135 - atomic_set(&p->rid, 0);
92136 - atomic_set(&p->ip_id_count,
92137 + atomic_set_unchecked(&p->rid, 0);
92138 + atomic_set_unchecked(&p->ip_id_count,
92139 (daddr->family == AF_INET) ?
92140 secure_ip_id(daddr->addr.a4) :
92141 secure_ipv6_id(daddr->addr.a6));
92142 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92143 index b66910a..cfe416e 100644
92144 --- a/net/ipv4/ip_fragment.c
92145 +++ b/net/ipv4/ip_fragment.c
92146 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92147 return 0;
92148
92149 start = qp->rid;
92150 - end = atomic_inc_return(&peer->rid);
92151 + end = atomic_inc_return_unchecked(&peer->rid);
92152 qp->rid = end;
92153
92154 rc = qp->q.fragments && (end - start) > max;
92155 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92156
92157 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92158 {
92159 - struct ctl_table *table;
92160 + ctl_table_no_const *table = NULL;
92161 struct ctl_table_header *hdr;
92162
92163 - table = ip4_frags_ns_ctl_table;
92164 if (!net_eq(net, &init_net)) {
92165 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92166 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92167 if (table == NULL)
92168 goto err_alloc;
92169
92170 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92171 /* Don't export sysctls to unprivileged users */
92172 if (net->user_ns != &init_user_ns)
92173 table[0].procname = NULL;
92174 - }
92175 + hdr = register_net_sysctl(net, "net/ipv4", table);
92176 + } else
92177 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92178
92179 - hdr = register_net_sysctl(net, "net/ipv4", table);
92180 if (hdr == NULL)
92181 goto err_reg;
92182
92183 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92184 return 0;
92185
92186 err_reg:
92187 - if (!net_eq(net, &init_net))
92188 - kfree(table);
92189 + kfree(table);
92190 err_alloc:
92191 return -ENOMEM;
92192 }
92193 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92194 index 8d6939e..19d0a95 100644
92195 --- a/net/ipv4/ip_gre.c
92196 +++ b/net/ipv4/ip_gre.c
92197 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92198 module_param(log_ecn_error, bool, 0644);
92199 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92200
92201 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92202 +static struct rtnl_link_ops ipgre_link_ops;
92203 static int ipgre_tunnel_init(struct net_device *dev);
92204
92205 static int ipgre_net_id __read_mostly;
92206 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92207 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92208 };
92209
92210 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92211 +static struct rtnl_link_ops ipgre_link_ops = {
92212 .kind = "gre",
92213 .maxtype = IFLA_GRE_MAX,
92214 .policy = ipgre_policy,
92215 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92216 .fill_info = ipgre_fill_info,
92217 };
92218
92219 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92220 +static struct rtnl_link_ops ipgre_tap_ops = {
92221 .kind = "gretap",
92222 .maxtype = IFLA_GRE_MAX,
92223 .policy = ipgre_policy,
92224 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92225 index d9c4f11..02b82dbc 100644
92226 --- a/net/ipv4/ip_sockglue.c
92227 +++ b/net/ipv4/ip_sockglue.c
92228 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92229 len = min_t(unsigned int, len, opt->optlen);
92230 if (put_user(len, optlen))
92231 return -EFAULT;
92232 - if (copy_to_user(optval, opt->__data, len))
92233 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92234 + copy_to_user(optval, opt->__data, len))
92235 return -EFAULT;
92236 return 0;
92237 }
92238 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92239 if (sk->sk_type != SOCK_STREAM)
92240 return -ENOPROTOOPT;
92241
92242 - msg.msg_control = optval;
92243 + msg.msg_control = (void __force_kernel *)optval;
92244 msg.msg_controllen = len;
92245 msg.msg_flags = flags;
92246
92247 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92248 index 17cc0ff..63856c4 100644
92249 --- a/net/ipv4/ip_vti.c
92250 +++ b/net/ipv4/ip_vti.c
92251 @@ -47,7 +47,7 @@
92252 #define HASH_SIZE 16
92253 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92254
92255 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92256 +static struct rtnl_link_ops vti_link_ops;
92257
92258 static int vti_net_id __read_mostly;
92259 struct vti_net {
92260 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92261 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92262 };
92263
92264 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92265 +static struct rtnl_link_ops vti_link_ops = {
92266 .kind = "vti",
92267 .maxtype = IFLA_VTI_MAX,
92268 .policy = vti_policy,
92269 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92270 index efa1138..20dbba0 100644
92271 --- a/net/ipv4/ipconfig.c
92272 +++ b/net/ipv4/ipconfig.c
92273 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92274
92275 mm_segment_t oldfs = get_fs();
92276 set_fs(get_ds());
92277 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92278 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92279 set_fs(oldfs);
92280 return res;
92281 }
92282 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92283
92284 mm_segment_t oldfs = get_fs();
92285 set_fs(get_ds());
92286 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92287 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92288 set_fs(oldfs);
92289 return res;
92290 }
92291 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92292
92293 mm_segment_t oldfs = get_fs();
92294 set_fs(get_ds());
92295 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92296 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92297 set_fs(oldfs);
92298 return res;
92299 }
92300 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92301 index b3ac3c3..ec6bd95 100644
92302 --- a/net/ipv4/ipip.c
92303 +++ b/net/ipv4/ipip.c
92304 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92305 static int ipip_net_id __read_mostly;
92306
92307 static int ipip_tunnel_init(struct net_device *dev);
92308 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92309 +static struct rtnl_link_ops ipip_link_ops;
92310
92311 static int ipip_err(struct sk_buff *skb, u32 info)
92312 {
92313 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92314 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92315 };
92316
92317 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92318 +static struct rtnl_link_ops ipip_link_ops = {
92319 .kind = "ipip",
92320 .maxtype = IFLA_IPTUN_MAX,
92321 .policy = ipip_policy,
92322 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92323 index 85a4f21..1beb1f5 100644
92324 --- a/net/ipv4/netfilter/arp_tables.c
92325 +++ b/net/ipv4/netfilter/arp_tables.c
92326 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92327 #endif
92328
92329 static int get_info(struct net *net, void __user *user,
92330 - const int *len, int compat)
92331 + int len, int compat)
92332 {
92333 char name[XT_TABLE_MAXNAMELEN];
92334 struct xt_table *t;
92335 int ret;
92336
92337 - if (*len != sizeof(struct arpt_getinfo)) {
92338 - duprintf("length %u != %Zu\n", *len,
92339 + if (len != sizeof(struct arpt_getinfo)) {
92340 + duprintf("length %u != %Zu\n", len,
92341 sizeof(struct arpt_getinfo));
92342 return -EINVAL;
92343 }
92344 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92345 info.size = private->size;
92346 strcpy(info.name, name);
92347
92348 - if (copy_to_user(user, &info, *len) != 0)
92349 + if (copy_to_user(user, &info, len) != 0)
92350 ret = -EFAULT;
92351 else
92352 ret = 0;
92353 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92354
92355 switch (cmd) {
92356 case ARPT_SO_GET_INFO:
92357 - ret = get_info(sock_net(sk), user, len, 1);
92358 + ret = get_info(sock_net(sk), user, *len, 1);
92359 break;
92360 case ARPT_SO_GET_ENTRIES:
92361 ret = compat_get_entries(sock_net(sk), user, len);
92362 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92363
92364 switch (cmd) {
92365 case ARPT_SO_GET_INFO:
92366 - ret = get_info(sock_net(sk), user, len, 0);
92367 + ret = get_info(sock_net(sk), user, *len, 0);
92368 break;
92369
92370 case ARPT_SO_GET_ENTRIES:
92371 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92372 index d23118d..6ad7277 100644
92373 --- a/net/ipv4/netfilter/ip_tables.c
92374 +++ b/net/ipv4/netfilter/ip_tables.c
92375 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92376 #endif
92377
92378 static int get_info(struct net *net, void __user *user,
92379 - const int *len, int compat)
92380 + int len, int compat)
92381 {
92382 char name[XT_TABLE_MAXNAMELEN];
92383 struct xt_table *t;
92384 int ret;
92385
92386 - if (*len != sizeof(struct ipt_getinfo)) {
92387 - duprintf("length %u != %zu\n", *len,
92388 + if (len != sizeof(struct ipt_getinfo)) {
92389 + duprintf("length %u != %zu\n", len,
92390 sizeof(struct ipt_getinfo));
92391 return -EINVAL;
92392 }
92393 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92394 info.size = private->size;
92395 strcpy(info.name, name);
92396
92397 - if (copy_to_user(user, &info, *len) != 0)
92398 + if (copy_to_user(user, &info, len) != 0)
92399 ret = -EFAULT;
92400 else
92401 ret = 0;
92402 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92403
92404 switch (cmd) {
92405 case IPT_SO_GET_INFO:
92406 - ret = get_info(sock_net(sk), user, len, 1);
92407 + ret = get_info(sock_net(sk), user, *len, 1);
92408 break;
92409 case IPT_SO_GET_ENTRIES:
92410 ret = compat_get_entries(sock_net(sk), user, len);
92411 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92412
92413 switch (cmd) {
92414 case IPT_SO_GET_INFO:
92415 - ret = get_info(sock_net(sk), user, len, 0);
92416 + ret = get_info(sock_net(sk), user, *len, 0);
92417 break;
92418
92419 case IPT_SO_GET_ENTRIES:
92420 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92421 index 746427c..80eab72 100644
92422 --- a/net/ipv4/ping.c
92423 +++ b/net/ipv4/ping.c
92424 @@ -55,7 +55,7 @@
92425
92426
92427 struct ping_table ping_table;
92428 -struct pingv6_ops pingv6_ops;
92429 +struct pingv6_ops *pingv6_ops;
92430 EXPORT_SYMBOL_GPL(pingv6_ops);
92431
92432 static u16 ping_port_rover;
92433 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92434 return -ENODEV;
92435 }
92436 }
92437 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92438 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92439 scoped);
92440 rcu_read_unlock();
92441
92442 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92443 }
92444 #if IS_ENABLED(CONFIG_IPV6)
92445 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92446 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92447 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92448 #endif
92449 }
92450
92451 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92452 info, (u8 *)icmph);
92453 #if IS_ENABLED(CONFIG_IPV6)
92454 } else if (family == AF_INET6) {
92455 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92456 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92457 info, (u8 *)icmph);
92458 #endif
92459 }
92460 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92461 return ip_recv_error(sk, msg, len);
92462 #if IS_ENABLED(CONFIG_IPV6)
92463 } else if (family == AF_INET6) {
92464 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92465 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92466 #endif
92467 }
92468 }
92469 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92470 IP6CB(skb)->iif);
92471
92472 if (inet6_sk(sk)->rxopt.all)
92473 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92474 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92475 #endif
92476 } else {
92477 BUG();
92478 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92479 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92480 0, sock_i_ino(sp),
92481 atomic_read(&sp->sk_refcnt), sp,
92482 - atomic_read(&sp->sk_drops), len);
92483 + atomic_read_unchecked(&sp->sk_drops), len);
92484 }
92485
92486 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92487 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92488 index 61e60d6..d6996cd 100644
92489 --- a/net/ipv4/raw.c
92490 +++ b/net/ipv4/raw.c
92491 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92492 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92493 {
92494 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92495 - atomic_inc(&sk->sk_drops);
92496 + atomic_inc_unchecked(&sk->sk_drops);
92497 kfree_skb(skb);
92498 return NET_RX_DROP;
92499 }
92500 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92501
92502 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92503 {
92504 + struct icmp_filter filter;
92505 +
92506 if (optlen > sizeof(struct icmp_filter))
92507 optlen = sizeof(struct icmp_filter);
92508 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92509 + if (copy_from_user(&filter, optval, optlen))
92510 return -EFAULT;
92511 + raw_sk(sk)->filter = filter;
92512 return 0;
92513 }
92514
92515 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92516 {
92517 int len, ret = -EFAULT;
92518 + struct icmp_filter filter;
92519
92520 if (get_user(len, optlen))
92521 goto out;
92522 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92523 if (len > sizeof(struct icmp_filter))
92524 len = sizeof(struct icmp_filter);
92525 ret = -EFAULT;
92526 - if (put_user(len, optlen) ||
92527 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92528 + filter = raw_sk(sk)->filter;
92529 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92530 goto out;
92531 ret = 0;
92532 out: return ret;
92533 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92534 0, 0L, 0,
92535 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92536 0, sock_i_ino(sp),
92537 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92538 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92539 }
92540
92541 static int raw_seq_show(struct seq_file *seq, void *v)
92542 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92543 index a9a54a2..647316e 100644
92544 --- a/net/ipv4/route.c
92545 +++ b/net/ipv4/route.c
92546 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92547 .maxlen = sizeof(int),
92548 .mode = 0200,
92549 .proc_handler = ipv4_sysctl_rtcache_flush,
92550 + .extra1 = &init_net,
92551 },
92552 { },
92553 };
92554
92555 static __net_init int sysctl_route_net_init(struct net *net)
92556 {
92557 - struct ctl_table *tbl;
92558 + ctl_table_no_const *tbl = NULL;
92559
92560 - tbl = ipv4_route_flush_table;
92561 if (!net_eq(net, &init_net)) {
92562 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92563 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92564 if (tbl == NULL)
92565 goto err_dup;
92566
92567 /* Don't export sysctls to unprivileged users */
92568 if (net->user_ns != &init_user_ns)
92569 tbl[0].procname = NULL;
92570 - }
92571 - tbl[0].extra1 = net;
92572 + tbl[0].extra1 = net;
92573 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92574 + } else
92575 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92576
92577 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92578 if (net->ipv4.route_hdr == NULL)
92579 goto err_reg;
92580 return 0;
92581
92582 err_reg:
92583 - if (tbl != ipv4_route_flush_table)
92584 - kfree(tbl);
92585 + kfree(tbl);
92586 err_dup:
92587 return -ENOMEM;
92588 }
92589 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92590
92591 static __net_init int rt_genid_init(struct net *net)
92592 {
92593 - atomic_set(&net->rt_genid, 0);
92594 - atomic_set(&net->fnhe_genid, 0);
92595 + atomic_set_unchecked(&net->rt_genid, 0);
92596 + atomic_set_unchecked(&net->fnhe_genid, 0);
92597 get_random_bytes(&net->ipv4.dev_addr_genid,
92598 sizeof(net->ipv4.dev_addr_genid));
92599 return 0;
92600 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92601 index 610e324..fd42e75 100644
92602 --- a/net/ipv4/sysctl_net_ipv4.c
92603 +++ b/net/ipv4/sysctl_net_ipv4.c
92604 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92605 {
92606 int ret;
92607 int range[2];
92608 - struct ctl_table tmp = {
92609 + ctl_table_no_const tmp = {
92610 .data = &range,
92611 .maxlen = sizeof(range),
92612 .mode = table->mode,
92613 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92614 int ret;
92615 gid_t urange[2];
92616 kgid_t low, high;
92617 - struct ctl_table tmp = {
92618 + ctl_table_no_const tmp = {
92619 .data = &urange,
92620 .maxlen = sizeof(urange),
92621 .mode = table->mode,
92622 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92623 void __user *buffer, size_t *lenp, loff_t *ppos)
92624 {
92625 char val[TCP_CA_NAME_MAX];
92626 - struct ctl_table tbl = {
92627 + ctl_table_no_const tbl = {
92628 .data = val,
92629 .maxlen = TCP_CA_NAME_MAX,
92630 };
92631 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92632 void __user *buffer, size_t *lenp,
92633 loff_t *ppos)
92634 {
92635 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92636 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92637 int ret;
92638
92639 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92640 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92641 void __user *buffer, size_t *lenp,
92642 loff_t *ppos)
92643 {
92644 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92645 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92646 int ret;
92647
92648 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92649 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92650 struct mem_cgroup *memcg;
92651 #endif
92652
92653 - struct ctl_table tmp = {
92654 + ctl_table_no_const tmp = {
92655 .data = &vec,
92656 .maxlen = sizeof(vec),
92657 .mode = ctl->mode,
92658 };
92659
92660 if (!write) {
92661 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92662 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92663 + ctl_table_no_const tcp_mem = *ctl;
92664 +
92665 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92666 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92667 }
92668
92669 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92670 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92671 void __user *buffer, size_t *lenp,
92672 loff_t *ppos)
92673 {
92674 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92675 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92676 struct tcp_fastopen_context *ctxt;
92677 int ret;
92678 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92679 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
92680 },
92681 {
92682 .procname = "ip_local_reserved_ports",
92683 - .data = NULL, /* initialized in sysctl_ipv4_init */
92684 + .data = sysctl_local_reserved_ports,
92685 .maxlen = 65536,
92686 .mode = 0644,
92687 .proc_handler = proc_do_large_bitmap,
92688 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
92689
92690 static __net_init int ipv4_sysctl_init_net(struct net *net)
92691 {
92692 - struct ctl_table *table;
92693 + ctl_table_no_const *table = NULL;
92694
92695 - table = ipv4_net_table;
92696 if (!net_eq(net, &init_net)) {
92697 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92698 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92699 if (table == NULL)
92700 goto err_alloc;
92701
92702 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92703
92704 tcp_init_mem(net);
92705
92706 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92707 + if (!net_eq(net, &init_net))
92708 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92709 + else
92710 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92711 if (net->ipv4.ipv4_hdr == NULL)
92712 goto err_reg;
92713
92714 return 0;
92715
92716 err_reg:
92717 - if (!net_eq(net, &init_net))
92718 - kfree(table);
92719 + kfree(table);
92720 err_alloc:
92721 return -ENOMEM;
92722 }
92723 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92724 static __init int sysctl_ipv4_init(void)
92725 {
92726 struct ctl_table_header *hdr;
92727 - struct ctl_table *i;
92728 -
92729 - for (i = ipv4_table; i->procname; i++) {
92730 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92731 - i->data = sysctl_local_reserved_ports;
92732 - break;
92733 - }
92734 - }
92735 - if (!i->procname)
92736 - return -EINVAL;
92737
92738 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92739 if (hdr == NULL)
92740 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92741 index 3ca2139..c4cc060 100644
92742 --- a/net/ipv4/tcp_input.c
92743 +++ b/net/ipv4/tcp_input.c
92744 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92745 * simplifies code)
92746 */
92747 static void
92748 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92749 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92750 struct sk_buff *head, struct sk_buff *tail,
92751 u32 start, u32 end)
92752 {
92753 @@ -5465,6 +5465,7 @@ discard:
92754 tcp_paws_reject(&tp->rx_opt, 0))
92755 goto discard_and_undo;
92756
92757 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92758 if (th->syn) {
92759 /* We see SYN without ACK. It is attempt of
92760 * simultaneous connect with crossed SYNs.
92761 @@ -5515,6 +5516,7 @@ discard:
92762 goto discard;
92763 #endif
92764 }
92765 +#endif
92766 /* "fifth, if neither of the SYN or RST bits is set then
92767 * drop the segment and return."
92768 */
92769 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92770 goto discard;
92771
92772 if (th->syn) {
92773 - if (th->fin)
92774 + if (th->fin || th->urg || th->psh)
92775 goto discard;
92776 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
92777 return 1;
92778 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
92779 index b299da5..097db06 100644
92780 --- a/net/ipv4/tcp_ipv4.c
92781 +++ b/net/ipv4/tcp_ipv4.c
92782 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
92783 EXPORT_SYMBOL(sysctl_tcp_low_latency);
92784
92785
92786 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92787 +extern int grsec_enable_blackhole;
92788 +#endif
92789 +
92790 #ifdef CONFIG_TCP_MD5SIG
92791 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
92792 __be32 daddr, __be32 saddr, const struct tcphdr *th);
92793 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
92794 return 0;
92795
92796 reset:
92797 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92798 + if (!grsec_enable_blackhole)
92799 +#endif
92800 tcp_v4_send_reset(rsk, skb);
92801 discard:
92802 kfree_skb(skb);
92803 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
92804 TCP_SKB_CB(skb)->sacked = 0;
92805
92806 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92807 - if (!sk)
92808 + if (!sk) {
92809 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92810 + ret = 1;
92811 +#endif
92812 goto no_tcp_socket;
92813 -
92814 + }
92815 process:
92816 - if (sk->sk_state == TCP_TIME_WAIT)
92817 + if (sk->sk_state == TCP_TIME_WAIT) {
92818 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92819 + ret = 2;
92820 +#endif
92821 goto do_time_wait;
92822 + }
92823
92824 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
92825 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92826 @@ -2034,6 +2048,10 @@ csum_error:
92827 bad_packet:
92828 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92829 } else {
92830 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92831 + if (!grsec_enable_blackhole || (ret == 1 &&
92832 + (skb->dev->flags & IFF_LOOPBACK)))
92833 +#endif
92834 tcp_v4_send_reset(NULL, skb);
92835 }
92836
92837 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
92838 index ab1c086..2a8d76b 100644
92839 --- a/net/ipv4/tcp_minisocks.c
92840 +++ b/net/ipv4/tcp_minisocks.c
92841 @@ -27,6 +27,10 @@
92842 #include <net/inet_common.h>
92843 #include <net/xfrm.h>
92844
92845 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92846 +extern int grsec_enable_blackhole;
92847 +#endif
92848 +
92849 int sysctl_tcp_syncookies __read_mostly = 1;
92850 EXPORT_SYMBOL(sysctl_tcp_syncookies);
92851
92852 @@ -715,7 +719,10 @@ embryonic_reset:
92853 * avoid becoming vulnerable to outside attack aiming at
92854 * resetting legit local connections.
92855 */
92856 - req->rsk_ops->send_reset(sk, skb);
92857 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92858 + if (!grsec_enable_blackhole)
92859 +#endif
92860 + req->rsk_ops->send_reset(sk, skb);
92861 } else if (fastopen) { /* received a valid RST pkt */
92862 reqsk_fastopen_remove(sk, req, true);
92863 tcp_reset(sk);
92864 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
92865 index d4943f6..e7a74a5 100644
92866 --- a/net/ipv4/tcp_probe.c
92867 +++ b/net/ipv4/tcp_probe.c
92868 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
92869 if (cnt + width >= len)
92870 break;
92871
92872 - if (copy_to_user(buf + cnt, tbuf, width))
92873 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
92874 return -EFAULT;
92875 cnt += width;
92876 }
92877 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
92878 index 4b85e6f..22f9ac9 100644
92879 --- a/net/ipv4/tcp_timer.c
92880 +++ b/net/ipv4/tcp_timer.c
92881 @@ -22,6 +22,10 @@
92882 #include <linux/gfp.h>
92883 #include <net/tcp.h>
92884
92885 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92886 +extern int grsec_lastack_retries;
92887 +#endif
92888 +
92889 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
92890 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
92891 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
92892 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
92893 }
92894 }
92895
92896 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92897 + if ((sk->sk_state == TCP_LAST_ACK) &&
92898 + (grsec_lastack_retries > 0) &&
92899 + (grsec_lastack_retries < retry_until))
92900 + retry_until = grsec_lastack_retries;
92901 +#endif
92902 +
92903 if (retransmits_timed_out(sk, retry_until,
92904 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
92905 /* Has it gone just too far? */
92906 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
92907 index 766e6ba..aff2f8d 100644
92908 --- a/net/ipv4/udp.c
92909 +++ b/net/ipv4/udp.c
92910 @@ -87,6 +87,7 @@
92911 #include <linux/types.h>
92912 #include <linux/fcntl.h>
92913 #include <linux/module.h>
92914 +#include <linux/security.h>
92915 #include <linux/socket.h>
92916 #include <linux/sockios.h>
92917 #include <linux/igmp.h>
92918 @@ -112,6 +113,10 @@
92919 #include <net/busy_poll.h>
92920 #include "udp_impl.h"
92921
92922 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92923 +extern int grsec_enable_blackhole;
92924 +#endif
92925 +
92926 struct udp_table udp_table __read_mostly;
92927 EXPORT_SYMBOL(udp_table);
92928
92929 @@ -595,6 +600,9 @@ found:
92930 return s;
92931 }
92932
92933 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
92934 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
92935 +
92936 /*
92937 * This routine is called by the ICMP module when it gets some
92938 * sort of error condition. If err < 0 then the socket should
92939 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92940 dport = usin->sin_port;
92941 if (dport == 0)
92942 return -EINVAL;
92943 +
92944 + err = gr_search_udp_sendmsg(sk, usin);
92945 + if (err)
92946 + return err;
92947 } else {
92948 if (sk->sk_state != TCP_ESTABLISHED)
92949 return -EDESTADDRREQ;
92950 +
92951 + err = gr_search_udp_sendmsg(sk, NULL);
92952 + if (err)
92953 + return err;
92954 +
92955 daddr = inet->inet_daddr;
92956 dport = inet->inet_dport;
92957 /* Open fast path for connected socket.
92958 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
92959 IS_UDPLITE(sk));
92960 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92961 IS_UDPLITE(sk));
92962 - atomic_inc(&sk->sk_drops);
92963 + atomic_inc_unchecked(&sk->sk_drops);
92964 __skb_unlink(skb, rcvq);
92965 __skb_queue_tail(&list_kill, skb);
92966 }
92967 @@ -1223,6 +1240,10 @@ try_again:
92968 if (!skb)
92969 goto out;
92970
92971 + err = gr_search_udp_recvmsg(sk, skb);
92972 + if (err)
92973 + goto out_free;
92974 +
92975 ulen = skb->len - sizeof(struct udphdr);
92976 copied = len;
92977 if (copied > ulen)
92978 @@ -1256,7 +1277,7 @@ try_again:
92979 if (unlikely(err)) {
92980 trace_kfree_skb(skb, udp_recvmsg);
92981 if (!peeked) {
92982 - atomic_inc(&sk->sk_drops);
92983 + atomic_inc_unchecked(&sk->sk_drops);
92984 UDP_INC_STATS_USER(sock_net(sk),
92985 UDP_MIB_INERRORS, is_udplite);
92986 }
92987 @@ -1543,7 +1564,7 @@ csum_error:
92988 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
92989 drop:
92990 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
92991 - atomic_inc(&sk->sk_drops);
92992 + atomic_inc_unchecked(&sk->sk_drops);
92993 kfree_skb(skb);
92994 return -1;
92995 }
92996 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
92997 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
92998
92999 if (!skb1) {
93000 - atomic_inc(&sk->sk_drops);
93001 + atomic_inc_unchecked(&sk->sk_drops);
93002 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93003 IS_UDPLITE(sk));
93004 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93005 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93006 goto csum_error;
93007
93008 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93009 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93010 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93011 +#endif
93012 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93013
93014 /*
93015 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93016 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93017 0, sock_i_ino(sp),
93018 atomic_read(&sp->sk_refcnt), sp,
93019 - atomic_read(&sp->sk_drops), len);
93020 + atomic_read_unchecked(&sp->sk_drops), len);
93021 }
93022
93023 int udp4_seq_show(struct seq_file *seq, void *v)
93024 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93025 index 9a459be..c7bc04c 100644
93026 --- a/net/ipv4/xfrm4_policy.c
93027 +++ b/net/ipv4/xfrm4_policy.c
93028 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93029 fl4->flowi4_tos = iph->tos;
93030 }
93031
93032 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93033 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93034 {
93035 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93036
93037 - xfrm4_policy_afinfo.garbage_collect(net);
93038 + xfrm_garbage_collect_deferred(net);
93039 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93040 }
93041
93042 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93043
93044 static int __net_init xfrm4_net_init(struct net *net)
93045 {
93046 - struct ctl_table *table;
93047 + ctl_table_no_const *table = NULL;
93048 struct ctl_table_header *hdr;
93049
93050 - table = xfrm4_policy_table;
93051 if (!net_eq(net, &init_net)) {
93052 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93053 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93054 if (!table)
93055 goto err_alloc;
93056
93057 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93058 - }
93059 -
93060 - hdr = register_net_sysctl(net, "net/ipv4", table);
93061 + hdr = register_net_sysctl(net, "net/ipv4", table);
93062 + } else
93063 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93064 if (!hdr)
93065 goto err_reg;
93066
93067 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93068 return 0;
93069
93070 err_reg:
93071 - if (!net_eq(net, &init_net))
93072 - kfree(table);
93073 + kfree(table);
93074 err_alloc:
93075 return -ENOMEM;
93076 }
93077 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93078 index 498ea99..42501bc 100644
93079 --- a/net/ipv6/addrconf.c
93080 +++ b/net/ipv6/addrconf.c
93081 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93082 idx = 0;
93083 head = &net->dev_index_head[h];
93084 rcu_read_lock();
93085 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93086 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93087 net->dev_base_seq;
93088 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93089 if (idx < s_idx)
93090 @@ -2381,7 +2381,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93091 p.iph.ihl = 5;
93092 p.iph.protocol = IPPROTO_IPV6;
93093 p.iph.ttl = 64;
93094 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93095 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93096
93097 if (ops->ndo_do_ioctl) {
93098 mm_segment_t oldfs = get_fs();
93099 @@ -4030,7 +4030,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93100 s_ip_idx = ip_idx = cb->args[2];
93101
93102 rcu_read_lock();
93103 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93104 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93105 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93106 idx = 0;
93107 head = &net->dev_index_head[h];
93108 @@ -4651,7 +4651,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93109 dst_free(&ifp->rt->dst);
93110 break;
93111 }
93112 - atomic_inc(&net->ipv6.dev_addr_genid);
93113 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93114 }
93115
93116 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93117 @@ -4671,7 +4671,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93118 int *valp = ctl->data;
93119 int val = *valp;
93120 loff_t pos = *ppos;
93121 - struct ctl_table lctl;
93122 + ctl_table_no_const lctl;
93123 int ret;
93124
93125 /*
93126 @@ -4756,7 +4756,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93127 int *valp = ctl->data;
93128 int val = *valp;
93129 loff_t pos = *ppos;
93130 - struct ctl_table lctl;
93131 + ctl_table_no_const lctl;
93132 int ret;
93133
93134 /*
93135 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93136 index 197e6f4..16d8396 100644
93137 --- a/net/ipv6/datagram.c
93138 +++ b/net/ipv6/datagram.c
93139 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93140 0,
93141 sock_i_ino(sp),
93142 atomic_read(&sp->sk_refcnt), sp,
93143 - atomic_read(&sp->sk_drops));
93144 + atomic_read_unchecked(&sp->sk_drops));
93145 }
93146 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93147 index 7cfc8d2..c5394b6 100644
93148 --- a/net/ipv6/icmp.c
93149 +++ b/net/ipv6/icmp.c
93150 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93151
93152 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93153 {
93154 - struct ctl_table *table;
93155 + ctl_table_no_const *table;
93156
93157 table = kmemdup(ipv6_icmp_table_template,
93158 sizeof(ipv6_icmp_table_template),
93159 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93160 index 90747f1..505320d 100644
93161 --- a/net/ipv6/ip6_gre.c
93162 +++ b/net/ipv6/ip6_gre.c
93163 @@ -74,7 +74,7 @@ struct ip6gre_net {
93164 struct net_device *fb_tunnel_dev;
93165 };
93166
93167 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93168 +static struct rtnl_link_ops ip6gre_link_ops;
93169 static int ip6gre_tunnel_init(struct net_device *dev);
93170 static void ip6gre_tunnel_setup(struct net_device *dev);
93171 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93172 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93173 }
93174
93175
93176 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93177 +static struct inet6_protocol ip6gre_protocol = {
93178 .handler = ip6gre_rcv,
93179 .err_handler = ip6gre_err,
93180 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93181 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93182 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93183 };
93184
93185 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93186 +static struct rtnl_link_ops ip6gre_link_ops = {
93187 .kind = "ip6gre",
93188 .maxtype = IFLA_GRE_MAX,
93189 .policy = ip6gre_policy,
93190 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93191 .fill_info = ip6gre_fill_info,
93192 };
93193
93194 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93195 +static struct rtnl_link_ops ip6gre_tap_ops = {
93196 .kind = "ip6gretap",
93197 .maxtype = IFLA_GRE_MAX,
93198 .policy = ip6gre_policy,
93199 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
93200 index e7ceb6c..44df1c9 100644
93201 --- a/net/ipv6/ip6_output.c
93202 +++ b/net/ipv6/ip6_output.c
93203 @@ -1040,6 +1040,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
93204 * udp datagram
93205 */
93206 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
93207 + struct frag_hdr fhdr;
93208 +
93209 skb = sock_alloc_send_skb(sk,
93210 hh_len + fragheaderlen + transhdrlen + 20,
93211 (flags & MSG_DONTWAIT), &err);
93212 @@ -1061,12 +1063,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
93213 skb->protocol = htons(ETH_P_IPV6);
93214 skb->ip_summed = CHECKSUM_PARTIAL;
93215 skb->csum = 0;
93216 - }
93217 -
93218 - err = skb_append_datato_frags(sk,skb, getfrag, from,
93219 - (length - transhdrlen));
93220 - if (!err) {
93221 - struct frag_hdr fhdr;
93222
93223 /* Specify the length of each IPv6 datagram fragment.
93224 * It has to be a multiple of 8.
93225 @@ -1077,15 +1073,10 @@ static inline int ip6_ufo_append_data(struct sock *sk,
93226 ipv6_select_ident(&fhdr, rt);
93227 skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
93228 __skb_queue_tail(&sk->sk_write_queue, skb);
93229 -
93230 - return 0;
93231 }
93232 - /* There is not enough support do UPD LSO,
93233 - * so follow normal path
93234 - */
93235 - kfree_skb(skb);
93236
93237 - return err;
93238 + return skb_append_datato_frags(sk, skb, getfrag, from,
93239 + (length - transhdrlen));
93240 }
93241
93242 static inline struct ipv6_opt_hdr *ip6_opt_dup(struct ipv6_opt_hdr *src,
93243 @@ -1252,27 +1243,27 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
93244 * --yoshfuji
93245 */
93246
93247 + if ((length > mtu) && dontfrag && (sk->sk_protocol == IPPROTO_UDP ||
93248 + sk->sk_protocol == IPPROTO_RAW)) {
93249 + ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
93250 + return -EMSGSIZE;
93251 + }
93252 +
93253 + skb = skb_peek_tail(&sk->sk_write_queue);
93254 cork->length += length;
93255 - if (length > mtu) {
93256 - int proto = sk->sk_protocol;
93257 - if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){
93258 - ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
93259 - return -EMSGSIZE;
93260 - }
93261 -
93262 - if (proto == IPPROTO_UDP &&
93263 - (rt->dst.dev->features & NETIF_F_UFO)) {
93264 -
93265 - err = ip6_ufo_append_data(sk, getfrag, from, length,
93266 - hh_len, fragheaderlen,
93267 - transhdrlen, mtu, flags, rt);
93268 - if (err)
93269 - goto error;
93270 - return 0;
93271 - }
93272 + if (((length > mtu) ||
93273 + (skb && skb_is_gso(skb))) &&
93274 + (sk->sk_protocol == IPPROTO_UDP) &&
93275 + (rt->dst.dev->features & NETIF_F_UFO)) {
93276 + err = ip6_ufo_append_data(sk, getfrag, from, length,
93277 + hh_len, fragheaderlen,
93278 + transhdrlen, mtu, flags, rt);
93279 + if (err)
93280 + goto error;
93281 + return 0;
93282 }
93283
93284 - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
93285 + if (!skb)
93286 goto alloc_new_skb;
93287
93288 while (length > 0) {
93289 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93290 index 46ba243..576f50e 100644
93291 --- a/net/ipv6/ip6_tunnel.c
93292 +++ b/net/ipv6/ip6_tunnel.c
93293 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93294
93295 static int ip6_tnl_dev_init(struct net_device *dev);
93296 static void ip6_tnl_dev_setup(struct net_device *dev);
93297 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93298 +static struct rtnl_link_ops ip6_link_ops;
93299
93300 static int ip6_tnl_net_id __read_mostly;
93301 struct ip6_tnl_net {
93302 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93303 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93304 };
93305
93306 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93307 +static struct rtnl_link_ops ip6_link_ops = {
93308 .kind = "ip6tnl",
93309 .maxtype = IFLA_IPTUN_MAX,
93310 .policy = ip6_tnl_policy,
93311 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93312 index d1e2e8e..51c19ae 100644
93313 --- a/net/ipv6/ipv6_sockglue.c
93314 +++ b/net/ipv6/ipv6_sockglue.c
93315 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93316 if (sk->sk_type != SOCK_STREAM)
93317 return -ENOPROTOOPT;
93318
93319 - msg.msg_control = optval;
93320 + msg.msg_control = (void __force_kernel *)optval;
93321 msg.msg_controllen = len;
93322 msg.msg_flags = flags;
93323
93324 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93325 index 44400c2..8e11f52 100644
93326 --- a/net/ipv6/netfilter/ip6_tables.c
93327 +++ b/net/ipv6/netfilter/ip6_tables.c
93328 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93329 #endif
93330
93331 static int get_info(struct net *net, void __user *user,
93332 - const int *len, int compat)
93333 + int len, int compat)
93334 {
93335 char name[XT_TABLE_MAXNAMELEN];
93336 struct xt_table *t;
93337 int ret;
93338
93339 - if (*len != sizeof(struct ip6t_getinfo)) {
93340 - duprintf("length %u != %zu\n", *len,
93341 + if (len != sizeof(struct ip6t_getinfo)) {
93342 + duprintf("length %u != %zu\n", len,
93343 sizeof(struct ip6t_getinfo));
93344 return -EINVAL;
93345 }
93346 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93347 info.size = private->size;
93348 strcpy(info.name, name);
93349
93350 - if (copy_to_user(user, &info, *len) != 0)
93351 + if (copy_to_user(user, &info, len) != 0)
93352 ret = -EFAULT;
93353 else
93354 ret = 0;
93355 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93356
93357 switch (cmd) {
93358 case IP6T_SO_GET_INFO:
93359 - ret = get_info(sock_net(sk), user, len, 1);
93360 + ret = get_info(sock_net(sk), user, *len, 1);
93361 break;
93362 case IP6T_SO_GET_ENTRIES:
93363 ret = compat_get_entries(sock_net(sk), user, len);
93364 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93365
93366 switch (cmd) {
93367 case IP6T_SO_GET_INFO:
93368 - ret = get_info(sock_net(sk), user, len, 0);
93369 + ret = get_info(sock_net(sk), user, *len, 0);
93370 break;
93371
93372 case IP6T_SO_GET_ENTRIES:
93373 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93374 index dffdc1a..ccc6678 100644
93375 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93376 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93377 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93378
93379 static int nf_ct_frag6_sysctl_register(struct net *net)
93380 {
93381 - struct ctl_table *table;
93382 + ctl_table_no_const *table = NULL;
93383 struct ctl_table_header *hdr;
93384
93385 - table = nf_ct_frag6_sysctl_table;
93386 if (!net_eq(net, &init_net)) {
93387 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93388 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93389 GFP_KERNEL);
93390 if (table == NULL)
93391 goto err_alloc;
93392 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93393 table[0].data = &net->nf_frag.frags.timeout;
93394 table[1].data = &net->nf_frag.frags.low_thresh;
93395 table[2].data = &net->nf_frag.frags.high_thresh;
93396 - }
93397 -
93398 - hdr = register_net_sysctl(net, "net/netfilter", table);
93399 + hdr = register_net_sysctl(net, "net/netfilter", table);
93400 + } else
93401 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93402 if (hdr == NULL)
93403 goto err_reg;
93404
93405 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93406 return 0;
93407
93408 err_reg:
93409 - if (!net_eq(net, &init_net))
93410 - kfree(table);
93411 + kfree(table);
93412 err_alloc:
93413 return -ENOMEM;
93414 }
93415 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93416 index ab92a36..bb4a528 100644
93417 --- a/net/ipv6/output_core.c
93418 +++ b/net/ipv6/output_core.c
93419 @@ -8,8 +8,8 @@
93420
93421 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93422 {
93423 - static atomic_t ipv6_fragmentation_id;
93424 - int old, new;
93425 + static atomic_unchecked_t ipv6_fragmentation_id;
93426 + int id;
93427
93428 #if IS_ENABLED(CONFIG_IPV6)
93429 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93430 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93431 }
93432 }
93433 #endif
93434 - do {
93435 - old = atomic_read(&ipv6_fragmentation_id);
93436 - new = old + 1;
93437 - if (!new)
93438 - new = 1;
93439 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93440 - fhdr->identification = htonl(new);
93441 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93442 + if (!id)
93443 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93444 + fhdr->identification = htonl(id);
93445 }
93446 EXPORT_SYMBOL(ipv6_select_ident);
93447
93448 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93449 index 18f19df..b46ada1 100644
93450 --- a/net/ipv6/ping.c
93451 +++ b/net/ipv6/ping.c
93452 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93453 };
93454 #endif
93455
93456 +static struct pingv6_ops real_pingv6_ops = {
93457 + .ipv6_recv_error = ipv6_recv_error,
93458 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93459 + .icmpv6_err_convert = icmpv6_err_convert,
93460 + .ipv6_icmp_error = ipv6_icmp_error,
93461 + .ipv6_chk_addr = ipv6_chk_addr,
93462 +};
93463 +
93464 +static struct pingv6_ops dummy_pingv6_ops = {
93465 + .ipv6_recv_error = dummy_ipv6_recv_error,
93466 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93467 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93468 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93469 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93470 +};
93471 +
93472 int __init pingv6_init(void)
93473 {
93474 #ifdef CONFIG_PROC_FS
93475 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93476 if (ret)
93477 return ret;
93478 #endif
93479 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93480 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93481 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93482 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93483 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93484 + pingv6_ops = &real_pingv6_ops;
93485 return inet6_register_protosw(&pingv6_protosw);
93486 }
93487
93488 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93489 */
93490 void pingv6_exit(void)
93491 {
93492 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93493 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93494 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93495 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93496 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93497 + pingv6_ops = &dummy_pingv6_ops;
93498 #ifdef CONFIG_PROC_FS
93499 unregister_pernet_subsys(&ping_v6_net_ops);
93500 #endif
93501 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93502 index cdaed47..515edde9 100644
93503 --- a/net/ipv6/raw.c
93504 +++ b/net/ipv6/raw.c
93505 @@ -108,7 +108,7 @@ found:
93506 */
93507 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93508 {
93509 - struct icmp6hdr *_hdr;
93510 + struct icmp6hdr _hdr;
93511 const struct icmp6hdr *hdr;
93512
93513 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93514 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93515 {
93516 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93517 skb_checksum_complete(skb)) {
93518 - atomic_inc(&sk->sk_drops);
93519 + atomic_inc_unchecked(&sk->sk_drops);
93520 kfree_skb(skb);
93521 return NET_RX_DROP;
93522 }
93523 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93524 struct raw6_sock *rp = raw6_sk(sk);
93525
93526 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93527 - atomic_inc(&sk->sk_drops);
93528 + atomic_inc_unchecked(&sk->sk_drops);
93529 kfree_skb(skb);
93530 return NET_RX_DROP;
93531 }
93532 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93533
93534 if (inet->hdrincl) {
93535 if (skb_checksum_complete(skb)) {
93536 - atomic_inc(&sk->sk_drops);
93537 + atomic_inc_unchecked(&sk->sk_drops);
93538 kfree_skb(skb);
93539 return NET_RX_DROP;
93540 }
93541 @@ -602,7 +602,7 @@ out:
93542 return err;
93543 }
93544
93545 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93546 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93547 struct flowi6 *fl6, struct dst_entry **dstp,
93548 unsigned int flags)
93549 {
93550 @@ -915,12 +915,15 @@ do_confirm:
93551 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93552 char __user *optval, int optlen)
93553 {
93554 + struct icmp6_filter filter;
93555 +
93556 switch (optname) {
93557 case ICMPV6_FILTER:
93558 if (optlen > sizeof(struct icmp6_filter))
93559 optlen = sizeof(struct icmp6_filter);
93560 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93561 + if (copy_from_user(&filter, optval, optlen))
93562 return -EFAULT;
93563 + raw6_sk(sk)->filter = filter;
93564 return 0;
93565 default:
93566 return -ENOPROTOOPT;
93567 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93568 char __user *optval, int __user *optlen)
93569 {
93570 int len;
93571 + struct icmp6_filter filter;
93572
93573 switch (optname) {
93574 case ICMPV6_FILTER:
93575 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93576 len = sizeof(struct icmp6_filter);
93577 if (put_user(len, optlen))
93578 return -EFAULT;
93579 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93580 + filter = raw6_sk(sk)->filter;
93581 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93582 return -EFAULT;
93583 return 0;
93584 default:
93585 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93586 index 1aeb473..bea761c 100644
93587 --- a/net/ipv6/reassembly.c
93588 +++ b/net/ipv6/reassembly.c
93589 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93590
93591 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93592 {
93593 - struct ctl_table *table;
93594 + ctl_table_no_const *table = NULL;
93595 struct ctl_table_header *hdr;
93596
93597 - table = ip6_frags_ns_ctl_table;
93598 if (!net_eq(net, &init_net)) {
93599 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93600 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93601 if (table == NULL)
93602 goto err_alloc;
93603
93604 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93605 /* Don't export sysctls to unprivileged users */
93606 if (net->user_ns != &init_user_ns)
93607 table[0].procname = NULL;
93608 - }
93609 + hdr = register_net_sysctl(net, "net/ipv6", table);
93610 + } else
93611 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93612
93613 - hdr = register_net_sysctl(net, "net/ipv6", table);
93614 if (hdr == NULL)
93615 goto err_reg;
93616
93617 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93618 return 0;
93619
93620 err_reg:
93621 - if (!net_eq(net, &init_net))
93622 - kfree(table);
93623 + kfree(table);
93624 err_alloc:
93625 return -ENOMEM;
93626 }
93627 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93628 index 8d9a93ed..cd89616 100644
93629 --- a/net/ipv6/route.c
93630 +++ b/net/ipv6/route.c
93631 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93632
93633 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93634 {
93635 - struct ctl_table *table;
93636 + ctl_table_no_const *table;
93637
93638 table = kmemdup(ipv6_route_table_template,
93639 sizeof(ipv6_route_table_template),
93640 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93641 index 21b25dd..9a43e37 100644
93642 --- a/net/ipv6/sit.c
93643 +++ b/net/ipv6/sit.c
93644 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93645 static void ipip6_dev_free(struct net_device *dev);
93646 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93647 __be32 *v4dst);
93648 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93649 +static struct rtnl_link_ops sit_link_ops;
93650
93651 static int sit_net_id __read_mostly;
93652 struct sit_net {
93653 @@ -1547,7 +1547,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93654 #endif
93655 };
93656
93657 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93658 +static struct rtnl_link_ops sit_link_ops = {
93659 .kind = "sit",
93660 .maxtype = IFLA_IPTUN_MAX,
93661 .policy = ipip6_policy,
93662 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93663 index 107b2f1..72741a9 100644
93664 --- a/net/ipv6/sysctl_net_ipv6.c
93665 +++ b/net/ipv6/sysctl_net_ipv6.c
93666 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93667
93668 static int __net_init ipv6_sysctl_net_init(struct net *net)
93669 {
93670 - struct ctl_table *ipv6_table;
93671 + ctl_table_no_const *ipv6_table;
93672 struct ctl_table *ipv6_route_table;
93673 struct ctl_table *ipv6_icmp_table;
93674 int err;
93675 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93676 index 6e1649d..75ddb4c 100644
93677 --- a/net/ipv6/tcp_ipv6.c
93678 +++ b/net/ipv6/tcp_ipv6.c
93679 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93680 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93681 }
93682
93683 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93684 +extern int grsec_enable_blackhole;
93685 +#endif
93686 +
93687 static void tcp_v6_hash(struct sock *sk)
93688 {
93689 if (sk->sk_state != TCP_CLOSE) {
93690 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93691 return 0;
93692
93693 reset:
93694 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93695 + if (!grsec_enable_blackhole)
93696 +#endif
93697 tcp_v6_send_reset(sk, skb);
93698 discard:
93699 if (opt_skb)
93700 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93701 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93702 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93703 if (np->rxopt.bits.rxtclass)
93704 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93705 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93706 if (ipv6_opt_accepted(sk, opt_skb)) {
93707 skb_set_owner_r(opt_skb, sk);
93708 opt_skb = xchg(&np->pktoptions, opt_skb);
93709 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93710 TCP_SKB_CB(skb)->sacked = 0;
93711
93712 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93713 - if (!sk)
93714 + if (!sk) {
93715 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93716 + ret = 1;
93717 +#endif
93718 goto no_tcp_socket;
93719 + }
93720
93721 process:
93722 - if (sk->sk_state == TCP_TIME_WAIT)
93723 + if (sk->sk_state == TCP_TIME_WAIT) {
93724 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93725 + ret = 2;
93726 +#endif
93727 goto do_time_wait;
93728 + }
93729
93730 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93731 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93732 @@ -1538,6 +1553,10 @@ csum_error:
93733 bad_packet:
93734 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93735 } else {
93736 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93737 + if (!grsec_enable_blackhole || (ret == 1 &&
93738 + (skb->dev->flags & IFF_LOOPBACK)))
93739 +#endif
93740 tcp_v6_send_reset(NULL, skb);
93741 }
93742
93743 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93744 index f405815..45a68a6 100644
93745 --- a/net/ipv6/udp.c
93746 +++ b/net/ipv6/udp.c
93747 @@ -53,6 +53,10 @@
93748 #include <trace/events/skb.h>
93749 #include "udp_impl.h"
93750
93751 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93752 +extern int grsec_enable_blackhole;
93753 +#endif
93754 +
93755 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93756 {
93757 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93758 @@ -420,7 +424,7 @@ try_again:
93759 if (unlikely(err)) {
93760 trace_kfree_skb(skb, udpv6_recvmsg);
93761 if (!peeked) {
93762 - atomic_inc(&sk->sk_drops);
93763 + atomic_inc_unchecked(&sk->sk_drops);
93764 if (is_udp4)
93765 UDP_INC_STATS_USER(sock_net(sk),
93766 UDP_MIB_INERRORS,
93767 @@ -666,7 +670,7 @@ csum_error:
93768 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93769 drop:
93770 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93771 - atomic_inc(&sk->sk_drops);
93772 + atomic_inc_unchecked(&sk->sk_drops);
93773 kfree_skb(skb);
93774 return -1;
93775 }
93776 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93777 if (likely(skb1 == NULL))
93778 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93779 if (!skb1) {
93780 - atomic_inc(&sk->sk_drops);
93781 + atomic_inc_unchecked(&sk->sk_drops);
93782 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93783 IS_UDPLITE(sk));
93784 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93785 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93786 goto csum_error;
93787
93788 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93789 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93790 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93791 +#endif
93792 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93793
93794 kfree_skb(skb);
93795 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93796 index 23ed03d..6532e67 100644
93797 --- a/net/ipv6/xfrm6_policy.c
93798 +++ b/net/ipv6/xfrm6_policy.c
93799 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93800 }
93801 }
93802
93803 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93804 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93805 {
93806 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
93807
93808 - xfrm6_policy_afinfo.garbage_collect(net);
93809 + xfrm_garbage_collect_deferred(net);
93810 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
93811 }
93812
93813 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
93814
93815 static int __net_init xfrm6_net_init(struct net *net)
93816 {
93817 - struct ctl_table *table;
93818 + ctl_table_no_const *table = NULL;
93819 struct ctl_table_header *hdr;
93820
93821 - table = xfrm6_policy_table;
93822 if (!net_eq(net, &init_net)) {
93823 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93824 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93825 if (!table)
93826 goto err_alloc;
93827
93828 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
93829 - }
93830 + hdr = register_net_sysctl(net, "net/ipv6", table);
93831 + } else
93832 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
93833
93834 - hdr = register_net_sysctl(net, "net/ipv6", table);
93835 if (!hdr)
93836 goto err_reg;
93837
93838 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
93839 return 0;
93840
93841 err_reg:
93842 - if (!net_eq(net, &init_net))
93843 - kfree(table);
93844 + kfree(table);
93845 err_alloc:
93846 return -ENOMEM;
93847 }
93848 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
93849 index 41ac7938..75e3bb1 100644
93850 --- a/net/irda/ircomm/ircomm_tty.c
93851 +++ b/net/irda/ircomm/ircomm_tty.c
93852 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93853 add_wait_queue(&port->open_wait, &wait);
93854
93855 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
93856 - __FILE__, __LINE__, tty->driver->name, port->count);
93857 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93858
93859 spin_lock_irqsave(&port->lock, flags);
93860 if (!tty_hung_up_p(filp))
93861 - port->count--;
93862 + atomic_dec(&port->count);
93863 port->blocked_open++;
93864 spin_unlock_irqrestore(&port->lock, flags);
93865
93866 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93867 }
93868
93869 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
93870 - __FILE__, __LINE__, tty->driver->name, port->count);
93871 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93872
93873 schedule();
93874 }
93875 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93876
93877 spin_lock_irqsave(&port->lock, flags);
93878 if (!tty_hung_up_p(filp))
93879 - port->count++;
93880 + atomic_inc(&port->count);
93881 port->blocked_open--;
93882 spin_unlock_irqrestore(&port->lock, flags);
93883
93884 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
93885 - __FILE__, __LINE__, tty->driver->name, port->count);
93886 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93887
93888 if (!retval)
93889 port->flags |= ASYNC_NORMAL_ACTIVE;
93890 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
93891
93892 /* ++ is not atomic, so this should be protected - Jean II */
93893 spin_lock_irqsave(&self->port.lock, flags);
93894 - self->port.count++;
93895 + atomic_inc(&self->port.count);
93896 spin_unlock_irqrestore(&self->port.lock, flags);
93897 tty_port_tty_set(&self->port, tty);
93898
93899 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
93900 - self->line, self->port.count);
93901 + self->line, atomic_read(&self->port.count));
93902
93903 /* Not really used by us, but lets do it anyway */
93904 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
93905 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
93906 tty_kref_put(port->tty);
93907 }
93908 port->tty = NULL;
93909 - port->count = 0;
93910 + atomic_set(&port->count, 0);
93911 spin_unlock_irqrestore(&port->lock, flags);
93912
93913 wake_up_interruptible(&port->open_wait);
93914 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
93915 seq_putc(m, '\n');
93916
93917 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
93918 - seq_printf(m, "Open count: %d\n", self->port.count);
93919 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
93920 seq_printf(m, "Max data size: %d\n", self->max_data_size);
93921 seq_printf(m, "Max header size: %d\n", self->max_header_size);
93922
93923 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
93924 index 168aff5..9d43132 100644
93925 --- a/net/iucv/af_iucv.c
93926 +++ b/net/iucv/af_iucv.c
93927 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
93928
93929 write_lock_bh(&iucv_sk_list.lock);
93930
93931 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
93932 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93933 while (__iucv_get_sock_by_name(name)) {
93934 sprintf(name, "%08x",
93935 - atomic_inc_return(&iucv_sk_list.autobind_name));
93936 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93937 }
93938
93939 write_unlock_bh(&iucv_sk_list.lock);
93940 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
93941 index cd5b8ec..f205e6b 100644
93942 --- a/net/iucv/iucv.c
93943 +++ b/net/iucv/iucv.c
93944 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
93945 return NOTIFY_OK;
93946 }
93947
93948 -static struct notifier_block __refdata iucv_cpu_notifier = {
93949 +static struct notifier_block iucv_cpu_notifier = {
93950 .notifier_call = iucv_cpu_notify,
93951 };
93952
93953 diff --git a/net/key/af_key.c b/net/key/af_key.c
93954 index ab8bd2c..cd2d641 100644
93955 --- a/net/key/af_key.c
93956 +++ b/net/key/af_key.c
93957 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
93958 static u32 get_acqseq(void)
93959 {
93960 u32 res;
93961 - static atomic_t acqseq;
93962 + static atomic_unchecked_t acqseq;
93963
93964 do {
93965 - res = atomic_inc_return(&acqseq);
93966 + res = atomic_inc_return_unchecked(&acqseq);
93967 } while (!res);
93968 return res;
93969 }
93970 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
93971 index 43dd752..63a23bc 100644
93972 --- a/net/mac80211/cfg.c
93973 +++ b/net/mac80211/cfg.c
93974 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
93975 ret = ieee80211_vif_use_channel(sdata, chandef,
93976 IEEE80211_CHANCTX_EXCLUSIVE);
93977 }
93978 - } else if (local->open_count == local->monitors) {
93979 + } else if (local_read(&local->open_count) == local->monitors) {
93980 local->_oper_chandef = *chandef;
93981 ieee80211_hw_config(local, 0);
93982 }
93983 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
93984 else
93985 local->probe_req_reg--;
93986
93987 - if (!local->open_count)
93988 + if (!local_read(&local->open_count))
93989 break;
93990
93991 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
93992 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
93993 if (chanctx_conf) {
93994 *chandef = chanctx_conf->def;
93995 ret = 0;
93996 - } else if (local->open_count > 0 &&
93997 - local->open_count == local->monitors &&
93998 + } else if (local_read(&local->open_count) > 0 &&
93999 + local_read(&local->open_count) == local->monitors &&
94000 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94001 if (local->use_chanctx)
94002 *chandef = local->monitor_chandef;
94003 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94004 index 8412a30..6e00181 100644
94005 --- a/net/mac80211/ieee80211_i.h
94006 +++ b/net/mac80211/ieee80211_i.h
94007 @@ -28,6 +28,7 @@
94008 #include <net/ieee80211_radiotap.h>
94009 #include <net/cfg80211.h>
94010 #include <net/mac80211.h>
94011 +#include <asm/local.h>
94012 #include "key.h"
94013 #include "sta_info.h"
94014 #include "debug.h"
94015 @@ -907,7 +908,7 @@ struct ieee80211_local {
94016 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94017 spinlock_t queue_stop_reason_lock;
94018
94019 - int open_count;
94020 + local_t open_count;
94021 int monitors, cooked_mntrs;
94022 /* number of interfaces with corresponding FIF_ flags */
94023 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94024 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94025 index cc11759..11d5541 100644
94026 --- a/net/mac80211/iface.c
94027 +++ b/net/mac80211/iface.c
94028 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94029 break;
94030 }
94031
94032 - if (local->open_count == 0) {
94033 + if (local_read(&local->open_count) == 0) {
94034 res = drv_start(local);
94035 if (res)
94036 goto err_del_bss;
94037 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94038 res = drv_add_interface(local, sdata);
94039 if (res)
94040 goto err_stop;
94041 - } else if (local->monitors == 0 && local->open_count == 0) {
94042 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94043 res = ieee80211_add_virtual_monitor(local);
94044 if (res)
94045 goto err_stop;
94046 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94047 atomic_inc(&local->iff_promiscs);
94048
94049 if (coming_up)
94050 - local->open_count++;
94051 + local_inc(&local->open_count);
94052
94053 if (hw_reconf_flags)
94054 ieee80211_hw_config(local, hw_reconf_flags);
94055 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94056 err_del_interface:
94057 drv_remove_interface(local, sdata);
94058 err_stop:
94059 - if (!local->open_count)
94060 + if (!local_read(&local->open_count))
94061 drv_stop(local);
94062 err_del_bss:
94063 sdata->bss = NULL;
94064 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94065 }
94066
94067 if (going_down)
94068 - local->open_count--;
94069 + local_dec(&local->open_count);
94070
94071 switch (sdata->vif.type) {
94072 case NL80211_IFTYPE_AP_VLAN:
94073 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94074 }
94075 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94076
94077 - if (local->open_count == 0)
94078 + if (local_read(&local->open_count) == 0)
94079 ieee80211_clear_tx_pending(local);
94080
94081 /*
94082 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94083
94084 ieee80211_recalc_ps(local, -1);
94085
94086 - if (local->open_count == 0) {
94087 + if (local_read(&local->open_count) == 0) {
94088 ieee80211_stop_device(local);
94089
94090 /* no reconfiguring after stop! */
94091 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94092 ieee80211_configure_filter(local);
94093 ieee80211_hw_config(local, hw_reconf_flags);
94094
94095 - if (local->monitors == local->open_count)
94096 + if (local->monitors == local_read(&local->open_count))
94097 ieee80211_add_virtual_monitor(local);
94098 }
94099
94100 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94101 index 091088a..daf43c7 100644
94102 --- a/net/mac80211/main.c
94103 +++ b/net/mac80211/main.c
94104 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94105 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94106 IEEE80211_CONF_CHANGE_POWER);
94107
94108 - if (changed && local->open_count) {
94109 + if (changed && local_read(&local->open_count)) {
94110 ret = drv_config(local, changed);
94111 /*
94112 * Goal:
94113 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94114 index 3401262..d5cd68d 100644
94115 --- a/net/mac80211/pm.c
94116 +++ b/net/mac80211/pm.c
94117 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94118 struct ieee80211_sub_if_data *sdata;
94119 struct sta_info *sta;
94120
94121 - if (!local->open_count)
94122 + if (!local_read(&local->open_count))
94123 goto suspend;
94124
94125 ieee80211_scan_cancel(local);
94126 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94127 cancel_work_sync(&local->dynamic_ps_enable_work);
94128 del_timer_sync(&local->dynamic_ps_timer);
94129
94130 - local->wowlan = wowlan && local->open_count;
94131 + local->wowlan = wowlan && local_read(&local->open_count);
94132 if (local->wowlan) {
94133 int err = drv_suspend(local, wowlan);
94134 if (err < 0) {
94135 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94136 WARN_ON(!list_empty(&local->chanctx_list));
94137
94138 /* stop hardware - this must stop RX */
94139 - if (local->open_count)
94140 + if (local_read(&local->open_count))
94141 ieee80211_stop_device(local);
94142
94143 suspend:
94144 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94145 index 30d58d2..449ac8e 100644
94146 --- a/net/mac80211/rate.c
94147 +++ b/net/mac80211/rate.c
94148 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94149
94150 ASSERT_RTNL();
94151
94152 - if (local->open_count)
94153 + if (local_read(&local->open_count))
94154 return -EBUSY;
94155
94156 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94157 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94158 index c97a065..ff61928 100644
94159 --- a/net/mac80211/rc80211_pid_debugfs.c
94160 +++ b/net/mac80211/rc80211_pid_debugfs.c
94161 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94162
94163 spin_unlock_irqrestore(&events->lock, status);
94164
94165 - if (copy_to_user(buf, pb, p))
94166 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94167 return -EFAULT;
94168
94169 return p;
94170 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94171 index 2265445..ba14971 100644
94172 --- a/net/mac80211/util.c
94173 +++ b/net/mac80211/util.c
94174 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94175 }
94176 #endif
94177 /* everything else happens only if HW was up & running */
94178 - if (!local->open_count)
94179 + if (!local_read(&local->open_count))
94180 goto wake_up;
94181
94182 /*
94183 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94184 local->in_reconfig = false;
94185 barrier();
94186
94187 - if (local->monitors == local->open_count && local->monitors > 0)
94188 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94189 ieee80211_add_virtual_monitor(local);
94190
94191 /*
94192 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94193 index 56d22ca..87c778f 100644
94194 --- a/net/netfilter/Kconfig
94195 +++ b/net/netfilter/Kconfig
94196 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94197
94198 To compile it as a module, choose M here. If unsure, say N.
94199
94200 +config NETFILTER_XT_MATCH_GRADM
94201 + tristate '"gradm" match support'
94202 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94203 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94204 + ---help---
94205 + The gradm match allows to match on grsecurity RBAC being enabled.
94206 + It is useful when iptables rules are applied early on bootup to
94207 + prevent connections to the machine (except from a trusted host)
94208 + while the RBAC system is disabled.
94209 +
94210 config NETFILTER_XT_MATCH_HASHLIMIT
94211 tristate '"hashlimit" match support'
94212 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94213 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94214 index a1abf87..dbcb7ee 100644
94215 --- a/net/netfilter/Makefile
94216 +++ b/net/netfilter/Makefile
94217 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94218 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94219 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94220 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94221 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94222 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94223 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94224 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94225 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94226 index f771390..145b765 100644
94227 --- a/net/netfilter/ipset/ip_set_core.c
94228 +++ b/net/netfilter/ipset/ip_set_core.c
94229 @@ -1820,7 +1820,7 @@ done:
94230 return ret;
94231 }
94232
94233 -static struct nf_sockopt_ops so_set __read_mostly = {
94234 +static struct nf_sockopt_ops so_set = {
94235 .pf = PF_INET,
94236 .get_optmin = SO_IP_SET,
94237 .get_optmax = SO_IP_SET + 1,
94238 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94239 index 4c8e5c0..5a79b4d 100644
94240 --- a/net/netfilter/ipvs/ip_vs_conn.c
94241 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94242 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94243 /* Increase the refcnt counter of the dest */
94244 ip_vs_dest_hold(dest);
94245
94246 - conn_flags = atomic_read(&dest->conn_flags);
94247 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94248 if (cp->protocol != IPPROTO_UDP)
94249 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94250 flags = cp->flags;
94251 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94252
94253 cp->control = NULL;
94254 atomic_set(&cp->n_control, 0);
94255 - atomic_set(&cp->in_pkts, 0);
94256 + atomic_set_unchecked(&cp->in_pkts, 0);
94257
94258 cp->packet_xmit = NULL;
94259 cp->app = NULL;
94260 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94261
94262 /* Don't drop the entry if its number of incoming packets is not
94263 located in [0, 8] */
94264 - i = atomic_read(&cp->in_pkts);
94265 + i = atomic_read_unchecked(&cp->in_pkts);
94266 if (i > 8 || i < 0) return 0;
94267
94268 if (!todrop_rate[i]) return 0;
94269 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94270 index 4f69e83..da2d8bf 100644
94271 --- a/net/netfilter/ipvs/ip_vs_core.c
94272 +++ b/net/netfilter/ipvs/ip_vs_core.c
94273 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94274 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94275 /* do not touch skb anymore */
94276
94277 - atomic_inc(&cp->in_pkts);
94278 + atomic_inc_unchecked(&cp->in_pkts);
94279 ip_vs_conn_put(cp);
94280 return ret;
94281 }
94282 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94283 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94284 pkts = sysctl_sync_threshold(ipvs);
94285 else
94286 - pkts = atomic_add_return(1, &cp->in_pkts);
94287 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94288
94289 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94290 ip_vs_sync_conn(net, cp, pkts);
94291 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94292 index c8148e4..eff604f 100644
94293 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94294 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94295 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94296 */
94297 ip_vs_rs_hash(ipvs, dest);
94298 }
94299 - atomic_set(&dest->conn_flags, conn_flags);
94300 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94301
94302 /* bind the service */
94303 if (!dest->svc) {
94304 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94305 * align with netns init in ip_vs_control_net_init()
94306 */
94307
94308 -static struct ctl_table vs_vars[] = {
94309 +static ctl_table_no_const vs_vars[] __read_only = {
94310 {
94311 .procname = "amemthresh",
94312 .maxlen = sizeof(int),
94313 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94314 " %-7s %-6d %-10d %-10d\n",
94315 &dest->addr.in6,
94316 ntohs(dest->port),
94317 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94318 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94319 atomic_read(&dest->weight),
94320 atomic_read(&dest->activeconns),
94321 atomic_read(&dest->inactconns));
94322 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94323 "%-7s %-6d %-10d %-10d\n",
94324 ntohl(dest->addr.ip),
94325 ntohs(dest->port),
94326 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94327 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94328 atomic_read(&dest->weight),
94329 atomic_read(&dest->activeconns),
94330 atomic_read(&dest->inactconns));
94331 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94332
94333 entry.addr = dest->addr.ip;
94334 entry.port = dest->port;
94335 - entry.conn_flags = atomic_read(&dest->conn_flags);
94336 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94337 entry.weight = atomic_read(&dest->weight);
94338 entry.u_threshold = dest->u_threshold;
94339 entry.l_threshold = dest->l_threshold;
94340 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94341 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94342 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94343 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94344 - (atomic_read(&dest->conn_flags) &
94345 + (atomic_read_unchecked(&dest->conn_flags) &
94346 IP_VS_CONN_F_FWD_MASK)) ||
94347 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94348 atomic_read(&dest->weight)) ||
94349 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94350 {
94351 int idx;
94352 struct netns_ipvs *ipvs = net_ipvs(net);
94353 - struct ctl_table *tbl;
94354 + ctl_table_no_const *tbl;
94355
94356 atomic_set(&ipvs->dropentry, 0);
94357 spin_lock_init(&ipvs->dropentry_lock);
94358 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94359 index 1383b0e..a486da1 100644
94360 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94361 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94362 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94363 * IPVS LBLC sysctl table
94364 */
94365 #ifdef CONFIG_SYSCTL
94366 -static struct ctl_table vs_vars_table[] = {
94367 +static ctl_table_no_const vs_vars_table[] __read_only = {
94368 {
94369 .procname = "lblc_expiration",
94370 .data = NULL,
94371 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94372 index 3cd85b2..dfab2b8 100644
94373 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94374 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94375 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94376 * IPVS LBLCR sysctl table
94377 */
94378
94379 -static struct ctl_table vs_vars_table[] = {
94380 +static ctl_table_no_const vs_vars_table[] __read_only = {
94381 {
94382 .procname = "lblcr_expiration",
94383 .data = NULL,
94384 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94385 index f448471..995f131 100644
94386 --- a/net/netfilter/ipvs/ip_vs_sync.c
94387 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94388 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94389 cp = cp->control;
94390 if (cp) {
94391 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94392 - pkts = atomic_add_return(1, &cp->in_pkts);
94393 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94394 else
94395 pkts = sysctl_sync_threshold(ipvs);
94396 ip_vs_sync_conn(net, cp->control, pkts);
94397 @@ -771,7 +771,7 @@ control:
94398 if (!cp)
94399 return;
94400 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94401 - pkts = atomic_add_return(1, &cp->in_pkts);
94402 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94403 else
94404 pkts = sysctl_sync_threshold(ipvs);
94405 goto sloop;
94406 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94407
94408 if (opt)
94409 memcpy(&cp->in_seq, opt, sizeof(*opt));
94410 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94411 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94412 cp->state = state;
94413 cp->old_state = cp->state;
94414 /*
94415 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94416 index b75ff64..0c51bbe 100644
94417 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94418 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94419 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94420 else
94421 rc = NF_ACCEPT;
94422 /* do not touch skb anymore */
94423 - atomic_inc(&cp->in_pkts);
94424 + atomic_inc_unchecked(&cp->in_pkts);
94425 goto out;
94426 }
94427
94428 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94429 else
94430 rc = NF_ACCEPT;
94431 /* do not touch skb anymore */
94432 - atomic_inc(&cp->in_pkts);
94433 + atomic_inc_unchecked(&cp->in_pkts);
94434 goto out;
94435 }
94436
94437 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94438 index 2d3030a..7ba1c0a 100644
94439 --- a/net/netfilter/nf_conntrack_acct.c
94440 +++ b/net/netfilter/nf_conntrack_acct.c
94441 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94442 #ifdef CONFIG_SYSCTL
94443 static int nf_conntrack_acct_init_sysctl(struct net *net)
94444 {
94445 - struct ctl_table *table;
94446 + ctl_table_no_const *table;
94447
94448 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94449 GFP_KERNEL);
94450 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94451 index 0283bae..5febcb0 100644
94452 --- a/net/netfilter/nf_conntrack_core.c
94453 +++ b/net/netfilter/nf_conntrack_core.c
94454 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94455 #define DYING_NULLS_VAL ((1<<30)+1)
94456 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94457
94458 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94459 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94460 +#endif
94461 +
94462 int nf_conntrack_init_net(struct net *net)
94463 {
94464 int ret;
94465 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94466 goto err_stat;
94467 }
94468
94469 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94470 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94471 +#else
94472 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94473 +#endif
94474 if (!net->ct.slabname) {
94475 ret = -ENOMEM;
94476 goto err_slabname;
94477 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94478 index 1df1761..ce8b88a 100644
94479 --- a/net/netfilter/nf_conntrack_ecache.c
94480 +++ b/net/netfilter/nf_conntrack_ecache.c
94481 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94482 #ifdef CONFIG_SYSCTL
94483 static int nf_conntrack_event_init_sysctl(struct net *net)
94484 {
94485 - struct ctl_table *table;
94486 + ctl_table_no_const *table;
94487
94488 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94489 GFP_KERNEL);
94490 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94491 index 974a2a4..52cc6ff 100644
94492 --- a/net/netfilter/nf_conntrack_helper.c
94493 +++ b/net/netfilter/nf_conntrack_helper.c
94494 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94495
94496 static int nf_conntrack_helper_init_sysctl(struct net *net)
94497 {
94498 - struct ctl_table *table;
94499 + ctl_table_no_const *table;
94500
94501 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94502 GFP_KERNEL);
94503 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94504 index 0ab9636..cea3c6a 100644
94505 --- a/net/netfilter/nf_conntrack_proto.c
94506 +++ b/net/netfilter/nf_conntrack_proto.c
94507 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94508
94509 static void
94510 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94511 - struct ctl_table **table,
94512 + ctl_table_no_const **table,
94513 unsigned int users)
94514 {
94515 if (users > 0)
94516 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94517 index a99b6c3..cb372f9 100644
94518 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94519 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94520 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94521 const char *msg;
94522 u_int8_t state;
94523
94524 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94525 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94526 BUG_ON(dh == NULL);
94527
94528 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94529 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94530 out_invalid:
94531 if (LOG_INVALID(net, IPPROTO_DCCP))
94532 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94533 - NULL, msg);
94534 + NULL, "%s", msg);
94535 return false;
94536 }
94537
94538 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94539 u_int8_t type, old_state, new_state;
94540 enum ct_dccp_roles role;
94541
94542 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94543 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94544 BUG_ON(dh == NULL);
94545 type = dh->dccph_type;
94546
94547 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94548 unsigned int cscov;
94549 const char *msg;
94550
94551 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94552 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94553 if (dh == NULL) {
94554 msg = "nf_ct_dccp: short packet ";
94555 goto out_invalid;
94556 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94557
94558 out_invalid:
94559 if (LOG_INVALID(net, IPPROTO_DCCP))
94560 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94561 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94562 return -NF_ACCEPT;
94563 }
94564
94565 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94566 index f641751..d3c5b51 100644
94567 --- a/net/netfilter/nf_conntrack_standalone.c
94568 +++ b/net/netfilter/nf_conntrack_standalone.c
94569 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94570
94571 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94572 {
94573 - struct ctl_table *table;
94574 + ctl_table_no_const *table;
94575
94576 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94577 GFP_KERNEL);
94578 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94579 index 902fb0a..87f7fdb 100644
94580 --- a/net/netfilter/nf_conntrack_timestamp.c
94581 +++ b/net/netfilter/nf_conntrack_timestamp.c
94582 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94583 #ifdef CONFIG_SYSCTL
94584 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94585 {
94586 - struct ctl_table *table;
94587 + ctl_table_no_const *table;
94588
94589 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94590 GFP_KERNEL);
94591 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94592 index 85296d4..8becdec 100644
94593 --- a/net/netfilter/nf_log.c
94594 +++ b/net/netfilter/nf_log.c
94595 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94596
94597 #ifdef CONFIG_SYSCTL
94598 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94599 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94600 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94601
94602 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94603 void __user *buffer, size_t *lenp, loff_t *ppos)
94604 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94605 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94606 mutex_unlock(&nf_log_mutex);
94607 } else {
94608 + ctl_table_no_const nf_log_table = *table;
94609 +
94610 mutex_lock(&nf_log_mutex);
94611 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94612 lockdep_is_held(&nf_log_mutex));
94613 if (!logger)
94614 - table->data = "NONE";
94615 + nf_log_table.data = "NONE";
94616 else
94617 - table->data = logger->name;
94618 - r = proc_dostring(table, write, buffer, lenp, ppos);
94619 + nf_log_table.data = logger->name;
94620 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94621 mutex_unlock(&nf_log_mutex);
94622 }
94623
94624 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94625 index f042ae5..30ea486 100644
94626 --- a/net/netfilter/nf_sockopt.c
94627 +++ b/net/netfilter/nf_sockopt.c
94628 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94629 }
94630 }
94631
94632 - list_add(&reg->list, &nf_sockopts);
94633 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94634 out:
94635 mutex_unlock(&nf_sockopt_mutex);
94636 return ret;
94637 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94638 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94639 {
94640 mutex_lock(&nf_sockopt_mutex);
94641 - list_del(&reg->list);
94642 + pax_list_del((struct list_head *)&reg->list);
94643 mutex_unlock(&nf_sockopt_mutex);
94644 }
94645 EXPORT_SYMBOL(nf_unregister_sockopt);
94646 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94647 index d92cc31..e46f350 100644
94648 --- a/net/netfilter/nfnetlink_log.c
94649 +++ b/net/netfilter/nfnetlink_log.c
94650 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94651 struct nfnl_log_net {
94652 spinlock_t instances_lock;
94653 struct hlist_head instance_table[INSTANCE_BUCKETS];
94654 - atomic_t global_seq;
94655 + atomic_unchecked_t global_seq;
94656 };
94657
94658 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94659 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94660 /* global sequence number */
94661 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94662 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94663 - htonl(atomic_inc_return(&log->global_seq))))
94664 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94665 goto nla_put_failure;
94666
94667 if (data_len) {
94668 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94669 new file mode 100644
94670 index 0000000..c566332
94671 --- /dev/null
94672 +++ b/net/netfilter/xt_gradm.c
94673 @@ -0,0 +1,51 @@
94674 +/*
94675 + * gradm match for netfilter
94676 + * Copyright © Zbigniew Krzystolik, 2010
94677 + *
94678 + * This program is free software; you can redistribute it and/or modify
94679 + * it under the terms of the GNU General Public License; either version
94680 + * 2 or 3 as published by the Free Software Foundation.
94681 + */
94682 +#include <linux/module.h>
94683 +#include <linux/moduleparam.h>
94684 +#include <linux/skbuff.h>
94685 +#include <linux/netfilter/x_tables.h>
94686 +#include <linux/grsecurity.h>
94687 +#include <linux/netfilter/xt_gradm.h>
94688 +
94689 +static bool
94690 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94691 +{
94692 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94693 + bool retval = false;
94694 + if (gr_acl_is_enabled())
94695 + retval = true;
94696 + return retval ^ info->invflags;
94697 +}
94698 +
94699 +static struct xt_match gradm_mt_reg __read_mostly = {
94700 + .name = "gradm",
94701 + .revision = 0,
94702 + .family = NFPROTO_UNSPEC,
94703 + .match = gradm_mt,
94704 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94705 + .me = THIS_MODULE,
94706 +};
94707 +
94708 +static int __init gradm_mt_init(void)
94709 +{
94710 + return xt_register_match(&gradm_mt_reg);
94711 +}
94712 +
94713 +static void __exit gradm_mt_exit(void)
94714 +{
94715 + xt_unregister_match(&gradm_mt_reg);
94716 +}
94717 +
94718 +module_init(gradm_mt_init);
94719 +module_exit(gradm_mt_exit);
94720 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94721 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94722 +MODULE_LICENSE("GPL");
94723 +MODULE_ALIAS("ipt_gradm");
94724 +MODULE_ALIAS("ip6t_gradm");
94725 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94726 index 4fe4fb4..87a89e5 100644
94727 --- a/net/netfilter/xt_statistic.c
94728 +++ b/net/netfilter/xt_statistic.c
94729 @@ -19,7 +19,7 @@
94730 #include <linux/module.h>
94731
94732 struct xt_statistic_priv {
94733 - atomic_t count;
94734 + atomic_unchecked_t count;
94735 } ____cacheline_aligned_in_smp;
94736
94737 MODULE_LICENSE("GPL");
94738 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94739 break;
94740 case XT_STATISTIC_MODE_NTH:
94741 do {
94742 - oval = atomic_read(&info->master->count);
94743 + oval = atomic_read_unchecked(&info->master->count);
94744 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94745 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94746 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94747 if (nval == 0)
94748 ret = !ret;
94749 break;
94750 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94751 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94752 if (info->master == NULL)
94753 return -ENOMEM;
94754 - atomic_set(&info->master->count, info->u.nth.count);
94755 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94756
94757 return 0;
94758 }
94759 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94760 index 0c61b59..941bddd 100644
94761 --- a/net/netlink/af_netlink.c
94762 +++ b/net/netlink/af_netlink.c
94763 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94764 sk->sk_error_report(sk);
94765 }
94766 }
94767 - atomic_inc(&sk->sk_drops);
94768 + atomic_inc_unchecked(&sk->sk_drops);
94769 }
94770
94771 static void netlink_rcv_wake(struct sock *sk)
94772 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94773 sk_wmem_alloc_get(s),
94774 nlk->cb,
94775 atomic_read(&s->sk_refcnt),
94776 - atomic_read(&s->sk_drops),
94777 + atomic_read_unchecked(&s->sk_drops),
94778 sock_i_ino(s)
94779 );
94780
94781 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94782 index 0c741ce..f8c8ca7 100644
94783 --- a/net/netlink/genetlink.c
94784 +++ b/net/netlink/genetlink.c
94785 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
94786 goto errout;
94787 }
94788
94789 + pax_open_kernel();
94790 if (ops->dumpit)
94791 - ops->flags |= GENL_CMD_CAP_DUMP;
94792 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
94793 if (ops->doit)
94794 - ops->flags |= GENL_CMD_CAP_DO;
94795 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
94796 if (ops->policy)
94797 - ops->flags |= GENL_CMD_CAP_HASPOL;
94798 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
94799 + pax_close_kernel();
94800
94801 genl_lock_all();
94802 - list_add_tail(&ops->ops_list, &family->ops_list);
94803 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
94804 genl_unlock_all();
94805
94806 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
94807 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
94808 err = 0;
94809 errout:
94810 return err;
94811 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
94812 genl_lock_all();
94813 list_for_each_entry(rc, &family->ops_list, ops_list) {
94814 if (rc == ops) {
94815 - list_del(&ops->ops_list);
94816 + pax_list_del((struct list_head *)&ops->ops_list);
94817 genl_unlock_all();
94818 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
94819 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
94820 return 0;
94821 }
94822 }
94823 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
94824 index 698814b..7cfde4e 100644
94825 --- a/net/netrom/af_netrom.c
94826 +++ b/net/netrom/af_netrom.c
94827 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
94828 *uaddr_len = sizeof(struct full_sockaddr_ax25);
94829 } else {
94830 sax->fsa_ax25.sax25_family = AF_NETROM;
94831 - sax->fsa_ax25.sax25_ndigis = 0;
94832 sax->fsa_ax25.sax25_call = nr->source_addr;
94833 *uaddr_len = sizeof(struct sockaddr_ax25);
94834 }
94835 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
94836 index 75c8bbf..ee9be59 100644
94837 --- a/net/packet/af_packet.c
94838 +++ b/net/packet/af_packet.c
94839 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94840
94841 spin_lock(&sk->sk_receive_queue.lock);
94842 po->stats.stats1.tp_packets++;
94843 - skb->dropcount = atomic_read(&sk->sk_drops);
94844 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94845 __skb_queue_tail(&sk->sk_receive_queue, skb);
94846 spin_unlock(&sk->sk_receive_queue.lock);
94847 sk->sk_data_ready(sk, skb->len);
94848 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94849 drop_n_acct:
94850 spin_lock(&sk->sk_receive_queue.lock);
94851 po->stats.stats1.tp_drops++;
94852 - atomic_inc(&sk->sk_drops);
94853 + atomic_inc_unchecked(&sk->sk_drops);
94854 spin_unlock(&sk->sk_receive_queue.lock);
94855
94856 drop_n_restore:
94857 @@ -2640,6 +2640,7 @@ out:
94858
94859 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94860 {
94861 + struct sock_extended_err ee;
94862 struct sock_exterr_skb *serr;
94863 struct sk_buff *skb, *skb2;
94864 int copied, err;
94865 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94866 sock_recv_timestamp(msg, sk, skb);
94867
94868 serr = SKB_EXT_ERR(skb);
94869 + ee = serr->ee;
94870 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
94871 - sizeof(serr->ee), &serr->ee);
94872 + sizeof ee, &ee);
94873
94874 msg->msg_flags |= MSG_ERRQUEUE;
94875 err = copied;
94876 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94877 case PACKET_HDRLEN:
94878 if (len > sizeof(int))
94879 len = sizeof(int);
94880 - if (copy_from_user(&val, optval, len))
94881 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
94882 return -EFAULT;
94883 switch (val) {
94884 case TPACKET_V1:
94885 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94886 len = lv;
94887 if (put_user(len, optlen))
94888 return -EFAULT;
94889 - if (copy_to_user(optval, data, len))
94890 + if (len > sizeof(st) || copy_to_user(optval, data, len))
94891 return -EFAULT;
94892 return 0;
94893 }
94894 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
94895 index e774117..900b8b7 100644
94896 --- a/net/phonet/pep.c
94897 +++ b/net/phonet/pep.c
94898 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94899
94900 case PNS_PEP_CTRL_REQ:
94901 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
94902 - atomic_inc(&sk->sk_drops);
94903 + atomic_inc_unchecked(&sk->sk_drops);
94904 break;
94905 }
94906 __skb_pull(skb, 4);
94907 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94908 }
94909
94910 if (pn->rx_credits == 0) {
94911 - atomic_inc(&sk->sk_drops);
94912 + atomic_inc_unchecked(&sk->sk_drops);
94913 err = -ENOBUFS;
94914 break;
94915 }
94916 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
94917 }
94918
94919 if (pn->rx_credits == 0) {
94920 - atomic_inc(&sk->sk_drops);
94921 + atomic_inc_unchecked(&sk->sk_drops);
94922 err = NET_RX_DROP;
94923 break;
94924 }
94925 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
94926 index 1afd138..0b42453 100644
94927 --- a/net/phonet/socket.c
94928 +++ b/net/phonet/socket.c
94929 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
94930 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
94931 sock_i_ino(sk),
94932 atomic_read(&sk->sk_refcnt), sk,
94933 - atomic_read(&sk->sk_drops), &len);
94934 + atomic_read_unchecked(&sk->sk_drops), &len);
94935 }
94936 seq_printf(seq, "%*s\n", 127 - len, "");
94937 return 0;
94938 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
94939 index c02a8c4..3c5b600 100644
94940 --- a/net/phonet/sysctl.c
94941 +++ b/net/phonet/sysctl.c
94942 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
94943 {
94944 int ret;
94945 int range[2] = {local_port_range[0], local_port_range[1]};
94946 - struct ctl_table tmp = {
94947 + ctl_table_no_const tmp = {
94948 .data = &range,
94949 .maxlen = sizeof(range),
94950 .mode = table->mode,
94951 diff --git a/net/rds/cong.c b/net/rds/cong.c
94952 index e5b65ac..f3b6fb7 100644
94953 --- a/net/rds/cong.c
94954 +++ b/net/rds/cong.c
94955 @@ -78,7 +78,7 @@
94956 * finds that the saved generation number is smaller than the global generation
94957 * number, it wakes up the process.
94958 */
94959 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
94960 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
94961
94962 /*
94963 * Congestion monitoring
94964 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
94965 rdsdebug("waking map %p for %pI4\n",
94966 map, &map->m_addr);
94967 rds_stats_inc(s_cong_update_received);
94968 - atomic_inc(&rds_cong_generation);
94969 + atomic_inc_unchecked(&rds_cong_generation);
94970 if (waitqueue_active(&map->m_waitq))
94971 wake_up(&map->m_waitq);
94972 if (waitqueue_active(&rds_poll_waitq))
94973 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
94974
94975 int rds_cong_updated_since(unsigned long *recent)
94976 {
94977 - unsigned long gen = atomic_read(&rds_cong_generation);
94978 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
94979
94980 if (likely(*recent == gen))
94981 return 0;
94982 diff --git a/net/rds/ib.h b/net/rds/ib.h
94983 index 7280ab8..e04f4ea 100644
94984 --- a/net/rds/ib.h
94985 +++ b/net/rds/ib.h
94986 @@ -128,7 +128,7 @@ struct rds_ib_connection {
94987 /* sending acks */
94988 unsigned long i_ack_flags;
94989 #ifdef KERNEL_HAS_ATOMIC64
94990 - atomic64_t i_ack_next; /* next ACK to send */
94991 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94992 #else
94993 spinlock_t i_ack_lock; /* protect i_ack_next */
94994 u64 i_ack_next; /* next ACK to send */
94995 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
94996 index 31b74f5..dc1fbfa 100644
94997 --- a/net/rds/ib_cm.c
94998 +++ b/net/rds/ib_cm.c
94999 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95000 /* Clear the ACK state */
95001 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95002 #ifdef KERNEL_HAS_ATOMIC64
95003 - atomic64_set(&ic->i_ack_next, 0);
95004 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95005 #else
95006 ic->i_ack_next = 0;
95007 #endif
95008 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95009 index 8eb9501..0c386ff 100644
95010 --- a/net/rds/ib_recv.c
95011 +++ b/net/rds/ib_recv.c
95012 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95013 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95014 int ack_required)
95015 {
95016 - atomic64_set(&ic->i_ack_next, seq);
95017 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95018 if (ack_required) {
95019 smp_mb__before_clear_bit();
95020 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95021 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95022 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95023 smp_mb__after_clear_bit();
95024
95025 - return atomic64_read(&ic->i_ack_next);
95026 + return atomic64_read_unchecked(&ic->i_ack_next);
95027 }
95028 #endif
95029
95030 diff --git a/net/rds/iw.h b/net/rds/iw.h
95031 index 04ce3b1..48119a6 100644
95032 --- a/net/rds/iw.h
95033 +++ b/net/rds/iw.h
95034 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95035 /* sending acks */
95036 unsigned long i_ack_flags;
95037 #ifdef KERNEL_HAS_ATOMIC64
95038 - atomic64_t i_ack_next; /* next ACK to send */
95039 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95040 #else
95041 spinlock_t i_ack_lock; /* protect i_ack_next */
95042 u64 i_ack_next; /* next ACK to send */
95043 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95044 index a91e1db..cf3053f 100644
95045 --- a/net/rds/iw_cm.c
95046 +++ b/net/rds/iw_cm.c
95047 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95048 /* Clear the ACK state */
95049 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95050 #ifdef KERNEL_HAS_ATOMIC64
95051 - atomic64_set(&ic->i_ack_next, 0);
95052 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95053 #else
95054 ic->i_ack_next = 0;
95055 #endif
95056 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95057 index 4503335..db566b4 100644
95058 --- a/net/rds/iw_recv.c
95059 +++ b/net/rds/iw_recv.c
95060 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95061 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95062 int ack_required)
95063 {
95064 - atomic64_set(&ic->i_ack_next, seq);
95065 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95066 if (ack_required) {
95067 smp_mb__before_clear_bit();
95068 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95069 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95070 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95071 smp_mb__after_clear_bit();
95072
95073 - return atomic64_read(&ic->i_ack_next);
95074 + return atomic64_read_unchecked(&ic->i_ack_next);
95075 }
95076 #endif
95077
95078 diff --git a/net/rds/rds.h b/net/rds/rds.h
95079 index ec1d731..90a3a8d 100644
95080 --- a/net/rds/rds.h
95081 +++ b/net/rds/rds.h
95082 @@ -449,7 +449,7 @@ struct rds_transport {
95083 void (*sync_mr)(void *trans_private, int direction);
95084 void (*free_mr)(void *trans_private, int invalidate);
95085 void (*flush_mrs)(void);
95086 -};
95087 +} __do_const;
95088
95089 struct rds_sock {
95090 struct sock rs_sk;
95091 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95092 index edac9ef..16bcb98 100644
95093 --- a/net/rds/tcp.c
95094 +++ b/net/rds/tcp.c
95095 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95096 int val = 1;
95097
95098 set_fs(KERNEL_DS);
95099 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95100 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95101 sizeof(val));
95102 set_fs(oldfs);
95103 }
95104 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95105 index 81cf5a4..b5826ff 100644
95106 --- a/net/rds/tcp_send.c
95107 +++ b/net/rds/tcp_send.c
95108 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95109
95110 oldfs = get_fs();
95111 set_fs(KERNEL_DS);
95112 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95113 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95114 sizeof(val));
95115 set_fs(oldfs);
95116 }
95117 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95118 index e61aa60..f07cc89 100644
95119 --- a/net/rxrpc/af_rxrpc.c
95120 +++ b/net/rxrpc/af_rxrpc.c
95121 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95122 __be32 rxrpc_epoch;
95123
95124 /* current debugging ID */
95125 -atomic_t rxrpc_debug_id;
95126 +atomic_unchecked_t rxrpc_debug_id;
95127
95128 /* count of skbs currently in use */
95129 atomic_t rxrpc_n_skbs;
95130 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95131 index e4d9cbc..b229649 100644
95132 --- a/net/rxrpc/ar-ack.c
95133 +++ b/net/rxrpc/ar-ack.c
95134 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95135
95136 _enter("{%d,%d,%d,%d},",
95137 call->acks_hard, call->acks_unacked,
95138 - atomic_read(&call->sequence),
95139 + atomic_read_unchecked(&call->sequence),
95140 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95141
95142 stop = 0;
95143 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95144
95145 /* each Tx packet has a new serial number */
95146 sp->hdr.serial =
95147 - htonl(atomic_inc_return(&call->conn->serial));
95148 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95149
95150 hdr = (struct rxrpc_header *) txb->head;
95151 hdr->serial = sp->hdr.serial;
95152 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95153 */
95154 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95155 {
95156 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95157 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95158 }
95159
95160 /*
95161 @@ -629,7 +629,7 @@ process_further:
95162
95163 latest = ntohl(sp->hdr.serial);
95164 hard = ntohl(ack.firstPacket);
95165 - tx = atomic_read(&call->sequence);
95166 + tx = atomic_read_unchecked(&call->sequence);
95167
95168 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95169 latest,
95170 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95171 goto maybe_reschedule;
95172
95173 send_ACK_with_skew:
95174 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95175 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95176 ntohl(ack.serial));
95177 send_ACK:
95178 mtu = call->conn->trans->peer->if_mtu;
95179 @@ -1173,7 +1173,7 @@ send_ACK:
95180 ackinfo.rxMTU = htonl(5692);
95181 ackinfo.jumbo_max = htonl(4);
95182
95183 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95184 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95185 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95186 ntohl(hdr.serial),
95187 ntohs(ack.maxSkew),
95188 @@ -1191,7 +1191,7 @@ send_ACK:
95189 send_message:
95190 _debug("send message");
95191
95192 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95193 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95194 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95195 send_message_2:
95196
95197 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95198 index a3bbb36..3341fb9 100644
95199 --- a/net/rxrpc/ar-call.c
95200 +++ b/net/rxrpc/ar-call.c
95201 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95202 spin_lock_init(&call->lock);
95203 rwlock_init(&call->state_lock);
95204 atomic_set(&call->usage, 1);
95205 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95206 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95207 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95208
95209 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95210 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95211 index 4106ca9..a338d7a 100644
95212 --- a/net/rxrpc/ar-connection.c
95213 +++ b/net/rxrpc/ar-connection.c
95214 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95215 rwlock_init(&conn->lock);
95216 spin_lock_init(&conn->state_lock);
95217 atomic_set(&conn->usage, 1);
95218 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95219 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95220 conn->avail_calls = RXRPC_MAXCALLS;
95221 conn->size_align = 4;
95222 conn->header_size = sizeof(struct rxrpc_header);
95223 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95224 index e7ed43a..6afa140 100644
95225 --- a/net/rxrpc/ar-connevent.c
95226 +++ b/net/rxrpc/ar-connevent.c
95227 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95228
95229 len = iov[0].iov_len + iov[1].iov_len;
95230
95231 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95232 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95233 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95234
95235 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95236 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95237 index 529572f..c758ca7 100644
95238 --- a/net/rxrpc/ar-input.c
95239 +++ b/net/rxrpc/ar-input.c
95240 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95241 /* track the latest serial number on this connection for ACK packet
95242 * information */
95243 serial = ntohl(sp->hdr.serial);
95244 - hi_serial = atomic_read(&call->conn->hi_serial);
95245 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95246 while (serial > hi_serial)
95247 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95248 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95249 serial);
95250
95251 /* request ACK generation for any ACK or DATA packet that requests
95252 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95253 index a693aca..81e7293 100644
95254 --- a/net/rxrpc/ar-internal.h
95255 +++ b/net/rxrpc/ar-internal.h
95256 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95257 int error; /* error code for local abort */
95258 int debug_id; /* debug ID for printks */
95259 unsigned int call_counter; /* call ID counter */
95260 - atomic_t serial; /* packet serial number counter */
95261 - atomic_t hi_serial; /* highest serial number received */
95262 + atomic_unchecked_t serial; /* packet serial number counter */
95263 + atomic_unchecked_t hi_serial; /* highest serial number received */
95264 u8 avail_calls; /* number of calls available */
95265 u8 size_align; /* data size alignment (for security) */
95266 u8 header_size; /* rxrpc + security header size */
95267 @@ -346,7 +346,7 @@ struct rxrpc_call {
95268 spinlock_t lock;
95269 rwlock_t state_lock; /* lock for state transition */
95270 atomic_t usage;
95271 - atomic_t sequence; /* Tx data packet sequence counter */
95272 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95273 u32 abort_code; /* local/remote abort code */
95274 enum { /* current state of call */
95275 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95276 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95277 */
95278 extern atomic_t rxrpc_n_skbs;
95279 extern __be32 rxrpc_epoch;
95280 -extern atomic_t rxrpc_debug_id;
95281 +extern atomic_unchecked_t rxrpc_debug_id;
95282 extern struct workqueue_struct *rxrpc_workqueue;
95283
95284 /*
95285 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95286 index 87f7135..74d3703 100644
95287 --- a/net/rxrpc/ar-local.c
95288 +++ b/net/rxrpc/ar-local.c
95289 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95290 spin_lock_init(&local->lock);
95291 rwlock_init(&local->services_lock);
95292 atomic_set(&local->usage, 1);
95293 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95294 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95295 memcpy(&local->srx, srx, sizeof(*srx));
95296 }
95297
95298 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95299 index e1ac183..b43e10e 100644
95300 --- a/net/rxrpc/ar-output.c
95301 +++ b/net/rxrpc/ar-output.c
95302 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95303 sp->hdr.cid = call->cid;
95304 sp->hdr.callNumber = call->call_id;
95305 sp->hdr.seq =
95306 - htonl(atomic_inc_return(&call->sequence));
95307 + htonl(atomic_inc_return_unchecked(&call->sequence));
95308 sp->hdr.serial =
95309 - htonl(atomic_inc_return(&conn->serial));
95310 + htonl(atomic_inc_return_unchecked(&conn->serial));
95311 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95312 sp->hdr.userStatus = 0;
95313 sp->hdr.securityIndex = conn->security_ix;
95314 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95315 index bebaa43..2644591 100644
95316 --- a/net/rxrpc/ar-peer.c
95317 +++ b/net/rxrpc/ar-peer.c
95318 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95319 INIT_LIST_HEAD(&peer->error_targets);
95320 spin_lock_init(&peer->lock);
95321 atomic_set(&peer->usage, 1);
95322 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95323 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95324 memcpy(&peer->srx, srx, sizeof(*srx));
95325
95326 rxrpc_assess_MTU_size(peer);
95327 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95328 index 38047f7..9f48511 100644
95329 --- a/net/rxrpc/ar-proc.c
95330 +++ b/net/rxrpc/ar-proc.c
95331 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95332 atomic_read(&conn->usage),
95333 rxrpc_conn_states[conn->state],
95334 key_serial(conn->key),
95335 - atomic_read(&conn->serial),
95336 - atomic_read(&conn->hi_serial));
95337 + atomic_read_unchecked(&conn->serial),
95338 + atomic_read_unchecked(&conn->hi_serial));
95339
95340 return 0;
95341 }
95342 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95343 index 92df566..87ec1bf 100644
95344 --- a/net/rxrpc/ar-transport.c
95345 +++ b/net/rxrpc/ar-transport.c
95346 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95347 spin_lock_init(&trans->client_lock);
95348 rwlock_init(&trans->conn_lock);
95349 atomic_set(&trans->usage, 1);
95350 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95351 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95352
95353 if (peer->srx.transport.family == AF_INET) {
95354 switch (peer->srx.transport_type) {
95355 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95356 index f226709..0e735a8 100644
95357 --- a/net/rxrpc/rxkad.c
95358 +++ b/net/rxrpc/rxkad.c
95359 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95360
95361 len = iov[0].iov_len + iov[1].iov_len;
95362
95363 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95364 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95365 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95366
95367 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95368 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95369
95370 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95371
95372 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95373 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95374 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95375
95376 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95377 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95378 index 09ffcc9..3eff2c2 100644
95379 --- a/net/sctp/ipv6.c
95380 +++ b/net/sctp/ipv6.c
95381 @@ -210,44 +210,23 @@ out:
95382 in6_dev_put(idev);
95383 }
95384
95385 -/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
95386 static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
95387 {
95388 struct sock *sk = skb->sk;
95389 struct ipv6_pinfo *np = inet6_sk(sk);
95390 - struct flowi6 fl6;
95391 -
95392 - memset(&fl6, 0, sizeof(fl6));
95393 -
95394 - fl6.flowi6_proto = sk->sk_protocol;
95395 -
95396 - /* Fill in the dest address from the route entry passed with the skb
95397 - * and the source address from the transport.
95398 - */
95399 - fl6.daddr = transport->ipaddr.v6.sin6_addr;
95400 - fl6.saddr = transport->saddr.v6.sin6_addr;
95401 -
95402 - fl6.flowlabel = np->flow_label;
95403 - IP6_ECN_flow_xmit(sk, fl6.flowlabel);
95404 - if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
95405 - fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
95406 - else
95407 - fl6.flowi6_oif = sk->sk_bound_dev_if;
95408 -
95409 - if (np->opt && np->opt->srcrt) {
95410 - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
95411 - fl6.daddr = *rt0->addr;
95412 - }
95413 + struct flowi6 *fl6 = &transport->fl.u.ip6;
95414
95415 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
95416 - skb->len, &fl6.saddr, &fl6.daddr);
95417 + skb->len, &fl6->saddr, &fl6->daddr);
95418
95419 - SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95420 + IP6_ECN_flow_xmit(sk, fl6->flowlabel);
95421
95422 if (!(transport->param_flags & SPP_PMTUD_ENABLE))
95423 skb->local_df = 1;
95424
95425 - return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
95426 + SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95427 +
95428 + return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
95429 }
95430
95431 /* Returns the dst cache entry for the given source and destination ip
95432 @@ -260,10 +239,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95433 struct dst_entry *dst = NULL;
95434 struct flowi6 *fl6 = &fl->u.ip6;
95435 struct sctp_bind_addr *bp;
95436 + struct ipv6_pinfo *np = inet6_sk(sk);
95437 struct sctp_sockaddr_entry *laddr;
95438 union sctp_addr *baddr = NULL;
95439 union sctp_addr *daddr = &t->ipaddr;
95440 union sctp_addr dst_saddr;
95441 + struct in6_addr *final_p, final;
95442 __u8 matchlen = 0;
95443 __u8 bmatchlen;
95444 sctp_scope_t scope;
95445 @@ -287,7 +268,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95446 pr_debug("src=%pI6 - ", &fl6->saddr);
95447 }
95448
95449 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95450 + final_p = fl6_update_dst(fl6, np->opt, &final);
95451 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95452 if (!asoc || saddr)
95453 goto out;
95454
95455 @@ -339,10 +321,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95456 }
95457 }
95458 rcu_read_unlock();
95459 +
95460 if (baddr) {
95461 fl6->saddr = baddr->v6.sin6_addr;
95462 fl6->fl6_sport = baddr->v6.sin6_port;
95463 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95464 + final_p = fl6_update_dst(fl6, np->opt, &final);
95465 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95466 }
95467
95468 out:
95469 @@ -984,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95470 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95471 };
95472
95473 -static struct sctp_af sctp_af_inet6 = {
95474 +static struct sctp_af sctp_af_inet6 __read_only = {
95475 .sa_family = AF_INET6,
95476 .sctp_xmit = sctp_v6_xmit,
95477 .setsockopt = ipv6_setsockopt,
95478 @@ -1016,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95479 #endif
95480 };
95481
95482 -static struct sctp_pf sctp_pf_inet6 = {
95483 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95484 .event_msgname = sctp_inet6_event_msgname,
95485 .skb_msgname = sctp_inet6_skb_msgname,
95486 .af_supported = sctp_inet6_af_supported,
95487 @@ -1041,7 +1025,7 @@ void sctp_v6_pf_init(void)
95488
95489 void sctp_v6_pf_exit(void)
95490 {
95491 - list_del(&sctp_af_inet6.list);
95492 + pax_list_del(&sctp_af_inet6.list);
95493 }
95494
95495 /* Initialize IPv6 support and register with socket layer. */
95496 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95497 index 62526c4..36a13c5 100644
95498 --- a/net/sctp/proc.c
95499 +++ b/net/sctp/proc.c
95500 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95501 seq_printf(seq,
95502 "%8pK %8pK %-3d %-3d %-2d %-4d "
95503 "%4d %8d %8d %7d %5lu %-5d %5d ",
95504 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95505 + assoc, sk,
95506 + sctp_sk(sk)->type, sk->sk_state,
95507 assoc->state, hash,
95508 assoc->assoc_id,
95509 assoc->sndbuf_used,
95510 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95511 index 4a17494d..f7e3fa0 100644
95512 --- a/net/sctp/protocol.c
95513 +++ b/net/sctp/protocol.c
95514 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95515 return 0;
95516 }
95517
95518 + pax_open_kernel();
95519 INIT_LIST_HEAD(&af->list);
95520 - list_add_tail(&af->list, &sctp_address_families);
95521 + pax_close_kernel();
95522 + pax_list_add_tail(&af->list, &sctp_address_families);
95523 return 1;
95524 }
95525
95526 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95527
95528 static struct sctp_af sctp_af_inet;
95529
95530 -static struct sctp_pf sctp_pf_inet = {
95531 +static struct sctp_pf sctp_pf_inet __read_only = {
95532 .event_msgname = sctp_inet_event_msgname,
95533 .skb_msgname = sctp_inet_skb_msgname,
95534 .af_supported = sctp_inet_af_supported,
95535 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95536 };
95537
95538 /* IPv4 address related functions. */
95539 -static struct sctp_af sctp_af_inet = {
95540 +static struct sctp_af sctp_af_inet __read_only = {
95541 .sa_family = AF_INET,
95542 .sctp_xmit = sctp_v4_xmit,
95543 .setsockopt = ip_setsockopt,
95544 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95545
95546 static void sctp_v4_pf_exit(void)
95547 {
95548 - list_del(&sctp_af_inet.list);
95549 + pax_list_del(&sctp_af_inet.list);
95550 }
95551
95552 static int sctp_v4_protosw_init(void)
95553 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95554 index 9da6885..7571898 100644
95555 --- a/net/sctp/sm_sideeffect.c
95556 +++ b/net/sctp/sm_sideeffect.c
95557 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95558 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95559 }
95560
95561 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95562 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95563 NULL,
95564 sctp_generate_t1_cookie_event,
95565 sctp_generate_t1_init_event,
95566 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95567 index c6670d2..6313e65 100644
95568 --- a/net/sctp/socket.c
95569 +++ b/net/sctp/socket.c
95570 @@ -2156,11 +2156,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95571 {
95572 struct sctp_association *asoc;
95573 struct sctp_ulpevent *event;
95574 + struct sctp_event_subscribe subscribe;
95575
95576 if (optlen > sizeof(struct sctp_event_subscribe))
95577 return -EINVAL;
95578 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95579 + if (copy_from_user(&subscribe, optval, optlen))
95580 return -EFAULT;
95581 + sctp_sk(sk)->subscribe = subscribe;
95582
95583 /*
95584 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95585 @@ -4216,13 +4218,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95586 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95587 int __user *optlen)
95588 {
95589 + struct sctp_event_subscribe subscribe;
95590 +
95591 if (len <= 0)
95592 return -EINVAL;
95593 if (len > sizeof(struct sctp_event_subscribe))
95594 len = sizeof(struct sctp_event_subscribe);
95595 if (put_user(len, optlen))
95596 return -EFAULT;
95597 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95598 + subscribe = sctp_sk(sk)->subscribe;
95599 + if (copy_to_user(optval, &subscribe, len))
95600 return -EFAULT;
95601 return 0;
95602 }
95603 @@ -4240,6 +4245,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95604 */
95605 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95606 {
95607 + __u32 autoclose;
95608 +
95609 /* Applicable to UDP-style socket only */
95610 if (sctp_style(sk, TCP))
95611 return -EOPNOTSUPP;
95612 @@ -4248,7 +4255,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95613 len = sizeof(int);
95614 if (put_user(len, optlen))
95615 return -EFAULT;
95616 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95617 + autoclose = sctp_sk(sk)->autoclose;
95618 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95619 return -EFAULT;
95620 return 0;
95621 }
95622 @@ -4620,12 +4628,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95623 */
95624 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95625 {
95626 + struct sctp_initmsg initmsg;
95627 +
95628 if (len < sizeof(struct sctp_initmsg))
95629 return -EINVAL;
95630 len = sizeof(struct sctp_initmsg);
95631 if (put_user(len, optlen))
95632 return -EFAULT;
95633 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95634 + initmsg = sctp_sk(sk)->initmsg;
95635 + if (copy_to_user(optval, &initmsg, len))
95636 return -EFAULT;
95637 return 0;
95638 }
95639 @@ -4666,6 +4677,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95640 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95641 if (space_left < addrlen)
95642 return -ENOMEM;
95643 + if (addrlen > sizeof(temp) || addrlen < 0)
95644 + return -EFAULT;
95645 if (copy_to_user(to, &temp, addrlen))
95646 return -EFAULT;
95647 to += addrlen;
95648 @@ -6182,7 +6195,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
95649 /* Is there any exceptional events? */
95650 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
95651 mask |= POLLERR |
95652 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
95653 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
95654 if (sk->sk_shutdown & RCV_SHUTDOWN)
95655 mask |= POLLRDHUP | POLLIN | POLLRDNORM;
95656 if (sk->sk_shutdown == SHUTDOWN_MASK)
95657 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95658 index 9a5c4c9..46e4b29 100644
95659 --- a/net/sctp/sysctl.c
95660 +++ b/net/sctp/sysctl.c
95661 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95662 {
95663 struct net *net = current->nsproxy->net_ns;
95664 char tmp[8];
95665 - struct ctl_table tbl;
95666 + ctl_table_no_const tbl;
95667 int ret;
95668 int changed = 0;
95669 char *none = "none";
95670 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95671
95672 int sctp_sysctl_net_register(struct net *net)
95673 {
95674 - struct ctl_table *table;
95675 + ctl_table_no_const *table;
95676 int i;
95677
95678 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95679 diff --git a/net/socket.c b/net/socket.c
95680 index b2d7c62..441a7ef 100644
95681 --- a/net/socket.c
95682 +++ b/net/socket.c
95683 @@ -88,6 +88,7 @@
95684 #include <linux/magic.h>
95685 #include <linux/slab.h>
95686 #include <linux/xattr.h>
95687 +#include <linux/in.h>
95688
95689 #include <asm/uaccess.h>
95690 #include <asm/unistd.h>
95691 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95692 unsigned int sysctl_net_busy_poll __read_mostly;
95693 #endif
95694
95695 +#include <linux/grsock.h>
95696 +
95697 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95698 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95699 unsigned long nr_segs, loff_t pos);
95700 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95701 */
95702
95703 static DEFINE_SPINLOCK(net_family_lock);
95704 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95705 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95706
95707 /*
95708 * Statistics counters of the socket lists
95709 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95710 &sockfs_dentry_operations, SOCKFS_MAGIC);
95711 }
95712
95713 -static struct vfsmount *sock_mnt __read_mostly;
95714 +struct vfsmount *sock_mnt __read_mostly;
95715
95716 static struct file_system_type sock_fs_type = {
95717 .name = "sockfs",
95718 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95719 return -EAFNOSUPPORT;
95720 if (type < 0 || type >= SOCK_MAX)
95721 return -EINVAL;
95722 + if (protocol < 0)
95723 + return -EINVAL;
95724
95725 /* Compatibility.
95726
95727 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95728 if (err)
95729 return err;
95730
95731 + if(!kern && !gr_search_socket(family, type, protocol)) {
95732 + if (rcu_access_pointer(net_families[family]) == NULL)
95733 + return -EAFNOSUPPORT;
95734 + else
95735 + return -EACCES;
95736 + }
95737 +
95738 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95739 + if (rcu_access_pointer(net_families[family]) == NULL)
95740 + return -EAFNOSUPPORT;
95741 + else
95742 + return -EACCES;
95743 + }
95744 +
95745 /*
95746 * Allocate the socket and allow the family to set things up. if
95747 * the protocol is 0, the family is instructed to select an appropriate
95748 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95749 if (sock) {
95750 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95751 if (err >= 0) {
95752 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95753 + err = -EACCES;
95754 + goto error;
95755 + }
95756 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95757 + if (err)
95758 + goto error;
95759 +
95760 err = security_socket_bind(sock,
95761 (struct sockaddr *)&address,
95762 addrlen);
95763 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95764 (struct sockaddr *)
95765 &address, addrlen);
95766 }
95767 +error:
95768 fput_light(sock->file, fput_needed);
95769 }
95770 return err;
95771 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95772 if ((unsigned int)backlog > somaxconn)
95773 backlog = somaxconn;
95774
95775 + if (gr_handle_sock_server_other(sock->sk)) {
95776 + err = -EPERM;
95777 + goto error;
95778 + }
95779 +
95780 + err = gr_search_listen(sock);
95781 + if (err)
95782 + goto error;
95783 +
95784 err = security_socket_listen(sock, backlog);
95785 if (!err)
95786 err = sock->ops->listen(sock, backlog);
95787
95788 +error:
95789 fput_light(sock->file, fput_needed);
95790 }
95791 return err;
95792 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95793 newsock->type = sock->type;
95794 newsock->ops = sock->ops;
95795
95796 + if (gr_handle_sock_server_other(sock->sk)) {
95797 + err = -EPERM;
95798 + sock_release(newsock);
95799 + goto out_put;
95800 + }
95801 +
95802 + err = gr_search_accept(sock);
95803 + if (err) {
95804 + sock_release(newsock);
95805 + goto out_put;
95806 + }
95807 +
95808 /*
95809 * We don't need try_module_get here, as the listening socket (sock)
95810 * has the protocol module (sock->ops->owner) held.
95811 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95812 fd_install(newfd, newfile);
95813 err = newfd;
95814
95815 + gr_attach_curr_ip(newsock->sk);
95816 +
95817 out_put:
95818 fput_light(sock->file, fput_needed);
95819 out:
95820 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95821 int, addrlen)
95822 {
95823 struct socket *sock;
95824 + struct sockaddr *sck;
95825 struct sockaddr_storage address;
95826 int err, fput_needed;
95827
95828 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95829 if (err < 0)
95830 goto out_put;
95831
95832 + sck = (struct sockaddr *)&address;
95833 +
95834 + if (gr_handle_sock_client(sck)) {
95835 + err = -EACCES;
95836 + goto out_put;
95837 + }
95838 +
95839 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95840 + if (err)
95841 + goto out_put;
95842 +
95843 err =
95844 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95845 if (err)
95846 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95847 * the protocol.
95848 */
95849
95850 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95851 +
95852 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95853 unsigned int, flags, struct sockaddr __user *, addr,
95854 int, addr_len)
95855 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95856 struct socket *sock;
95857 struct iovec iov;
95858 struct msghdr msg;
95859 - struct sockaddr_storage address;
95860 + struct sockaddr_storage address = { };
95861 int err, err2;
95862 int fput_needed;
95863
95864 @@ -2040,7 +2106,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95865 * checking falls down on this.
95866 */
95867 if (copy_from_user(ctl_buf,
95868 - (void __user __force *)msg_sys->msg_control,
95869 + (void __force_user *)msg_sys->msg_control,
95870 ctl_len))
95871 goto out_freectl;
95872 msg_sys->msg_control = ctl_buf;
95873 @@ -2191,7 +2257,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95874 int err, total_len, len;
95875
95876 /* kernel mode address */
95877 - struct sockaddr_storage addr;
95878 + struct sockaddr_storage addr = { };
95879
95880 /* user mode address pointers */
95881 struct sockaddr __user *uaddr;
95882 @@ -2219,7 +2285,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95883 * kernel msghdr to use the kernel address space)
95884 */
95885
95886 - uaddr = (__force void __user *)msg_sys->msg_name;
95887 + uaddr = (void __force_user *)msg_sys->msg_name;
95888 uaddr_len = COMPAT_NAMELEN(msg);
95889 if (MSG_CMSG_COMPAT & flags) {
95890 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
95891 @@ -2974,7 +3040,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
95892 old_fs = get_fs();
95893 set_fs(KERNEL_DS);
95894 err = dev_ioctl(net, cmd,
95895 - (struct ifreq __user __force *) &kifr);
95896 + (struct ifreq __force_user *) &kifr);
95897 set_fs(old_fs);
95898
95899 return err;
95900 @@ -3083,7 +3149,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
95901
95902 old_fs = get_fs();
95903 set_fs(KERNEL_DS);
95904 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
95905 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
95906 set_fs(old_fs);
95907
95908 if (cmd == SIOCGIFMAP && !err) {
95909 @@ -3188,7 +3254,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
95910 ret |= __get_user(rtdev, &(ur4->rt_dev));
95911 if (rtdev) {
95912 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
95913 - r4.rt_dev = (char __user __force *)devname;
95914 + r4.rt_dev = (char __force_user *)devname;
95915 devname[15] = 0;
95916 } else
95917 r4.rt_dev = NULL;
95918 @@ -3414,8 +3480,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
95919 int __user *uoptlen;
95920 int err;
95921
95922 - uoptval = (char __user __force *) optval;
95923 - uoptlen = (int __user __force *) optlen;
95924 + uoptval = (char __force_user *) optval;
95925 + uoptlen = (int __force_user *) optlen;
95926
95927 set_fs(KERNEL_DS);
95928 if (level == SOL_SOCKET)
95929 @@ -3435,7 +3501,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
95930 char __user *uoptval;
95931 int err;
95932
95933 - uoptval = (char __user __force *) optval;
95934 + uoptval = (char __force_user *) optval;
95935
95936 set_fs(KERNEL_DS);
95937 if (level == SOL_SOCKET)
95938 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
95939 index 09fb638..2e6a5c5 100644
95940 --- a/net/sunrpc/auth_gss/svcauth_gss.c
95941 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
95942 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95943 uint64_t *handle)
95944 {
95945 struct rsc rsci, *rscp = NULL;
95946 - static atomic64_t ctxhctr;
95947 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
95948 long long ctxh;
95949 struct gss_api_mech *gm = NULL;
95950 time_t expiry;
95951 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95952 status = -ENOMEM;
95953 /* the handle needs to be just a unique id,
95954 * use a static counter */
95955 - ctxh = atomic64_inc_return(&ctxhctr);
95956 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
95957
95958 /* make a copy for the caller */
95959 *handle = ctxh;
95960 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
95961 index ecbc4e3..ad25df8 100644
95962 --- a/net/sunrpc/clnt.c
95963 +++ b/net/sunrpc/clnt.c
95964 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
95965 (RPC_IS_ASYNC(task) ? "async" : "sync"));
95966
95967 /* Increment call count */
95968 - task->tk_msg.rpc_proc->p_count++;
95969 + pax_open_kernel();
95970 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
95971 + pax_close_kernel();
95972 clnt->cl_stats->rpccnt++;
95973 task->tk_action = call_reserve;
95974 }
95975 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
95976 index 93a7a4e..3b98b9f 100644
95977 --- a/net/sunrpc/sched.c
95978 +++ b/net/sunrpc/sched.c
95979 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
95980 #ifdef RPC_DEBUG
95981 static void rpc_task_set_debuginfo(struct rpc_task *task)
95982 {
95983 - static atomic_t rpc_pid;
95984 + static atomic_unchecked_t rpc_pid;
95985
95986 - task->tk_pid = atomic_inc_return(&rpc_pid);
95987 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
95988 }
95989 #else
95990 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
95991 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
95992 index b974571..678ed90 100644
95993 --- a/net/sunrpc/svc.c
95994 +++ b/net/sunrpc/svc.c
95995 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
95996 svc_putnl(resv, RPC_SUCCESS);
95997
95998 /* Bump per-procedure stats counter */
95999 - procp->pc_count++;
96000 + pax_open_kernel();
96001 + (*(unsigned int *)&procp->pc_count)++;
96002 + pax_close_kernel();
96003
96004 /* Initialize storage for argp and resp */
96005 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96006 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96007 index c1b6270..05089c1 100644
96008 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96009 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96010 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96011 static unsigned int min_max_inline = 4096;
96012 static unsigned int max_max_inline = 65536;
96013
96014 -atomic_t rdma_stat_recv;
96015 -atomic_t rdma_stat_read;
96016 -atomic_t rdma_stat_write;
96017 -atomic_t rdma_stat_sq_starve;
96018 -atomic_t rdma_stat_rq_starve;
96019 -atomic_t rdma_stat_rq_poll;
96020 -atomic_t rdma_stat_rq_prod;
96021 -atomic_t rdma_stat_sq_poll;
96022 -atomic_t rdma_stat_sq_prod;
96023 +atomic_unchecked_t rdma_stat_recv;
96024 +atomic_unchecked_t rdma_stat_read;
96025 +atomic_unchecked_t rdma_stat_write;
96026 +atomic_unchecked_t rdma_stat_sq_starve;
96027 +atomic_unchecked_t rdma_stat_rq_starve;
96028 +atomic_unchecked_t rdma_stat_rq_poll;
96029 +atomic_unchecked_t rdma_stat_rq_prod;
96030 +atomic_unchecked_t rdma_stat_sq_poll;
96031 +atomic_unchecked_t rdma_stat_sq_prod;
96032
96033 /* Temporary NFS request map and context caches */
96034 struct kmem_cache *svc_rdma_map_cachep;
96035 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96036 len -= *ppos;
96037 if (len > *lenp)
96038 len = *lenp;
96039 - if (len && copy_to_user(buffer, str_buf, len))
96040 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96041 return -EFAULT;
96042 *lenp = len;
96043 *ppos += len;
96044 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96045 {
96046 .procname = "rdma_stat_read",
96047 .data = &rdma_stat_read,
96048 - .maxlen = sizeof(atomic_t),
96049 + .maxlen = sizeof(atomic_unchecked_t),
96050 .mode = 0644,
96051 .proc_handler = read_reset_stat,
96052 },
96053 {
96054 .procname = "rdma_stat_recv",
96055 .data = &rdma_stat_recv,
96056 - .maxlen = sizeof(atomic_t),
96057 + .maxlen = sizeof(atomic_unchecked_t),
96058 .mode = 0644,
96059 .proc_handler = read_reset_stat,
96060 },
96061 {
96062 .procname = "rdma_stat_write",
96063 .data = &rdma_stat_write,
96064 - .maxlen = sizeof(atomic_t),
96065 + .maxlen = sizeof(atomic_unchecked_t),
96066 .mode = 0644,
96067 .proc_handler = read_reset_stat,
96068 },
96069 {
96070 .procname = "rdma_stat_sq_starve",
96071 .data = &rdma_stat_sq_starve,
96072 - .maxlen = sizeof(atomic_t),
96073 + .maxlen = sizeof(atomic_unchecked_t),
96074 .mode = 0644,
96075 .proc_handler = read_reset_stat,
96076 },
96077 {
96078 .procname = "rdma_stat_rq_starve",
96079 .data = &rdma_stat_rq_starve,
96080 - .maxlen = sizeof(atomic_t),
96081 + .maxlen = sizeof(atomic_unchecked_t),
96082 .mode = 0644,
96083 .proc_handler = read_reset_stat,
96084 },
96085 {
96086 .procname = "rdma_stat_rq_poll",
96087 .data = &rdma_stat_rq_poll,
96088 - .maxlen = sizeof(atomic_t),
96089 + .maxlen = sizeof(atomic_unchecked_t),
96090 .mode = 0644,
96091 .proc_handler = read_reset_stat,
96092 },
96093 {
96094 .procname = "rdma_stat_rq_prod",
96095 .data = &rdma_stat_rq_prod,
96096 - .maxlen = sizeof(atomic_t),
96097 + .maxlen = sizeof(atomic_unchecked_t),
96098 .mode = 0644,
96099 .proc_handler = read_reset_stat,
96100 },
96101 {
96102 .procname = "rdma_stat_sq_poll",
96103 .data = &rdma_stat_sq_poll,
96104 - .maxlen = sizeof(atomic_t),
96105 + .maxlen = sizeof(atomic_unchecked_t),
96106 .mode = 0644,
96107 .proc_handler = read_reset_stat,
96108 },
96109 {
96110 .procname = "rdma_stat_sq_prod",
96111 .data = &rdma_stat_sq_prod,
96112 - .maxlen = sizeof(atomic_t),
96113 + .maxlen = sizeof(atomic_unchecked_t),
96114 .mode = 0644,
96115 .proc_handler = read_reset_stat,
96116 },
96117 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96118 index 0ce7552..d074459 100644
96119 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96120 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96121 @@ -501,7 +501,7 @@ next_sge:
96122 svc_rdma_put_context(ctxt, 0);
96123 goto out;
96124 }
96125 - atomic_inc(&rdma_stat_read);
96126 + atomic_inc_unchecked(&rdma_stat_read);
96127
96128 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96129 chl_map->ch[ch_no].count -= read_wr.num_sge;
96130 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96131 dto_q);
96132 list_del_init(&ctxt->dto_q);
96133 } else {
96134 - atomic_inc(&rdma_stat_rq_starve);
96135 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96136 clear_bit(XPT_DATA, &xprt->xpt_flags);
96137 ctxt = NULL;
96138 }
96139 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96140 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96141 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96142 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96143 - atomic_inc(&rdma_stat_recv);
96144 + atomic_inc_unchecked(&rdma_stat_recv);
96145
96146 /* Build up the XDR from the receive buffers. */
96147 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96148 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96149 index c1d124d..acfc59e 100644
96150 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96151 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96152 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96153 write_wr.wr.rdma.remote_addr = to;
96154
96155 /* Post It */
96156 - atomic_inc(&rdma_stat_write);
96157 + atomic_inc_unchecked(&rdma_stat_write);
96158 if (svc_rdma_send(xprt, &write_wr))
96159 goto err;
96160 return 0;
96161 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96162 index 62e4f9b..dd3f2d7 100644
96163 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96164 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96165 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96166 return;
96167
96168 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96169 - atomic_inc(&rdma_stat_rq_poll);
96170 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96171
96172 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96173 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96174 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96175 }
96176
96177 if (ctxt)
96178 - atomic_inc(&rdma_stat_rq_prod);
96179 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96180
96181 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96182 /*
96183 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96184 return;
96185
96186 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96187 - atomic_inc(&rdma_stat_sq_poll);
96188 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96189 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96190 if (wc.status != IB_WC_SUCCESS)
96191 /* Close the transport */
96192 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96193 }
96194
96195 if (ctxt)
96196 - atomic_inc(&rdma_stat_sq_prod);
96197 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96198 }
96199
96200 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96201 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96202 spin_lock_bh(&xprt->sc_lock);
96203 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96204 spin_unlock_bh(&xprt->sc_lock);
96205 - atomic_inc(&rdma_stat_sq_starve);
96206 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96207
96208 /* See if we can opportunistically reap SQ WR to make room */
96209 sq_cq_reap(xprt);
96210 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96211 index 9bc6db0..47ac8c0 100644
96212 --- a/net/sysctl_net.c
96213 +++ b/net/sysctl_net.c
96214 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96215 kgid_t root_gid = make_kgid(net->user_ns, 0);
96216
96217 /* Allow network administrator to have same access as root. */
96218 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96219 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96220 uid_eq(root_uid, current_uid())) {
96221 int mode = (table->mode >> 6) & 7;
96222 return (mode << 6) | (mode << 3) | mode;
96223 diff --git a/net/tipc/link.c b/net/tipc/link.c
96224 index 0cc3d90..cc42021 100644
96225 --- a/net/tipc/link.c
96226 +++ b/net/tipc/link.c
96227 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96228 struct tipc_msg fragm_hdr;
96229 struct sk_buff *buf, *buf_chain, *prev;
96230 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96231 - const unchar *sect_crs;
96232 + const unchar __user *sect_crs;
96233 int curr_sect;
96234 u32 fragm_no;
96235 int res = 0;
96236 @@ -1207,7 +1207,7 @@ again:
96237
96238 if (!sect_rest) {
96239 sect_rest = msg_sect[++curr_sect].iov_len;
96240 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96241 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96242 }
96243
96244 if (sect_rest < fragm_rest)
96245 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96246 index ced60e2..54eab6c 100644
96247 --- a/net/tipc/msg.c
96248 +++ b/net/tipc/msg.c
96249 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96250 skb_copy_to_linear_data(*buf, hdr, hsz);
96251 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96252 skb_copy_to_linear_data_offset(*buf, pos,
96253 - msg_sect[cnt].iov_base,
96254 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96255 msg_sect[cnt].iov_len);
96256 pos += msg_sect[cnt].iov_len;
96257 }
96258 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96259 index d38bb45..4fd6ac6 100644
96260 --- a/net/tipc/subscr.c
96261 +++ b/net/tipc/subscr.c
96262 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96263 struct kvec msg_sect;
96264 int ret;
96265
96266 - msg_sect.iov_base = (void *)&sub->evt;
96267 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96268 msg_sect.iov_len = sizeof(struct tipc_event);
96269
96270 sub->evt.event = htohl(event, sub->swap);
96271 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96272 index c4ce243..2be7c59 100644
96273 --- a/net/unix/af_unix.c
96274 +++ b/net/unix/af_unix.c
96275 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96276 err = -ECONNREFUSED;
96277 if (!S_ISSOCK(inode->i_mode))
96278 goto put_fail;
96279 +
96280 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96281 + err = -EACCES;
96282 + goto put_fail;
96283 + }
96284 +
96285 u = unix_find_socket_byinode(inode);
96286 if (!u)
96287 goto put_fail;
96288 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96289 if (u) {
96290 struct dentry *dentry;
96291 dentry = unix_sk(u)->path.dentry;
96292 +
96293 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96294 + err = -EPERM;
96295 + sock_put(u);
96296 + goto fail;
96297 + }
96298 +
96299 if (dentry)
96300 touch_atime(&unix_sk(u)->path);
96301 } else
96302 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96303 */
96304 err = security_path_mknod(&path, dentry, mode, 0);
96305 if (!err) {
96306 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96307 + err = -EACCES;
96308 + goto out;
96309 + }
96310 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96311 if (!err) {
96312 res->mnt = mntget(path.mnt);
96313 res->dentry = dget(dentry);
96314 + gr_handle_create(dentry, path.mnt);
96315 }
96316 }
96317 +out:
96318 done_path_create(&path, dentry);
96319 return err;
96320 }
96321 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96322 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96323 "Inode Path\n");
96324 else {
96325 - struct sock *s = v;
96326 + struct sock *s = v, *peer;
96327 struct unix_sock *u = unix_sk(s);
96328 unix_state_lock(s);
96329 + peer = unix_peer(s);
96330 + unix_state_unlock(s);
96331 +
96332 + unix_state_double_lock(s, peer);
96333
96334 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96335 s,
96336 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96337 }
96338 for ( ; i < len; i++)
96339 seq_putc(seq, u->addr->name->sun_path[i]);
96340 - }
96341 - unix_state_unlock(s);
96342 + } else if (peer)
96343 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96344 +
96345 + unix_state_double_unlock(s, peer);
96346 seq_putc(seq, '\n');
96347 }
96348
96349 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96350 index b3d5150..ff3a837 100644
96351 --- a/net/unix/sysctl_net_unix.c
96352 +++ b/net/unix/sysctl_net_unix.c
96353 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96354
96355 int __net_init unix_sysctl_register(struct net *net)
96356 {
96357 - struct ctl_table *table;
96358 + ctl_table_no_const *table;
96359
96360 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96361 if (table == NULL)
96362 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96363 index c8717c1..08539f5 100644
96364 --- a/net/wireless/wext-core.c
96365 +++ b/net/wireless/wext-core.c
96366 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96367 */
96368
96369 /* Support for very large requests */
96370 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96371 - (user_length > descr->max_tokens)) {
96372 + if (user_length > descr->max_tokens) {
96373 /* Allow userspace to GET more than max so
96374 * we can support any size GET requests.
96375 * There is still a limit : -ENOMEM.
96376 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96377 }
96378 }
96379
96380 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96381 - /*
96382 - * If this is a GET, but not NOMAX, it means that the extra
96383 - * data is not bounded by userspace, but by max_tokens. Thus
96384 - * set the length to max_tokens. This matches the extra data
96385 - * allocation.
96386 - * The driver should fill it with the number of tokens it
96387 - * provided, and it may check iwp->length rather than having
96388 - * knowledge of max_tokens. If the driver doesn't change the
96389 - * iwp->length, this ioctl just copies back max_token tokens
96390 - * filled with zeroes. Hopefully the driver isn't claiming
96391 - * them to be valid data.
96392 - */
96393 - iwp->length = descr->max_tokens;
96394 - }
96395 -
96396 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96397
96398 iwp->length += essid_compat;
96399 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96400 index f77c371..e412fa6 100644
96401 --- a/net/xfrm/xfrm_policy.c
96402 +++ b/net/xfrm/xfrm_policy.c
96403 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96404 {
96405 policy->walk.dead = 1;
96406
96407 - atomic_inc(&policy->genid);
96408 + atomic_inc_unchecked(&policy->genid);
96409
96410 del_timer(&policy->polq.hold_timer);
96411 xfrm_queue_purge(&policy->polq.hold_queue);
96412 @@ -657,7 +657,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96413 hlist_add_head(&policy->bydst, chain);
96414 xfrm_pol_hold(policy);
96415 net->xfrm.policy_count[dir]++;
96416 - atomic_inc(&flow_cache_genid);
96417 + atomic_inc_unchecked(&flow_cache_genid);
96418 rt_genid_bump(net);
96419 if (delpol) {
96420 xfrm_policy_requeue(delpol, policy);
96421 @@ -1627,7 +1627,7 @@ free_dst:
96422 goto out;
96423 }
96424
96425 -static int inline
96426 +static inline int
96427 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96428 {
96429 if (!*target) {
96430 @@ -1639,7 +1639,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96431 return 0;
96432 }
96433
96434 -static int inline
96435 +static inline int
96436 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96437 {
96438 #ifdef CONFIG_XFRM_SUB_POLICY
96439 @@ -1651,7 +1651,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96440 #endif
96441 }
96442
96443 -static int inline
96444 +static inline int
96445 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96446 {
96447 #ifdef CONFIG_XFRM_SUB_POLICY
96448 @@ -1745,7 +1745,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96449
96450 xdst->num_pols = num_pols;
96451 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96452 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96453 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96454
96455 return xdst;
96456 }
96457 @@ -2557,11 +2557,12 @@ void xfrm_garbage_collect(struct net *net)
96458 }
96459 EXPORT_SYMBOL(xfrm_garbage_collect);
96460
96461 -static void xfrm_garbage_collect_deferred(struct net *net)
96462 +void xfrm_garbage_collect_deferred(struct net *net)
96463 {
96464 flow_cache_flush_deferred();
96465 __xfrm_garbage_collect(net);
96466 }
96467 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96468
96469 static void xfrm_init_pmtu(struct dst_entry *dst)
96470 {
96471 @@ -2611,7 +2612,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96472 if (xdst->xfrm_genid != dst->xfrm->genid)
96473 return 0;
96474 if (xdst->num_pols > 0 &&
96475 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96476 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96477 return 0;
96478
96479 mtu = dst_mtu(dst->child);
96480 @@ -2699,8 +2700,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96481 dst_ops->link_failure = xfrm_link_failure;
96482 if (likely(dst_ops->neigh_lookup == NULL))
96483 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96484 - if (likely(afinfo->garbage_collect == NULL))
96485 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96486 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96487 }
96488 spin_unlock(&xfrm_policy_afinfo_lock);
96489 @@ -2754,7 +2753,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96490 dst_ops->check = NULL;
96491 dst_ops->negative_advice = NULL;
96492 dst_ops->link_failure = NULL;
96493 - afinfo->garbage_collect = NULL;
96494 }
96495 return err;
96496 }
96497 @@ -3137,7 +3135,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96498 sizeof(pol->xfrm_vec[i].saddr));
96499 pol->xfrm_vec[i].encap_family = mp->new_family;
96500 /* flush bundles */
96501 - atomic_inc(&pol->genid);
96502 + atomic_inc_unchecked(&pol->genid);
96503 }
96504 }
96505
96506 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96507 index 54c0acd..56814bd 100644
96508 --- a/net/xfrm/xfrm_state.c
96509 +++ b/net/xfrm/xfrm_state.c
96510 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96511
96512 if (unlikely(afinfo == NULL))
96513 return -EAFNOSUPPORT;
96514 - typemap = afinfo->type_map;
96515 + typemap = (const struct xfrm_type **)afinfo->type_map;
96516 spin_lock_bh(&xfrm_type_lock);
96517
96518 - if (likely(typemap[type->proto] == NULL))
96519 + if (likely(typemap[type->proto] == NULL)) {
96520 + pax_open_kernel();
96521 typemap[type->proto] = type;
96522 - else
96523 + pax_close_kernel();
96524 + } else
96525 err = -EEXIST;
96526 spin_unlock_bh(&xfrm_type_lock);
96527 xfrm_state_put_afinfo(afinfo);
96528 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96529
96530 if (unlikely(afinfo == NULL))
96531 return -EAFNOSUPPORT;
96532 - typemap = afinfo->type_map;
96533 + typemap = (const struct xfrm_type **)afinfo->type_map;
96534 spin_lock_bh(&xfrm_type_lock);
96535
96536 if (unlikely(typemap[type->proto] != type))
96537 err = -ENOENT;
96538 - else
96539 + else {
96540 + pax_open_kernel();
96541 typemap[type->proto] = NULL;
96542 + pax_close_kernel();
96543 + }
96544 spin_unlock_bh(&xfrm_type_lock);
96545 xfrm_state_put_afinfo(afinfo);
96546 return err;
96547 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96548 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96549 {
96550 struct xfrm_state_afinfo *afinfo;
96551 - const struct xfrm_type **typemap;
96552 const struct xfrm_type *type;
96553 int modload_attempted = 0;
96554
96555 @@ -219,9 +223,8 @@ retry:
96556 afinfo = xfrm_state_get_afinfo(family);
96557 if (unlikely(afinfo == NULL))
96558 return NULL;
96559 - typemap = afinfo->type_map;
96560
96561 - type = typemap[proto];
96562 + type = afinfo->type_map[proto];
96563 if (unlikely(type && !try_module_get(type->owner)))
96564 type = NULL;
96565 if (!type && !modload_attempted) {
96566 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96567 return -EAFNOSUPPORT;
96568
96569 err = -EEXIST;
96570 - modemap = afinfo->mode_map;
96571 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96572 spin_lock_bh(&xfrm_mode_lock);
96573 if (modemap[mode->encap])
96574 goto out;
96575 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96576 if (!try_module_get(afinfo->owner))
96577 goto out;
96578
96579 - mode->afinfo = afinfo;
96580 + pax_open_kernel();
96581 + *(const void **)&mode->afinfo = afinfo;
96582 modemap[mode->encap] = mode;
96583 + pax_close_kernel();
96584 err = 0;
96585
96586 out:
96587 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
96588 return -EAFNOSUPPORT;
96589
96590 err = -ENOENT;
96591 - modemap = afinfo->mode_map;
96592 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96593 spin_lock_bh(&xfrm_mode_lock);
96594 if (likely(modemap[mode->encap] == mode)) {
96595 + pax_open_kernel();
96596 modemap[mode->encap] = NULL;
96597 + pax_close_kernel();
96598 module_put(mode->afinfo->owner);
96599 err = 0;
96600 }
96601 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
96602 u32 xfrm_get_acqseq(void)
96603 {
96604 u32 res;
96605 - static atomic_t acqseq;
96606 + static atomic_unchecked_t acqseq;
96607
96608 do {
96609 - res = atomic_inc_return(&acqseq);
96610 + res = atomic_inc_return_unchecked(&acqseq);
96611 } while (!res);
96612
96613 return res;
96614 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
96615 index 05a6e3d..6716ec9 100644
96616 --- a/net/xfrm/xfrm_sysctl.c
96617 +++ b/net/xfrm/xfrm_sysctl.c
96618 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
96619
96620 int __net_init xfrm_sysctl_init(struct net *net)
96621 {
96622 - struct ctl_table *table;
96623 + ctl_table_no_const *table;
96624
96625 __xfrm_sysctl_init(net);
96626
96627 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
96628 index 3f565e4..4b26cee 100644
96629 --- a/net/xfrm/xfrm_user.c
96630 +++ b/net/xfrm/xfrm_user.c
96631 @@ -1856,7 +1856,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
96632 if (x->km.state != XFRM_STATE_VALID)
96633 goto out;
96634
96635 - err = xfrm_replay_verify_len(x->replay_esn, rp);
96636 + err = xfrm_replay_verify_len(x->replay_esn, re);
96637 if (err)
96638 goto out;
96639
96640 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
96641 index d5d859c..781cbcb 100644
96642 --- a/scripts/Makefile.build
96643 +++ b/scripts/Makefile.build
96644 @@ -111,7 +111,7 @@ endif
96645 endif
96646
96647 # Do not include host rules unless needed
96648 -ifneq ($(hostprogs-y)$(hostprogs-m),)
96649 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
96650 include scripts/Makefile.host
96651 endif
96652
96653 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
96654 index 686cb0d..9d653bf 100644
96655 --- a/scripts/Makefile.clean
96656 +++ b/scripts/Makefile.clean
96657 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
96658 __clean-files := $(extra-y) $(always) \
96659 $(targets) $(clean-files) \
96660 $(host-progs) \
96661 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
96662 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
96663 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
96664
96665 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
96666
96667 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
96668 index 1ac414f..38575f7 100644
96669 --- a/scripts/Makefile.host
96670 +++ b/scripts/Makefile.host
96671 @@ -31,6 +31,8 @@
96672 # Note: Shared libraries consisting of C++ files are not supported
96673
96674 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
96675 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
96676 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
96677
96678 # C code
96679 # Executables compiled from a single .c file
96680 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
96681 # Shared libaries (only .c supported)
96682 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
96683 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
96684 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
96685 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
96686 # Remove .so files from "xxx-objs"
96687 host-cobjs := $(filter-out %.so,$(host-cobjs))
96688 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
96689
96690 -#Object (.o) files used by the shared libaries
96691 +# Object (.o) files used by the shared libaries
96692 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
96693 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
96694
96695 # output directory for programs/.o files
96696 # hostprogs-y := tools/build may have been specified. Retrieve directory
96697 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
96698 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
96699 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
96700 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
96701 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
96702 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
96703 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
96704 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
96705
96706 obj-dirs += $(host-objdirs)
96707 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
96708 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
96709 $(call if_changed_dep,host-cshobjs)
96710
96711 +# Compile .c file, create position independent .o file
96712 +# host-cxxshobjs -> .o
96713 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
96714 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
96715 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
96716 + $(call if_changed_dep,host-cxxshobjs)
96717 +
96718 # Link a shared library, based on position independent .o files
96719 # *.o -> .so shared library (host-cshlib)
96720 quiet_cmd_host-cshlib = HOSTLLD -shared $@
96721 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
96722 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
96723 $(call if_changed,host-cshlib)
96724
96725 +# Link a shared library, based on position independent .o files
96726 +# *.o -> .so shared library (host-cxxshlib)
96727 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
96728 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
96729 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
96730 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
96731 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
96732 + $(call if_changed,host-cxxshlib)
96733 +
96734 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
96735 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
96736 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
96737
96738 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
96739 index 078fe1d..fbdb363 100644
96740 --- a/scripts/basic/fixdep.c
96741 +++ b/scripts/basic/fixdep.c
96742 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
96743 /*
96744 * Lookup a value in the configuration string.
96745 */
96746 -static int is_defined_config(const char *name, int len, unsigned int hash)
96747 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
96748 {
96749 struct item *aux;
96750
96751 @@ -211,10 +211,10 @@ static void clear_config(void)
96752 /*
96753 * Record the use of a CONFIG_* word.
96754 */
96755 -static void use_config(const char *m, int slen)
96756 +static void use_config(const char *m, unsigned int slen)
96757 {
96758 unsigned int hash = strhash(m, slen);
96759 - int c, i;
96760 + unsigned int c, i;
96761
96762 if (is_defined_config(m, slen, hash))
96763 return;
96764 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
96765
96766 static void parse_config_file(const char *map, size_t len)
96767 {
96768 - const int *end = (const int *) (map + len);
96769 + const unsigned int *end = (const unsigned int *) (map + len);
96770 /* start at +1, so that p can never be < map */
96771 - const int *m = (const int *) map + 1;
96772 + const unsigned int *m = (const unsigned int *) map + 1;
96773 const char *p, *q;
96774
96775 for (; m < end; m++) {
96776 @@ -435,7 +435,7 @@ static void print_deps(void)
96777 static void traps(void)
96778 {
96779 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
96780 - int *p = (int *)test;
96781 + unsigned int *p = (unsigned int *)test;
96782
96783 if (*p != INT_CONF) {
96784 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
96785 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
96786 new file mode 100644
96787 index 0000000..5e0222d
96788 --- /dev/null
96789 +++ b/scripts/gcc-plugin.sh
96790 @@ -0,0 +1,17 @@
96791 +#!/bin/bash
96792 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
96793 +#include "gcc-plugin.h"
96794 +#include "tree.h"
96795 +#include "tm.h"
96796 +#include "rtl.h"
96797 +#ifdef ENABLE_BUILD_WITH_CXX
96798 +#warning $2
96799 +#else
96800 +#warning $1
96801 +#endif
96802 +EOF`
96803 +if [ $? -eq 0 ]
96804 +then
96805 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
96806 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
96807 +fi
96808 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
96809 index 5de5660..d3deb89 100644
96810 --- a/scripts/headers_install.sh
96811 +++ b/scripts/headers_install.sh
96812 @@ -32,6 +32,7 @@ do
96813 FILE="$(basename "$i")"
96814 sed -r \
96815 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
96816 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
96817 -e 's/__attribute_const__([ \t]|$)/\1/g' \
96818 -e 's@^#include <linux/compiler.h>@@' \
96819 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
96820 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
96821 index 0149949..d482a0d 100644
96822 --- a/scripts/link-vmlinux.sh
96823 +++ b/scripts/link-vmlinux.sh
96824 @@ -158,7 +158,7 @@ else
96825 fi;
96826
96827 # final build of init/
96828 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
96829 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
96830
96831 kallsymso=""
96832 kallsyms_vmlinux=""
96833 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
96834 index 2370863..212fbca 100644
96835 --- a/scripts/mod/file2alias.c
96836 +++ b/scripts/mod/file2alias.c
96837 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
96838 unsigned long size, unsigned long id_size,
96839 void *symval)
96840 {
96841 - int i;
96842 + unsigned int i;
96843
96844 if (size % id_size || size < id_size) {
96845 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
96846 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
96847 /* USB is special because the bcdDevice can be matched against a numeric range */
96848 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
96849 static void do_usb_entry(void *symval,
96850 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
96851 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
96852 unsigned char range_lo, unsigned char range_hi,
96853 unsigned char max, struct module *mod)
96854 {
96855 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
96856 {
96857 unsigned int devlo, devhi;
96858 unsigned char chi, clo, max;
96859 - int ndigits;
96860 + unsigned int ndigits;
96861
96862 DEF_FIELD(symval, usb_device_id, match_flags);
96863 DEF_FIELD(symval, usb_device_id, idVendor);
96864 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
96865 for (i = 0; i < count; i++) {
96866 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
96867 char acpi_id[sizeof(*id)];
96868 - int j;
96869 + unsigned int j;
96870
96871 buf_printf(&mod->dev_table_buf,
96872 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
96873 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96874
96875 for (j = 0; j < PNP_MAX_DEVICES; j++) {
96876 const char *id = (char *)(*devs)[j].id;
96877 - int i2, j2;
96878 + unsigned int i2, j2;
96879 int dup = 0;
96880
96881 if (!id[0])
96882 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96883 /* add an individual alias for every device entry */
96884 if (!dup) {
96885 char acpi_id[PNP_ID_LEN];
96886 - int k;
96887 + unsigned int k;
96888
96889 buf_printf(&mod->dev_table_buf,
96890 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
96891 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
96892 static int do_dmi_entry(const char *filename, void *symval,
96893 char *alias)
96894 {
96895 - int i, j;
96896 + unsigned int i, j;
96897 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
96898 sprintf(alias, "dmi*");
96899
96900 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
96901 index 6216434..050cf89 100644
96902 --- a/scripts/mod/modpost.c
96903 +++ b/scripts/mod/modpost.c
96904 @@ -930,6 +930,7 @@ enum mismatch {
96905 ANY_INIT_TO_ANY_EXIT,
96906 ANY_EXIT_TO_ANY_INIT,
96907 EXPORT_TO_INIT_EXIT,
96908 + DATA_TO_TEXT
96909 };
96910
96911 struct sectioncheck {
96912 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
96913 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
96914 .mismatch = EXPORT_TO_INIT_EXIT,
96915 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
96916 +},
96917 +/* Do not reference code from writable data */
96918 +{
96919 + .fromsec = { DATA_SECTIONS, NULL },
96920 + .tosec = { TEXT_SECTIONS, NULL },
96921 + .mismatch = DATA_TO_TEXT
96922 }
96923 };
96924
96925 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
96926 continue;
96927 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
96928 continue;
96929 - if (sym->st_value == addr)
96930 - return sym;
96931 /* Find a symbol nearby - addr are maybe negative */
96932 d = sym->st_value - addr;
96933 + if (d == 0)
96934 + return sym;
96935 if (d < 0)
96936 d = addr - sym->st_value;
96937 if (d < distance) {
96938 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
96939 tosym, prl_to, prl_to, tosym);
96940 free(prl_to);
96941 break;
96942 + case DATA_TO_TEXT:
96943 +#if 0
96944 + fprintf(stderr,
96945 + "The %s %s:%s references\n"
96946 + "the %s %s:%s%s\n",
96947 + from, fromsec, fromsym, to, tosec, tosym, to_p);
96948 +#endif
96949 + break;
96950 }
96951 fprintf(stderr, "\n");
96952 }
96953 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
96954 static void check_sec_ref(struct module *mod, const char *modname,
96955 struct elf_info *elf)
96956 {
96957 - int i;
96958 + unsigned int i;
96959 Elf_Shdr *sechdrs = elf->sechdrs;
96960
96961 /* Walk through all sections */
96962 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
96963 va_end(ap);
96964 }
96965
96966 -void buf_write(struct buffer *buf, const char *s, int len)
96967 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
96968 {
96969 if (buf->size - buf->pos < len) {
96970 buf->size += len + SZ;
96971 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
96972 if (fstat(fileno(file), &st) < 0)
96973 goto close_write;
96974
96975 - if (st.st_size != b->pos)
96976 + if (st.st_size != (off_t)b->pos)
96977 goto close_write;
96978
96979 tmp = NOFAIL(malloc(b->pos));
96980 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
96981 index 51207e4..f7d603d 100644
96982 --- a/scripts/mod/modpost.h
96983 +++ b/scripts/mod/modpost.h
96984 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
96985
96986 struct buffer {
96987 char *p;
96988 - int pos;
96989 - int size;
96990 + unsigned int pos;
96991 + unsigned int size;
96992 };
96993
96994 void __attribute__((format(printf, 2, 3)))
96995 buf_printf(struct buffer *buf, const char *fmt, ...);
96996
96997 void
96998 -buf_write(struct buffer *buf, const char *s, int len);
96999 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97000
97001 struct module {
97002 struct module *next;
97003 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97004 index 9dfcd6d..099068e 100644
97005 --- a/scripts/mod/sumversion.c
97006 +++ b/scripts/mod/sumversion.c
97007 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97008 goto out;
97009 }
97010
97011 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97012 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97013 warn("writing sum in %s failed: %s\n",
97014 filename, strerror(errno));
97015 goto out;
97016 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97017 index 0865b3e..7235dd4 100644
97018 --- a/scripts/module-common.lds
97019 +++ b/scripts/module-common.lds
97020 @@ -6,6 +6,10 @@
97021 SECTIONS {
97022 /DISCARD/ : { *(.discard) }
97023
97024 + .rodata : {
97025 + *(.rodata) *(.rodata.*)
97026 + *(.data..read_only)
97027 + }
97028 __ksymtab : { *(SORT(___ksymtab+*)) }
97029 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97030 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97031 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97032 index acb8650..b8c5f02 100644
97033 --- a/scripts/package/builddeb
97034 +++ b/scripts/package/builddeb
97035 @@ -246,6 +246,7 @@ fi
97036 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97037 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97038 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97039 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97040 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97041 mkdir -p "$destdir"
97042 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97043 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97044 index 68bb4ef..2f419e1 100644
97045 --- a/scripts/pnmtologo.c
97046 +++ b/scripts/pnmtologo.c
97047 @@ -244,14 +244,14 @@ static void write_header(void)
97048 fprintf(out, " * Linux logo %s\n", logoname);
97049 fputs(" */\n\n", out);
97050 fputs("#include <linux/linux_logo.h>\n\n", out);
97051 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97052 + fprintf(out, "static unsigned char %s_data[] = {\n",
97053 logoname);
97054 }
97055
97056 static void write_footer(void)
97057 {
97058 fputs("\n};\n\n", out);
97059 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97060 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97061 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97062 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97063 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97064 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97065 fputs("\n};\n\n", out);
97066
97067 /* write logo clut */
97068 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97069 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97070 logoname);
97071 write_hex_cnt = 0;
97072 for (i = 0; i < logo_clutsize; i++) {
97073 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97074 index f5eb43d..1814de8 100644
97075 --- a/scripts/sortextable.h
97076 +++ b/scripts/sortextable.h
97077 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97078 const char *secstrtab;
97079 const char *strtab;
97080 char *extab_image;
97081 - int extab_index = 0;
97082 - int i;
97083 - int idx;
97084 + unsigned int extab_index = 0;
97085 + unsigned int i;
97086 + unsigned int idx;
97087
97088 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97089 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97090 diff --git a/security/Kconfig b/security/Kconfig
97091 index e9c6ac7..c5d45c8 100644
97092 --- a/security/Kconfig
97093 +++ b/security/Kconfig
97094 @@ -4,6 +4,959 @@
97095
97096 menu "Security options"
97097
97098 +menu "Grsecurity"
97099 +
97100 + config ARCH_TRACK_EXEC_LIMIT
97101 + bool
97102 +
97103 + config PAX_KERNEXEC_PLUGIN
97104 + bool
97105 +
97106 + config PAX_PER_CPU_PGD
97107 + bool
97108 +
97109 + config TASK_SIZE_MAX_SHIFT
97110 + int
97111 + depends on X86_64
97112 + default 47 if !PAX_PER_CPU_PGD
97113 + default 42 if PAX_PER_CPU_PGD
97114 +
97115 + config PAX_ENABLE_PAE
97116 + bool
97117 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97118 +
97119 + config PAX_USERCOPY_SLABS
97120 + bool
97121 +
97122 +config GRKERNSEC
97123 + bool "Grsecurity"
97124 + select CRYPTO
97125 + select CRYPTO_SHA256
97126 + select PROC_FS
97127 + select STOP_MACHINE
97128 + select TTY
97129 + help
97130 + If you say Y here, you will be able to configure many features
97131 + that will enhance the security of your system. It is highly
97132 + recommended that you say Y here and read through the help
97133 + for each option so that you fully understand the features and
97134 + can evaluate their usefulness for your machine.
97135 +
97136 +choice
97137 + prompt "Configuration Method"
97138 + depends on GRKERNSEC
97139 + default GRKERNSEC_CONFIG_CUSTOM
97140 + help
97141 +
97142 +config GRKERNSEC_CONFIG_AUTO
97143 + bool "Automatic"
97144 + help
97145 + If you choose this configuration method, you'll be able to answer a small
97146 + number of simple questions about how you plan to use this kernel.
97147 + The settings of grsecurity and PaX will be automatically configured for
97148 + the highest commonly-used settings within the provided constraints.
97149 +
97150 + If you require additional configuration, custom changes can still be made
97151 + from the "custom configuration" menu.
97152 +
97153 +config GRKERNSEC_CONFIG_CUSTOM
97154 + bool "Custom"
97155 + help
97156 + If you choose this configuration method, you'll be able to configure all
97157 + grsecurity and PaX settings manually. Via this method, no options are
97158 + automatically enabled.
97159 +
97160 +endchoice
97161 +
97162 +choice
97163 + prompt "Usage Type"
97164 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97165 + default GRKERNSEC_CONFIG_SERVER
97166 + help
97167 +
97168 +config GRKERNSEC_CONFIG_SERVER
97169 + bool "Server"
97170 + help
97171 + Choose this option if you plan to use this kernel on a server.
97172 +
97173 +config GRKERNSEC_CONFIG_DESKTOP
97174 + bool "Desktop"
97175 + help
97176 + Choose this option if you plan to use this kernel on a desktop.
97177 +
97178 +endchoice
97179 +
97180 +choice
97181 + prompt "Virtualization Type"
97182 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97183 + default GRKERNSEC_CONFIG_VIRT_NONE
97184 + help
97185 +
97186 +config GRKERNSEC_CONFIG_VIRT_NONE
97187 + bool "None"
97188 + help
97189 + Choose this option if this kernel will be run on bare metal.
97190 +
97191 +config GRKERNSEC_CONFIG_VIRT_GUEST
97192 + bool "Guest"
97193 + help
97194 + Choose this option if this kernel will be run as a VM guest.
97195 +
97196 +config GRKERNSEC_CONFIG_VIRT_HOST
97197 + bool "Host"
97198 + help
97199 + Choose this option if this kernel will be run as a VM host.
97200 +
97201 +endchoice
97202 +
97203 +choice
97204 + prompt "Virtualization Hardware"
97205 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97206 + help
97207 +
97208 +config GRKERNSEC_CONFIG_VIRT_EPT
97209 + bool "EPT/RVI Processor Support"
97210 + depends on X86
97211 + help
97212 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97213 + hardware virtualization. This allows for additional kernel hardening protections
97214 + to operate without additional performance impact.
97215 +
97216 + To see if your Intel processor supports EPT, see:
97217 + http://ark.intel.com/Products/VirtualizationTechnology
97218 + (Most Core i3/5/7 support EPT)
97219 +
97220 + To see if your AMD processor supports RVI, see:
97221 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97222 +
97223 +config GRKERNSEC_CONFIG_VIRT_SOFT
97224 + bool "First-gen/No Hardware Virtualization"
97225 + help
97226 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97227 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97228 +
97229 +endchoice
97230 +
97231 +choice
97232 + prompt "Virtualization Software"
97233 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97234 + help
97235 +
97236 +config GRKERNSEC_CONFIG_VIRT_XEN
97237 + bool "Xen"
97238 + help
97239 + Choose this option if this kernel is running as a Xen guest or host.
97240 +
97241 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97242 + bool "VMWare"
97243 + help
97244 + Choose this option if this kernel is running as a VMWare guest or host.
97245 +
97246 +config GRKERNSEC_CONFIG_VIRT_KVM
97247 + bool "KVM"
97248 + help
97249 + Choose this option if this kernel is running as a KVM guest or host.
97250 +
97251 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97252 + bool "VirtualBox"
97253 + help
97254 + Choose this option if this kernel is running as a VirtualBox guest or host.
97255 +
97256 +endchoice
97257 +
97258 +choice
97259 + prompt "Required Priorities"
97260 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97261 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97262 + help
97263 +
97264 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97265 + bool "Performance"
97266 + help
97267 + Choose this option if performance is of highest priority for this deployment
97268 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97269 + clearing of structures intended for userland, and freed memory sanitizing will
97270 + be disabled.
97271 +
97272 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97273 + bool "Security"
97274 + help
97275 + Choose this option if security is of highest priority for this deployment of
97276 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97277 + for userland, and freed memory sanitizing will be enabled for this kernel.
97278 + In a worst-case scenario, these features can introduce a 20% performance hit
97279 + (UDEREF on x64 contributing half of this hit).
97280 +
97281 +endchoice
97282 +
97283 +menu "Default Special Groups"
97284 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97285 +
97286 +config GRKERNSEC_PROC_GID
97287 + int "GID exempted from /proc restrictions"
97288 + default 1001
97289 + help
97290 + Setting this GID determines which group will be exempted from
97291 + grsecurity's /proc restrictions, allowing users of the specified
97292 + group to view network statistics and the existence of other users'
97293 + processes on the system. This GID may also be chosen at boot time
97294 + via "grsec_proc_gid=" on the kernel commandline.
97295 +
97296 +config GRKERNSEC_TPE_UNTRUSTED_GID
97297 + int "GID for TPE-untrusted users"
97298 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97299 + default 1005
97300 + help
97301 + Setting this GID determines which group untrusted users should
97302 + be added to. These users will be placed under grsecurity's Trusted Path
97303 + Execution mechanism, preventing them from executing their own binaries.
97304 + The users will only be able to execute binaries in directories owned and
97305 + writable only by the root user. If the sysctl option is enabled, a sysctl
97306 + option with name "tpe_gid" is created.
97307 +
97308 +config GRKERNSEC_TPE_TRUSTED_GID
97309 + int "GID for TPE-trusted users"
97310 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97311 + default 1005
97312 + help
97313 + Setting this GID determines what group TPE restrictions will be
97314 + *disabled* for. If the sysctl option is enabled, a sysctl option
97315 + with name "tpe_gid" is created.
97316 +
97317 +config GRKERNSEC_SYMLINKOWN_GID
97318 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97319 + depends on GRKERNSEC_CONFIG_SERVER
97320 + default 1006
97321 + help
97322 + Setting this GID determines what group kernel-enforced
97323 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97324 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97325 +
97326 +
97327 +endmenu
97328 +
97329 +menu "Customize Configuration"
97330 +depends on GRKERNSEC
97331 +
97332 +menu "PaX"
97333 +
97334 +config PAX
97335 + bool "Enable various PaX features"
97336 + default y if GRKERNSEC_CONFIG_AUTO
97337 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97338 + help
97339 + This allows you to enable various PaX features. PaX adds
97340 + intrusion prevention mechanisms to the kernel that reduce
97341 + the risks posed by exploitable memory corruption bugs.
97342 +
97343 +menu "PaX Control"
97344 + depends on PAX
97345 +
97346 +config PAX_SOFTMODE
97347 + bool 'Support soft mode'
97348 + help
97349 + Enabling this option will allow you to run PaX in soft mode, that
97350 + is, PaX features will not be enforced by default, only on executables
97351 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97352 + support as they are the only way to mark executables for soft mode use.
97353 +
97354 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97355 + line option on boot. Furthermore you can control various PaX features
97356 + at runtime via the entries in /proc/sys/kernel/pax.
97357 +
97358 +config PAX_EI_PAX
97359 + bool 'Use legacy ELF header marking'
97360 + default y if GRKERNSEC_CONFIG_AUTO
97361 + help
97362 + Enabling this option will allow you to control PaX features on
97363 + a per executable basis via the 'chpax' utility available at
97364 + http://pax.grsecurity.net/. The control flags will be read from
97365 + an otherwise reserved part of the ELF header. This marking has
97366 + numerous drawbacks (no support for soft-mode, toolchain does not
97367 + know about the non-standard use of the ELF header) therefore it
97368 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97369 + support.
97370 +
97371 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97372 + support as well, they will override the legacy EI_PAX marks.
97373 +
97374 + If you enable none of the marking options then all applications
97375 + will run with PaX enabled on them by default.
97376 +
97377 +config PAX_PT_PAX_FLAGS
97378 + bool 'Use ELF program header marking'
97379 + default y if GRKERNSEC_CONFIG_AUTO
97380 + help
97381 + Enabling this option will allow you to control PaX features on
97382 + a per executable basis via the 'paxctl' utility available at
97383 + http://pax.grsecurity.net/. The control flags will be read from
97384 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97385 + has the benefits of supporting both soft mode and being fully
97386 + integrated into the toolchain (the binutils patch is available
97387 + from http://pax.grsecurity.net).
97388 +
97389 + Note that if you enable the legacy EI_PAX marking support as well,
97390 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97391 +
97392 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97393 + must make sure that the marks are the same if a binary has both marks.
97394 +
97395 + If you enable none of the marking options then all applications
97396 + will run with PaX enabled on them by default.
97397 +
97398 +config PAX_XATTR_PAX_FLAGS
97399 + bool 'Use filesystem extended attributes marking'
97400 + default y if GRKERNSEC_CONFIG_AUTO
97401 + select CIFS_XATTR if CIFS
97402 + select EXT2_FS_XATTR if EXT2_FS
97403 + select EXT3_FS_XATTR if EXT3_FS
97404 + select EXT4_FS_XATTR if EXT4_FS
97405 + select JFFS2_FS_XATTR if JFFS2_FS
97406 + select REISERFS_FS_XATTR if REISERFS_FS
97407 + select SQUASHFS_XATTR if SQUASHFS
97408 + select TMPFS_XATTR if TMPFS
97409 + select UBIFS_FS_XATTR if UBIFS_FS
97410 + help
97411 + Enabling this option will allow you to control PaX features on
97412 + a per executable basis via the 'setfattr' utility. The control
97413 + flags will be read from the user.pax.flags extended attribute of
97414 + the file. This marking has the benefit of supporting binary-only
97415 + applications that self-check themselves (e.g., skype) and would
97416 + not tolerate chpax/paxctl changes. The main drawback is that
97417 + extended attributes are not supported by some filesystems (e.g.,
97418 + isofs, udf, vfat) so copying files through such filesystems will
97419 + lose the extended attributes and these PaX markings.
97420 +
97421 + Note that if you enable the legacy EI_PAX marking support as well,
97422 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97423 +
97424 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97425 + must make sure that the marks are the same if a binary has both marks.
97426 +
97427 + If you enable none of the marking options then all applications
97428 + will run with PaX enabled on them by default.
97429 +
97430 +choice
97431 + prompt 'MAC system integration'
97432 + default PAX_HAVE_ACL_FLAGS
97433 + help
97434 + Mandatory Access Control systems have the option of controlling
97435 + PaX flags on a per executable basis, choose the method supported
97436 + by your particular system.
97437 +
97438 + - "none": if your MAC system does not interact with PaX,
97439 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97440 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97441 +
97442 + NOTE: this option is for developers/integrators only.
97443 +
97444 + config PAX_NO_ACL_FLAGS
97445 + bool 'none'
97446 +
97447 + config PAX_HAVE_ACL_FLAGS
97448 + bool 'direct'
97449 +
97450 + config PAX_HOOK_ACL_FLAGS
97451 + bool 'hook'
97452 +endchoice
97453 +
97454 +endmenu
97455 +
97456 +menu "Non-executable pages"
97457 + depends on PAX
97458 +
97459 +config PAX_NOEXEC
97460 + bool "Enforce non-executable pages"
97461 + default y if GRKERNSEC_CONFIG_AUTO
97462 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97463 + help
97464 + By design some architectures do not allow for protecting memory
97465 + pages against execution or even if they do, Linux does not make
97466 + use of this feature. In practice this means that if a page is
97467 + readable (such as the stack or heap) it is also executable.
97468 +
97469 + There is a well known exploit technique that makes use of this
97470 + fact and a common programming mistake where an attacker can
97471 + introduce code of his choice somewhere in the attacked program's
97472 + memory (typically the stack or the heap) and then execute it.
97473 +
97474 + If the attacked program was running with different (typically
97475 + higher) privileges than that of the attacker, then he can elevate
97476 + his own privilege level (e.g. get a root shell, write to files for
97477 + which he does not have write access to, etc).
97478 +
97479 + Enabling this option will let you choose from various features
97480 + that prevent the injection and execution of 'foreign' code in
97481 + a program.
97482 +
97483 + This will also break programs that rely on the old behaviour and
97484 + expect that dynamically allocated memory via the malloc() family
97485 + of functions is executable (which it is not). Notable examples
97486 + are the XFree86 4.x server, the java runtime and wine.
97487 +
97488 +config PAX_PAGEEXEC
97489 + bool "Paging based non-executable pages"
97490 + default y if GRKERNSEC_CONFIG_AUTO
97491 + 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)
97492 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97493 + help
97494 + This implementation is based on the paging feature of the CPU.
97495 + On i386 without hardware non-executable bit support there is a
97496 + variable but usually low performance impact, however on Intel's
97497 + P4 core based CPUs it is very high so you should not enable this
97498 + for kernels meant to be used on such CPUs.
97499 +
97500 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97501 + with hardware non-executable bit support there is no performance
97502 + impact, on ppc the impact is negligible.
97503 +
97504 + Note that several architectures require various emulations due to
97505 + badly designed userland ABIs, this will cause a performance impact
97506 + but will disappear as soon as userland is fixed. For example, ppc
97507 + userland MUST have been built with secure-plt by a recent toolchain.
97508 +
97509 +config PAX_SEGMEXEC
97510 + bool "Segmentation based non-executable pages"
97511 + default y if GRKERNSEC_CONFIG_AUTO
97512 + depends on PAX_NOEXEC && X86_32
97513 + help
97514 + This implementation is based on the segmentation feature of the
97515 + CPU and has a very small performance impact, however applications
97516 + will be limited to a 1.5 GB address space instead of the normal
97517 + 3 GB.
97518 +
97519 +config PAX_EMUTRAMP
97520 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97521 + default y if PARISC
97522 + help
97523 + There are some programs and libraries that for one reason or
97524 + another attempt to execute special small code snippets from
97525 + non-executable memory pages. Most notable examples are the
97526 + signal handler return code generated by the kernel itself and
97527 + the GCC trampolines.
97528 +
97529 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97530 + such programs will no longer work under your kernel.
97531 +
97532 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97533 + utilities to enable trampoline emulation for the affected programs
97534 + yet still have the protection provided by the non-executable pages.
97535 +
97536 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97537 + your system will not even boot.
97538 +
97539 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97540 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97541 + for the affected files.
97542 +
97543 + NOTE: enabling this feature *may* open up a loophole in the
97544 + protection provided by non-executable pages that an attacker
97545 + could abuse. Therefore the best solution is to not have any
97546 + files on your system that would require this option. This can
97547 + be achieved by not using libc5 (which relies on the kernel
97548 + signal handler return code) and not using or rewriting programs
97549 + that make use of the nested function implementation of GCC.
97550 + Skilled users can just fix GCC itself so that it implements
97551 + nested function calls in a way that does not interfere with PaX.
97552 +
97553 +config PAX_EMUSIGRT
97554 + bool "Automatically emulate sigreturn trampolines"
97555 + depends on PAX_EMUTRAMP && PARISC
97556 + default y
97557 + help
97558 + Enabling this option will have the kernel automatically detect
97559 + and emulate signal return trampolines executing on the stack
97560 + that would otherwise lead to task termination.
97561 +
97562 + This solution is intended as a temporary one for users with
97563 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
97564 + Modula-3 runtime, etc) or executables linked to such, basically
97565 + everything that does not specify its own SA_RESTORER function in
97566 + normal executable memory like glibc 2.1+ does.
97567 +
97568 + On parisc you MUST enable this option, otherwise your system will
97569 + not even boot.
97570 +
97571 + NOTE: this feature cannot be disabled on a per executable basis
97572 + and since it *does* open up a loophole in the protection provided
97573 + by non-executable pages, the best solution is to not have any
97574 + files on your system that would require this option.
97575 +
97576 +config PAX_MPROTECT
97577 + bool "Restrict mprotect()"
97578 + default y if GRKERNSEC_CONFIG_AUTO
97579 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
97580 + help
97581 + Enabling this option will prevent programs from
97582 + - changing the executable status of memory pages that were
97583 + not originally created as executable,
97584 + - making read-only executable pages writable again,
97585 + - creating executable pages from anonymous memory,
97586 + - making read-only-after-relocations (RELRO) data pages writable again.
97587 +
97588 + You should say Y here to complete the protection provided by
97589 + the enforcement of non-executable pages.
97590 +
97591 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97592 + this feature on a per file basis.
97593 +
97594 +config PAX_MPROTECT_COMPAT
97595 + bool "Use legacy/compat protection demoting (read help)"
97596 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97597 + depends on PAX_MPROTECT
97598 + help
97599 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
97600 + by sending the proper error code to the application. For some broken
97601 + userland, this can cause problems with Python or other applications. The
97602 + current implementation however allows for applications like clamav to
97603 + detect if JIT compilation/execution is allowed and to fall back gracefully
97604 + to an interpreter-based mode if it does not. While we encourage everyone
97605 + to use the current implementation as-is and push upstream to fix broken
97606 + userland (note that the RWX logging option can assist with this), in some
97607 + environments this may not be possible. Having to disable MPROTECT
97608 + completely on certain binaries reduces the security benefit of PaX,
97609 + so this option is provided for those environments to revert to the old
97610 + behavior.
97611 +
97612 +config PAX_ELFRELOCS
97613 + bool "Allow ELF text relocations (read help)"
97614 + depends on PAX_MPROTECT
97615 + default n
97616 + help
97617 + Non-executable pages and mprotect() restrictions are effective
97618 + in preventing the introduction of new executable code into an
97619 + attacked task's address space. There remain only two venues
97620 + for this kind of attack: if the attacker can execute already
97621 + existing code in the attacked task then he can either have it
97622 + create and mmap() a file containing his code or have it mmap()
97623 + an already existing ELF library that does not have position
97624 + independent code in it and use mprotect() on it to make it
97625 + writable and copy his code there. While protecting against
97626 + the former approach is beyond PaX, the latter can be prevented
97627 + by having only PIC ELF libraries on one's system (which do not
97628 + need to relocate their code). If you are sure this is your case,
97629 + as is the case with all modern Linux distributions, then leave
97630 + this option disabled. You should say 'n' here.
97631 +
97632 +config PAX_ETEXECRELOCS
97633 + bool "Allow ELF ET_EXEC text relocations"
97634 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
97635 + select PAX_ELFRELOCS
97636 + default y
97637 + help
97638 + On some architectures there are incorrectly created applications
97639 + that require text relocations and would not work without enabling
97640 + this option. If you are an alpha, ia64 or parisc user, you should
97641 + enable this option and disable it once you have made sure that
97642 + none of your applications need it.
97643 +
97644 +config PAX_EMUPLT
97645 + bool "Automatically emulate ELF PLT"
97646 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
97647 + default y
97648 + help
97649 + Enabling this option will have the kernel automatically detect
97650 + and emulate the Procedure Linkage Table entries in ELF files.
97651 + On some architectures such entries are in writable memory, and
97652 + become non-executable leading to task termination. Therefore
97653 + it is mandatory that you enable this option on alpha, parisc,
97654 + sparc and sparc64, otherwise your system would not even boot.
97655 +
97656 + NOTE: this feature *does* open up a loophole in the protection
97657 + provided by the non-executable pages, therefore the proper
97658 + solution is to modify the toolchain to produce a PLT that does
97659 + not need to be writable.
97660 +
97661 +config PAX_DLRESOLVE
97662 + bool 'Emulate old glibc resolver stub'
97663 + depends on PAX_EMUPLT && SPARC
97664 + default n
97665 + help
97666 + This option is needed if userland has an old glibc (before 2.4)
97667 + that puts a 'save' instruction into the runtime generated resolver
97668 + stub that needs special emulation.
97669 +
97670 +config PAX_KERNEXEC
97671 + bool "Enforce non-executable kernel pages"
97672 + 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))
97673 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
97674 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
97675 + select PAX_KERNEXEC_PLUGIN if X86_64
97676 + help
97677 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
97678 + that is, enabling this option will make it harder to inject
97679 + and execute 'foreign' code in kernel memory itself.
97680 +
97681 +choice
97682 + prompt "Return Address Instrumentation Method"
97683 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
97684 + depends on PAX_KERNEXEC_PLUGIN
97685 + help
97686 + Select the method used to instrument function pointer dereferences.
97687 + Note that binary modules cannot be instrumented by this approach.
97688 +
97689 + Note that the implementation requires a gcc with plugin support,
97690 + i.e., gcc 4.5 or newer. You may need to install the supporting
97691 + headers explicitly in addition to the normal gcc package.
97692 +
97693 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
97694 + bool "bts"
97695 + help
97696 + This method is compatible with binary only modules but has
97697 + a higher runtime overhead.
97698 +
97699 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
97700 + bool "or"
97701 + depends on !PARAVIRT
97702 + help
97703 + This method is incompatible with binary only modules but has
97704 + a lower runtime overhead.
97705 +endchoice
97706 +
97707 +config PAX_KERNEXEC_PLUGIN_METHOD
97708 + string
97709 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
97710 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
97711 + default ""
97712 +
97713 +config PAX_KERNEXEC_MODULE_TEXT
97714 + int "Minimum amount of memory reserved for module code"
97715 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
97716 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97717 + depends on PAX_KERNEXEC && X86_32
97718 + help
97719 + Due to implementation details the kernel must reserve a fixed
97720 + amount of memory for runtime allocated code (such as modules)
97721 + at compile time that cannot be changed at runtime. Here you
97722 + can specify the minimum amount in MB that will be reserved.
97723 + Due to the same implementation details this size will always
97724 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
97725 + the actually available memory for runtime allocated code will
97726 + usually be more than this minimum.
97727 +
97728 + The default 4 MB should be enough for most users but if you have
97729 + an excessive number of modules (e.g., most distribution configs
97730 + compile many drivers as modules) or use huge modules such as
97731 + nvidia's kernel driver, you will need to adjust this amount.
97732 + A good rule of thumb is to look at your currently loaded kernel
97733 + modules and add up their sizes.
97734 +
97735 +endmenu
97736 +
97737 +menu "Address Space Layout Randomization"
97738 + depends on PAX
97739 +
97740 +config PAX_ASLR
97741 + bool "Address Space Layout Randomization"
97742 + default y if GRKERNSEC_CONFIG_AUTO
97743 + help
97744 + Many if not most exploit techniques rely on the knowledge of
97745 + certain addresses in the attacked program. The following options
97746 + will allow the kernel to apply a certain amount of randomization
97747 + to specific parts of the program thereby forcing an attacker to
97748 + guess them in most cases. Any failed guess will most likely crash
97749 + the attacked program which allows the kernel to detect such attempts
97750 + and react on them. PaX itself provides no reaction mechanisms,
97751 + instead it is strongly encouraged that you make use of Nergal's
97752 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
97753 + (http://www.grsecurity.net/) built-in crash detection features or
97754 + develop one yourself.
97755 +
97756 + By saying Y here you can choose to randomize the following areas:
97757 + - top of the task's kernel stack
97758 + - top of the task's userland stack
97759 + - base address for mmap() requests that do not specify one
97760 + (this includes all libraries)
97761 + - base address of the main executable
97762 +
97763 + It is strongly recommended to say Y here as address space layout
97764 + randomization has negligible impact on performance yet it provides
97765 + a very effective protection.
97766 +
97767 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97768 + this feature on a per file basis.
97769 +
97770 +config PAX_RANDKSTACK
97771 + bool "Randomize kernel stack base"
97772 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
97773 + depends on X86_TSC && X86
97774 + help
97775 + By saying Y here the kernel will randomize every task's kernel
97776 + stack on every system call. This will not only force an attacker
97777 + to guess it but also prevent him from making use of possible
97778 + leaked information about it.
97779 +
97780 + Since the kernel stack is a rather scarce resource, randomization
97781 + may cause unexpected stack overflows, therefore you should very
97782 + carefully test your system. Note that once enabled in the kernel
97783 + configuration, this feature cannot be disabled on a per file basis.
97784 +
97785 +config PAX_RANDUSTACK
97786 + bool "Randomize user stack base"
97787 + default y if GRKERNSEC_CONFIG_AUTO
97788 + depends on PAX_ASLR
97789 + help
97790 + By saying Y here the kernel will randomize every task's userland
97791 + stack. The randomization is done in two steps where the second
97792 + one may apply a big amount of shift to the top of the stack and
97793 + cause problems for programs that want to use lots of memory (more
97794 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
97795 + For this reason the second step can be controlled by 'chpax' or
97796 + 'paxctl' on a per file basis.
97797 +
97798 +config PAX_RANDMMAP
97799 + bool "Randomize mmap() base"
97800 + default y if GRKERNSEC_CONFIG_AUTO
97801 + depends on PAX_ASLR
97802 + help
97803 + By saying Y here the kernel will use a randomized base address for
97804 + mmap() requests that do not specify one themselves. As a result
97805 + all dynamically loaded libraries will appear at random addresses
97806 + and therefore be harder to exploit by a technique where an attacker
97807 + attempts to execute library code for his purposes (e.g. spawn a
97808 + shell from an exploited program that is running at an elevated
97809 + privilege level).
97810 +
97811 + Furthermore, if a program is relinked as a dynamic ELF file, its
97812 + base address will be randomized as well, completing the full
97813 + randomization of the address space layout. Attacking such programs
97814 + becomes a guess game. You can find an example of doing this at
97815 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
97816 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
97817 +
97818 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
97819 + feature on a per file basis.
97820 +
97821 +endmenu
97822 +
97823 +menu "Miscellaneous hardening features"
97824 +
97825 +config PAX_MEMORY_SANITIZE
97826 + bool "Sanitize all freed memory"
97827 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97828 + depends on !HIBERNATION
97829 + help
97830 + By saying Y here the kernel will erase memory pages and slab objects
97831 + as soon as they are freed. This in turn reduces the lifetime of data
97832 + stored in them, making it less likely that sensitive information such
97833 + as passwords, cryptographic secrets, etc stay in memory for too long.
97834 +
97835 + This is especially useful for programs whose runtime is short, long
97836 + lived processes and the kernel itself benefit from this as long as
97837 + they ensure timely freeing of memory that may hold sensitive
97838 + information.
97839 +
97840 + A nice side effect of the sanitization of slab objects is the
97841 + reduction of possible info leaks caused by padding bytes within the
97842 + leaky structures. Use-after-free bugs for structures containing
97843 + pointers can also be detected as dereferencing the sanitized pointer
97844 + will generate an access violation.
97845 +
97846 + The tradeoff is performance impact, on a single CPU system kernel
97847 + compilation sees a 3% slowdown, other systems and workloads may vary
97848 + and you are advised to test this feature on your expected workload
97849 + before deploying it.
97850 +
97851 + To reduce the performance penalty by sanitizing pages only, albeit
97852 + limiting the effectiveness of this feature at the same time, slab
97853 + sanitization can be disabled with the kernel commandline parameter
97854 + "pax_sanitize_slab=0".
97855 +
97856 + Note that this feature does not protect data stored in live pages,
97857 + e.g., process memory swapped to disk may stay there for a long time.
97858 +
97859 +config PAX_MEMORY_STACKLEAK
97860 + bool "Sanitize kernel stack"
97861 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97862 + depends on X86
97863 + help
97864 + By saying Y here the kernel will erase the kernel stack before it
97865 + returns from a system call. This in turn reduces the information
97866 + that a kernel stack leak bug can reveal.
97867 +
97868 + Note that such a bug can still leak information that was put on
97869 + the stack by the current system call (the one eventually triggering
97870 + the bug) but traces of earlier system calls on the kernel stack
97871 + cannot leak anymore.
97872 +
97873 + The tradeoff is performance impact: on a single CPU system kernel
97874 + compilation sees a 1% slowdown, other systems and workloads may vary
97875 + and you are advised to test this feature on your expected workload
97876 + before deploying it.
97877 +
97878 + Note that the full feature requires a gcc with plugin support,
97879 + i.e., gcc 4.5 or newer. You may need to install the supporting
97880 + headers explicitly in addition to the normal gcc package. Using
97881 + older gcc versions means that functions with large enough stack
97882 + frames may leave uninitialized memory behind that may be exposed
97883 + to a later syscall leaking the stack.
97884 +
97885 +config PAX_MEMORY_STRUCTLEAK
97886 + bool "Forcibly initialize local variables copied to userland"
97887 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97888 + help
97889 + By saying Y here the kernel will zero initialize some local
97890 + variables that are going to be copied to userland. This in
97891 + turn prevents unintended information leakage from the kernel
97892 + stack should later code forget to explicitly set all parts of
97893 + the copied variable.
97894 +
97895 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
97896 + at a much smaller coverage.
97897 +
97898 + Note that the implementation requires a gcc with plugin support,
97899 + i.e., gcc 4.5 or newer. You may need to install the supporting
97900 + headers explicitly in addition to the normal gcc package.
97901 +
97902 +config PAX_MEMORY_UDEREF
97903 + bool "Prevent invalid userland pointer dereference"
97904 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
97905 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
97906 + select PAX_PER_CPU_PGD if X86_64
97907 + help
97908 + By saying Y here the kernel will be prevented from dereferencing
97909 + userland pointers in contexts where the kernel expects only kernel
97910 + pointers. This is both a useful runtime debugging feature and a
97911 + security measure that prevents exploiting a class of kernel bugs.
97912 +
97913 + The tradeoff is that some virtualization solutions may experience
97914 + a huge slowdown and therefore you should not enable this feature
97915 + for kernels meant to run in such environments. Whether a given VM
97916 + solution is affected or not is best determined by simply trying it
97917 + out, the performance impact will be obvious right on boot as this
97918 + mechanism engages from very early on. A good rule of thumb is that
97919 + VMs running on CPUs without hardware virtualization support (i.e.,
97920 + the majority of IA-32 CPUs) will likely experience the slowdown.
97921 +
97922 + On X86_64 the kernel will make use of PCID support when available
97923 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
97924 + or performance impact. Pass pax_weakuderef on the kernel command
97925 + line to choose the latter.
97926 +
97927 +config PAX_REFCOUNT
97928 + bool "Prevent various kernel object reference counter overflows"
97929 + default y if GRKERNSEC_CONFIG_AUTO
97930 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
97931 + help
97932 + By saying Y here the kernel will detect and prevent overflowing
97933 + various (but not all) kinds of object reference counters. Such
97934 + overflows can normally occur due to bugs only and are often, if
97935 + not always, exploitable.
97936 +
97937 + The tradeoff is that data structures protected by an overflowed
97938 + refcount will never be freed and therefore will leak memory. Note
97939 + that this leak also happens even without this protection but in
97940 + that case the overflow can eventually trigger the freeing of the
97941 + data structure while it is still being used elsewhere, resulting
97942 + in the exploitable situation that this feature prevents.
97943 +
97944 + Since this has a negligible performance impact, you should enable
97945 + this feature.
97946 +
97947 +config PAX_CONSTIFY_PLUGIN
97948 + bool "Automatically constify eligible structures"
97949 + default y
97950 + depends on !UML && PAX_KERNEXEC
97951 + help
97952 + By saying Y here the compiler will automatically constify a class
97953 + of types that contain only function pointers. This reduces the
97954 + kernel's attack surface and also produces a better memory layout.
97955 +
97956 + Note that the implementation requires a gcc with plugin support,
97957 + i.e., gcc 4.5 or newer. You may need to install the supporting
97958 + headers explicitly in addition to the normal gcc package.
97959 +
97960 + Note that if some code really has to modify constified variables
97961 + then the source code will have to be patched to allow it. Examples
97962 + can be found in PaX itself (the no_const attribute) and for some
97963 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
97964 +
97965 +config PAX_USERCOPY
97966 + bool "Harden heap object copies between kernel and userland"
97967 + default y if GRKERNSEC_CONFIG_AUTO
97968 + depends on ARM || IA64 || PPC || SPARC || X86
97969 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
97970 + select PAX_USERCOPY_SLABS
97971 + help
97972 + By saying Y here the kernel will enforce the size of heap objects
97973 + when they are copied in either direction between the kernel and
97974 + userland, even if only a part of the heap object is copied.
97975 +
97976 + Specifically, this checking prevents information leaking from the
97977 + kernel heap during kernel to userland copies (if the kernel heap
97978 + object is otherwise fully initialized) and prevents kernel heap
97979 + overflows during userland to kernel copies.
97980 +
97981 + Note that the current implementation provides the strictest bounds
97982 + checks for the SLUB allocator.
97983 +
97984 + Enabling this option also enables per-slab cache protection against
97985 + data in a given cache being copied into/out of via userland
97986 + accessors. Though the whitelist of regions will be reduced over
97987 + time, it notably protects important data structures like task structs.
97988 +
97989 + If frame pointers are enabled on x86, this option will also restrict
97990 + copies into and out of the kernel stack to local variables within a
97991 + single frame.
97992 +
97993 + Since this has a negligible performance impact, you should enable
97994 + this feature.
97995 +
97996 +config PAX_USERCOPY_DEBUG
97997 + bool
97998 + depends on X86 && PAX_USERCOPY
97999 + default n
98000 +
98001 +config PAX_SIZE_OVERFLOW
98002 + bool "Prevent various integer overflows in function size parameters"
98003 + default y if GRKERNSEC_CONFIG_AUTO
98004 + depends on X86
98005 + help
98006 + By saying Y here the kernel recomputes expressions of function
98007 + arguments marked by a size_overflow attribute with double integer
98008 + precision (DImode/TImode for 32/64 bit integer types).
98009 +
98010 + The recomputed argument is checked against TYPE_MAX and an event
98011 + is logged on overflow and the triggering process is killed.
98012 +
98013 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98014 +
98015 + Note that the implementation requires a gcc with plugin support,
98016 + i.e., gcc 4.5 or newer. You may need to install the supporting
98017 + headers explicitly in addition to the normal gcc package.
98018 +
98019 +config PAX_LATENT_ENTROPY
98020 + bool "Generate some entropy during boot"
98021 + default y if GRKERNSEC_CONFIG_AUTO
98022 + help
98023 + By saying Y here the kernel will instrument early boot code to
98024 + extract some entropy from both original and artificially created
98025 + program state. This will help especially embedded systems where
98026 + there is little 'natural' source of entropy normally. The cost
98027 + is some slowdown of the boot process.
98028 +
98029 + When pax_extra_latent_entropy is passed on the kernel command line,
98030 + entropy will be extracted from up to the first 4GB of RAM while the
98031 + runtime memory allocator is being initialized. This costs even more
98032 + slowdown of the boot process.
98033 +
98034 + Note that the implementation requires a gcc with plugin support,
98035 + i.e., gcc 4.5 or newer. You may need to install the supporting
98036 + headers explicitly in addition to the normal gcc package.
98037 +
98038 + Note that entropy extracted this way is not cryptographically
98039 + secure!
98040 +
98041 +endmenu
98042 +
98043 +endmenu
98044 +
98045 +source grsecurity/Kconfig
98046 +
98047 +endmenu
98048 +
98049 +endmenu
98050 +
98051 source security/keys/Kconfig
98052
98053 config SECURITY_DMESG_RESTRICT
98054 @@ -103,7 +1056,7 @@ config INTEL_TXT
98055 config LSM_MMAP_MIN_ADDR
98056 int "Low address space for LSM to protect from user allocation"
98057 depends on SECURITY && SECURITY_SELINUX
98058 - default 32768 if ARM
98059 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98060 default 65536
98061 help
98062 This is the portion of low virtual memory which should be protected
98063 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98064 index 9b9013b..51ebf96 100644
98065 --- a/security/apparmor/Kconfig
98066 +++ b/security/apparmor/Kconfig
98067 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98068 boot.
98069
98070 If you are unsure how to answer this question, answer 1.
98071 +
98072 +config SECURITY_APPARMOR_COMPAT_24
98073 + bool "Enable AppArmor 2.4 compatability"
98074 + depends on SECURITY_APPARMOR
98075 + default y
98076 + help
98077 + This option enables compatability with AppArmor 2.4. It is
98078 + recommended if compatability with older versions of AppArmor
98079 + is desired.
98080 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98081 index 16c15ec..42b7c9f 100644
98082 --- a/security/apparmor/apparmorfs.c
98083 +++ b/security/apparmor/apparmorfs.c
98084 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98085 .release = single_release,
98086 };
98087
98088 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98089 +/**
98090 + * __next_namespace - find the next namespace to list
98091 + * @root: root namespace to stop search at (NOT NULL)
98092 + * @ns: current ns position (NOT NULL)
98093 + *
98094 + * Find the next namespace from @ns under @root and handle all locking needed
98095 + * while switching current namespace.
98096 + *
98097 + * Returns: next namespace or NULL if at last namespace under @root
98098 + * NOTE: will not unlock root->lock
98099 + */
98100 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98101 + struct aa_namespace *ns)
98102 +{
98103 + struct aa_namespace *parent;
98104 +
98105 + /* is next namespace a child */
98106 + if (!list_empty(&ns->sub_ns)) {
98107 + struct aa_namespace *next;
98108 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98109 + read_lock(&next->lock);
98110 + return next;
98111 + }
98112 +
98113 + /* check if the next ns is a sibling, parent, gp, .. */
98114 + parent = ns->parent;
98115 + while (parent) {
98116 + read_unlock(&ns->lock);
98117 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98118 + read_lock(&ns->lock);
98119 + return ns;
98120 + }
98121 + if (parent == root)
98122 + return NULL;
98123 + ns = parent;
98124 + parent = parent->parent;
98125 + }
98126 +
98127 + return NULL;
98128 +}
98129 +
98130 +/**
98131 + * __first_profile - find the first profile in a namespace
98132 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98133 + * @ns: namespace to start in (NOT NULL)
98134 + *
98135 + * Returns: unrefcounted profile or NULL if no profile
98136 + */
98137 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98138 + struct aa_namespace *ns)
98139 +{
98140 + for ( ; ns; ns = __next_namespace(root, ns)) {
98141 + if (!list_empty(&ns->base.profiles))
98142 + return list_first_entry(&ns->base.profiles,
98143 + struct aa_profile, base.list);
98144 + }
98145 + return NULL;
98146 +}
98147 +
98148 +/**
98149 + * __next_profile - step to the next profile in a profile tree
98150 + * @profile: current profile in tree (NOT NULL)
98151 + *
98152 + * Perform a depth first taversal on the profile tree in a namespace
98153 + *
98154 + * Returns: next profile or NULL if done
98155 + * Requires: profile->ns.lock to be held
98156 + */
98157 +static struct aa_profile *__next_profile(struct aa_profile *p)
98158 +{
98159 + struct aa_profile *parent;
98160 + struct aa_namespace *ns = p->ns;
98161 +
98162 + /* is next profile a child */
98163 + if (!list_empty(&p->base.profiles))
98164 + return list_first_entry(&p->base.profiles, typeof(*p),
98165 + base.list);
98166 +
98167 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98168 + parent = p->parent;
98169 + while (parent) {
98170 + list_for_each_entry_continue(p, &parent->base.profiles,
98171 + base.list)
98172 + return p;
98173 + p = parent;
98174 + parent = parent->parent;
98175 + }
98176 +
98177 + /* is next another profile in the namespace */
98178 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98179 + return p;
98180 +
98181 + return NULL;
98182 +}
98183 +
98184 +/**
98185 + * next_profile - step to the next profile in where ever it may be
98186 + * @root: root namespace (NOT NULL)
98187 + * @profile: current profile (NOT NULL)
98188 + *
98189 + * Returns: next profile or NULL if there isn't one
98190 + */
98191 +static struct aa_profile *next_profile(struct aa_namespace *root,
98192 + struct aa_profile *profile)
98193 +{
98194 + struct aa_profile *next = __next_profile(profile);
98195 + if (next)
98196 + return next;
98197 +
98198 + /* finished all profiles in namespace move to next namespace */
98199 + return __first_profile(root, __next_namespace(root, profile->ns));
98200 +}
98201 +
98202 +/**
98203 + * p_start - start a depth first traversal of profile tree
98204 + * @f: seq_file to fill
98205 + * @pos: current position
98206 + *
98207 + * Returns: first profile under current namespace or NULL if none found
98208 + *
98209 + * acquires first ns->lock
98210 + */
98211 +static void *p_start(struct seq_file *f, loff_t *pos)
98212 + __acquires(root->lock)
98213 +{
98214 + struct aa_profile *profile = NULL;
98215 + struct aa_namespace *root = aa_current_profile()->ns;
98216 + loff_t l = *pos;
98217 + f->private = aa_get_namespace(root);
98218 +
98219 +
98220 + /* find the first profile */
98221 + read_lock(&root->lock);
98222 + profile = __first_profile(root, root);
98223 +
98224 + /* skip to position */
98225 + for (; profile && l > 0; l--)
98226 + profile = next_profile(root, profile);
98227 +
98228 + return profile;
98229 +}
98230 +
98231 +/**
98232 + * p_next - read the next profile entry
98233 + * @f: seq_file to fill
98234 + * @p: profile previously returned
98235 + * @pos: current position
98236 + *
98237 + * Returns: next profile after @p or NULL if none
98238 + *
98239 + * may acquire/release locks in namespace tree as necessary
98240 + */
98241 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98242 +{
98243 + struct aa_profile *profile = p;
98244 + struct aa_namespace *root = f->private;
98245 + (*pos)++;
98246 +
98247 + return next_profile(root, profile);
98248 +}
98249 +
98250 +/**
98251 + * p_stop - stop depth first traversal
98252 + * @f: seq_file we are filling
98253 + * @p: the last profile writen
98254 + *
98255 + * Release all locking done by p_start/p_next on namespace tree
98256 + */
98257 +static void p_stop(struct seq_file *f, void *p)
98258 + __releases(root->lock)
98259 +{
98260 + struct aa_profile *profile = p;
98261 + struct aa_namespace *root = f->private, *ns;
98262 +
98263 + if (profile) {
98264 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98265 + read_unlock(&ns->lock);
98266 + }
98267 + read_unlock(&root->lock);
98268 + aa_put_namespace(root);
98269 +}
98270 +
98271 +/**
98272 + * seq_show_profile - show a profile entry
98273 + * @f: seq_file to file
98274 + * @p: current position (profile) (NOT NULL)
98275 + *
98276 + * Returns: error on failure
98277 + */
98278 +static int seq_show_profile(struct seq_file *f, void *p)
98279 +{
98280 + struct aa_profile *profile = (struct aa_profile *)p;
98281 + struct aa_namespace *root = f->private;
98282 +
98283 + if (profile->ns != root)
98284 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98285 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98286 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98287 +
98288 + return 0;
98289 +}
98290 +
98291 +static const struct seq_operations aa_fs_profiles_op = {
98292 + .start = p_start,
98293 + .next = p_next,
98294 + .stop = p_stop,
98295 + .show = seq_show_profile,
98296 +};
98297 +
98298 +static int profiles_open(struct inode *inode, struct file *file)
98299 +{
98300 + return seq_open(file, &aa_fs_profiles_op);
98301 +}
98302 +
98303 +static int profiles_release(struct inode *inode, struct file *file)
98304 +{
98305 + return seq_release(inode, file);
98306 +}
98307 +
98308 +const struct file_operations aa_fs_profiles_fops = {
98309 + .open = profiles_open,
98310 + .read = seq_read,
98311 + .llseek = seq_lseek,
98312 + .release = profiles_release,
98313 +};
98314 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98315 +
98316 /** Base file system setup **/
98317
98318 static struct aa_fs_entry aa_fs_entry_file[] = {
98319 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98320 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98321 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98322 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98323 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98324 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98325 +#endif
98326 AA_FS_DIR("features", aa_fs_entry_features),
98327 { }
98328 };
98329 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98330 index 2e2a0dd..a0cbc44 100644
98331 --- a/security/apparmor/lsm.c
98332 +++ b/security/apparmor/lsm.c
98333 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98334 return error;
98335 }
98336
98337 -static struct security_operations apparmor_ops = {
98338 +static struct security_operations apparmor_ops __read_only = {
98339 .name = "apparmor",
98340
98341 .ptrace_access_check = apparmor_ptrace_access_check,
98342 diff --git a/security/commoncap.c b/security/commoncap.c
98343 index c44b6fe..932df30 100644
98344 --- a/security/commoncap.c
98345 +++ b/security/commoncap.c
98346 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98347 return 0;
98348 }
98349
98350 +/* returns:
98351 + 1 for suid privilege
98352 + 2 for sgid privilege
98353 + 3 for fscap privilege
98354 +*/
98355 +int is_privileged_binary(const struct dentry *dentry)
98356 +{
98357 + struct cpu_vfs_cap_data capdata;
98358 + struct inode *inode = dentry->d_inode;
98359 +
98360 + if (!inode || S_ISDIR(inode->i_mode))
98361 + return 0;
98362 +
98363 + if (inode->i_mode & S_ISUID)
98364 + return 1;
98365 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98366 + return 2;
98367 +
98368 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98369 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98370 + return 3;
98371 + }
98372 +
98373 + return 0;
98374 +}
98375 +
98376 /*
98377 * Attempt to get the on-exec apply capability sets for an executable file from
98378 * its xattrs and, if present, apply them to the proposed credentials being
98379 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98380 const struct cred *cred = current_cred();
98381 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98382
98383 + if (gr_acl_enable_at_secure())
98384 + return 1;
98385 +
98386 if (!uid_eq(cred->uid, root_uid)) {
98387 if (bprm->cap_effective)
98388 return 1;
98389 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98390 index b3dd616..4bb17f3 100644
98391 --- a/security/integrity/ima/ima.h
98392 +++ b/security/integrity/ima/ima.h
98393 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98394 extern spinlock_t ima_queue_lock;
98395
98396 struct ima_h_table {
98397 - atomic_long_t len; /* number of stored measurements in the list */
98398 - atomic_long_t violations;
98399 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98400 + atomic_long_unchecked_t violations;
98401 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98402 };
98403 extern struct ima_h_table ima_htable;
98404 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98405 index 1c03e8f1..398a941 100644
98406 --- a/security/integrity/ima/ima_api.c
98407 +++ b/security/integrity/ima/ima_api.c
98408 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98409 int result;
98410
98411 /* can overflow, only indicator */
98412 - atomic_long_inc(&ima_htable.violations);
98413 + atomic_long_inc_unchecked(&ima_htable.violations);
98414
98415 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98416 if (!entry) {
98417 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98418 index 38477c9..87a60c7 100644
98419 --- a/security/integrity/ima/ima_fs.c
98420 +++ b/security/integrity/ima/ima_fs.c
98421 @@ -28,12 +28,12 @@
98422 static int valid_policy = 1;
98423 #define TMPBUFLEN 12
98424 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98425 - loff_t *ppos, atomic_long_t *val)
98426 + loff_t *ppos, atomic_long_unchecked_t *val)
98427 {
98428 char tmpbuf[TMPBUFLEN];
98429 ssize_t len;
98430
98431 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98432 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98433 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98434 }
98435
98436 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98437 index ff63fe0..809cd96 100644
98438 --- a/security/integrity/ima/ima_queue.c
98439 +++ b/security/integrity/ima/ima_queue.c
98440 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98441 INIT_LIST_HEAD(&qe->later);
98442 list_add_tail_rcu(&qe->later, &ima_measurements);
98443
98444 - atomic_long_inc(&ima_htable.len);
98445 + atomic_long_inc_unchecked(&ima_htable.len);
98446 key = ima_hash_key(entry->digest);
98447 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98448 return 0;
98449 diff --git a/security/keys/compat.c b/security/keys/compat.c
98450 index d65fa7f..cbfe366 100644
98451 --- a/security/keys/compat.c
98452 +++ b/security/keys/compat.c
98453 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98454 if (ret == 0)
98455 goto no_payload_free;
98456
98457 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98458 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98459 err:
98460 if (iov != iovstack)
98461 kfree(iov);
98462 diff --git a/security/keys/internal.h b/security/keys/internal.h
98463 index d4f1468..cc52f92 100644
98464 --- a/security/keys/internal.h
98465 +++ b/security/keys/internal.h
98466 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98467 extern long keyctl_invalidate_key(key_serial_t);
98468
98469 extern long keyctl_instantiate_key_common(key_serial_t,
98470 - const struct iovec *,
98471 + const struct iovec __user *,
98472 unsigned, size_t, key_serial_t);
98473
98474 /*
98475 diff --git a/security/keys/key.c b/security/keys/key.c
98476 index 8fb7c7b..ba3610d 100644
98477 --- a/security/keys/key.c
98478 +++ b/security/keys/key.c
98479 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98480
98481 atomic_set(&key->usage, 1);
98482 init_rwsem(&key->sem);
98483 - lockdep_set_class(&key->sem, &type->lock_class);
98484 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98485 key->type = type;
98486 key->user = user;
98487 key->quotalen = quotalen;
98488 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98489 struct key_type *p;
98490 int ret;
98491
98492 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98493 + pax_open_kernel();
98494 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98495 + pax_close_kernel();
98496
98497 ret = -EEXIST;
98498 down_write(&key_types_sem);
98499 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98500 }
98501
98502 /* store the type */
98503 - list_add(&ktype->link, &key_types_list);
98504 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98505
98506 pr_notice("Key type %s registered\n", ktype->name);
98507 ret = 0;
98508 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98509 void unregister_key_type(struct key_type *ktype)
98510 {
98511 down_write(&key_types_sem);
98512 - list_del_init(&ktype->link);
98513 + pax_list_del_init((struct list_head *)&ktype->link);
98514 downgrade_write(&key_types_sem);
98515 key_gc_keytype(ktype);
98516 pr_notice("Key type %s unregistered\n", ktype->name);
98517 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98518 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98519
98520 /* add the special key types */
98521 - list_add_tail(&key_type_keyring.link, &key_types_list);
98522 - list_add_tail(&key_type_dead.link, &key_types_list);
98523 - list_add_tail(&key_type_user.link, &key_types_list);
98524 - list_add_tail(&key_type_logon.link, &key_types_list);
98525 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98526 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98527 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98528 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98529
98530 /* record the root user tracking */
98531 rb_link_node(&root_key_user.node,
98532 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98533 index 33cfd27..842fc5a 100644
98534 --- a/security/keys/keyctl.c
98535 +++ b/security/keys/keyctl.c
98536 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98537 /*
98538 * Copy the iovec data from userspace
98539 */
98540 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98541 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98542 unsigned ioc)
98543 {
98544 for (; ioc > 0; ioc--) {
98545 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98546 * If successful, 0 will be returned.
98547 */
98548 long keyctl_instantiate_key_common(key_serial_t id,
98549 - const struct iovec *payload_iov,
98550 + const struct iovec __user *payload_iov,
98551 unsigned ioc,
98552 size_t plen,
98553 key_serial_t ringid)
98554 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98555 [0].iov_len = plen
98556 };
98557
98558 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98559 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98560 }
98561
98562 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98563 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
98564 if (ret == 0)
98565 goto no_payload_free;
98566
98567 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98568 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98569 err:
98570 if (iov != iovstack)
98571 kfree(iov);
98572 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
98573 index 6ece7f2..ecdb55c 100644
98574 --- a/security/keys/keyring.c
98575 +++ b/security/keys/keyring.c
98576 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
98577 ret = -EFAULT;
98578
98579 for (loop = 0; loop < klist->nkeys; loop++) {
98580 + key_serial_t serial;
98581 key = rcu_deref_link_locked(klist, loop,
98582 keyring);
98583 + serial = key->serial;
98584
98585 tmp = sizeof(key_serial_t);
98586 if (tmp > buflen)
98587 tmp = buflen;
98588
98589 - if (copy_to_user(buffer,
98590 - &key->serial,
98591 - tmp) != 0)
98592 + if (copy_to_user(buffer, &serial, tmp))
98593 goto error;
98594
98595 buflen -= tmp;
98596 diff --git a/security/min_addr.c b/security/min_addr.c
98597 index f728728..6457a0c 100644
98598 --- a/security/min_addr.c
98599 +++ b/security/min_addr.c
98600 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
98601 */
98602 static void update_mmap_min_addr(void)
98603 {
98604 +#ifndef SPARC
98605 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
98606 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
98607 mmap_min_addr = dac_mmap_min_addr;
98608 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
98609 #else
98610 mmap_min_addr = dac_mmap_min_addr;
98611 #endif
98612 +#endif
98613 }
98614
98615 /*
98616 diff --git a/security/security.c b/security/security.c
98617 index 94b35ae..f4e7751 100644
98618 --- a/security/security.c
98619 +++ b/security/security.c
98620 @@ -33,8 +33,8 @@
98621 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
98622 CONFIG_DEFAULT_SECURITY;
98623
98624 -static struct security_operations *security_ops;
98625 -static struct security_operations default_security_ops = {
98626 +struct security_operations *security_ops __read_only;
98627 +struct security_operations default_security_ops __read_only = {
98628 .name = "default",
98629 };
98630
98631 @@ -73,11 +73,6 @@ int __init security_init(void)
98632 return 0;
98633 }
98634
98635 -void reset_security_ops(void)
98636 -{
98637 - security_ops = &default_security_ops;
98638 -}
98639 -
98640 /* Save user chosen LSM */
98641 static int __init choose_lsm(char *str)
98642 {
98643 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
98644 index dad36a6..7e5ffbf 100644
98645 --- a/security/selinux/avc.c
98646 +++ b/security/selinux/avc.c
98647 @@ -59,7 +59,7 @@ struct avc_node {
98648 struct avc_cache {
98649 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
98650 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
98651 - atomic_t lru_hint; /* LRU hint for reclaim scan */
98652 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
98653 atomic_t active_nodes;
98654 u32 latest_notif; /* latest revocation notification */
98655 };
98656 @@ -167,7 +167,7 @@ void __init avc_init(void)
98657 spin_lock_init(&avc_cache.slots_lock[i]);
98658 }
98659 atomic_set(&avc_cache.active_nodes, 0);
98660 - atomic_set(&avc_cache.lru_hint, 0);
98661 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
98662
98663 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
98664 0, SLAB_PANIC, NULL);
98665 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
98666 spinlock_t *lock;
98667
98668 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
98669 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98670 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98671 head = &avc_cache.slots[hvalue];
98672 lock = &avc_cache.slots_lock[hvalue];
98673
98674 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
98675 index c956390..1899f06 100644
98676 --- a/security/selinux/hooks.c
98677 +++ b/security/selinux/hooks.c
98678 @@ -97,8 +97,6 @@
98679
98680 #define NUM_SEL_MNT_OPTS 5
98681
98682 -extern struct security_operations *security_ops;
98683 -
98684 /* SECMARK reference count */
98685 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
98686
98687 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
98688
98689 #endif
98690
98691 -static struct security_operations selinux_ops = {
98692 +static struct security_operations selinux_ops __read_only = {
98693 .name = "selinux",
98694
98695 .ptrace_access_check = selinux_ptrace_access_check,
98696 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
98697 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
98698 static int selinux_disabled;
98699
98700 +extern struct security_operations *security_ops;
98701 +extern struct security_operations default_security_ops;
98702 +
98703 int selinux_disable(void)
98704 {
98705 if (ss_initialized) {
98706 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
98707 selinux_disabled = 1;
98708 selinux_enabled = 0;
98709
98710 - reset_security_ops();
98711 + pax_open_kernel();
98712 + security_ops = &default_security_ops;
98713 + pax_close_kernel();
98714
98715 /* Try to destroy the avc node cache */
98716 avc_disable();
98717 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
98718 index 65f67cb..3f141ef 100644
98719 --- a/security/selinux/include/xfrm.h
98720 +++ b/security/selinux/include/xfrm.h
98721 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
98722
98723 static inline void selinux_xfrm_notify_policyload(void)
98724 {
98725 - atomic_inc(&flow_cache_genid);
98726 + atomic_inc_unchecked(&flow_cache_genid);
98727 rt_genid_bump(&init_net);
98728 }
98729 #else
98730 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
98731 index eefbd10..9f10ddb 100644
98732 --- a/security/smack/smack_lsm.c
98733 +++ b/security/smack/smack_lsm.c
98734 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
98735 return 0;
98736 }
98737
98738 -struct security_operations smack_ops = {
98739 +struct security_operations smack_ops __read_only = {
98740 .name = "smack",
98741
98742 .ptrace_access_check = smack_ptrace_access_check,
98743 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
98744 index 390c646..f2f8db3 100644
98745 --- a/security/tomoyo/mount.c
98746 +++ b/security/tomoyo/mount.c
98747 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
98748 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
98749 need_dev = -1; /* dev_name is a directory */
98750 } else {
98751 + if (!capable(CAP_SYS_ADMIN)) {
98752 + error = -EPERM;
98753 + goto out;
98754 + }
98755 fstype = get_fs_type(type);
98756 if (!fstype) {
98757 error = -ENODEV;
98758 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
98759 index f0b756e..b129202 100644
98760 --- a/security/tomoyo/tomoyo.c
98761 +++ b/security/tomoyo/tomoyo.c
98762 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
98763 * tomoyo_security_ops is a "struct security_operations" which is used for
98764 * registering TOMOYO.
98765 */
98766 -static struct security_operations tomoyo_security_ops = {
98767 +static struct security_operations tomoyo_security_ops __read_only = {
98768 .name = "tomoyo",
98769 .cred_alloc_blank = tomoyo_cred_alloc_blank,
98770 .cred_prepare = tomoyo_cred_prepare,
98771 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
98772 index 20ef514..4182bed 100644
98773 --- a/security/yama/Kconfig
98774 +++ b/security/yama/Kconfig
98775 @@ -1,6 +1,6 @@
98776 config SECURITY_YAMA
98777 bool "Yama support"
98778 - depends on SECURITY
98779 + depends on SECURITY && !GRKERNSEC
98780 select SECURITYFS
98781 select SECURITY_PATH
98782 default n
98783 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
98784 index 13c88fbc..f8c115e 100644
98785 --- a/security/yama/yama_lsm.c
98786 +++ b/security/yama/yama_lsm.c
98787 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
98788 }
98789
98790 #ifndef CONFIG_SECURITY_YAMA_STACKED
98791 -static struct security_operations yama_ops = {
98792 +static struct security_operations yama_ops __read_only = {
98793 .name = "yama",
98794
98795 .ptrace_access_check = yama_ptrace_access_check,
98796 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
98797 #endif
98798
98799 #ifdef CONFIG_SYSCTL
98800 +static int zero __read_only;
98801 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
98802 +
98803 static int yama_dointvec_minmax(struct ctl_table *table, int write,
98804 void __user *buffer, size_t *lenp, loff_t *ppos)
98805 {
98806 - int rc;
98807 + ctl_table_no_const yama_table;
98808
98809 if (write && !capable(CAP_SYS_PTRACE))
98810 return -EPERM;
98811
98812 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
98813 - if (rc)
98814 - return rc;
98815 -
98816 + yama_table = *table;
98817 /* Lock the max value if it ever gets set. */
98818 - if (write && *(int *)table->data == *(int *)table->extra2)
98819 - table->extra1 = table->extra2;
98820 -
98821 - return rc;
98822 + if (ptrace_scope == max_scope)
98823 + yama_table.extra1 = &max_scope;
98824 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
98825 }
98826
98827 -static int zero;
98828 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
98829 -
98830 struct ctl_path yama_sysctl_path[] = {
98831 { .procname = "kernel", },
98832 { .procname = "yama", },
98833 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
98834 index 4cedc69..e59d8a3 100644
98835 --- a/sound/aoa/codecs/onyx.c
98836 +++ b/sound/aoa/codecs/onyx.c
98837 @@ -54,7 +54,7 @@ struct onyx {
98838 spdif_locked:1,
98839 analog_locked:1,
98840 original_mute:2;
98841 - int open_count;
98842 + local_t open_count;
98843 struct codec_info *codec_info;
98844
98845 /* mutex serializes concurrent access to the device
98846 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
98847 struct onyx *onyx = cii->codec_data;
98848
98849 mutex_lock(&onyx->mutex);
98850 - onyx->open_count++;
98851 + local_inc(&onyx->open_count);
98852 mutex_unlock(&onyx->mutex);
98853
98854 return 0;
98855 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
98856 struct onyx *onyx = cii->codec_data;
98857
98858 mutex_lock(&onyx->mutex);
98859 - onyx->open_count--;
98860 - if (!onyx->open_count)
98861 + if (local_dec_and_test(&onyx->open_count))
98862 onyx->spdif_locked = onyx->analog_locked = 0;
98863 mutex_unlock(&onyx->mutex);
98864
98865 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
98866 index ffd2025..df062c9 100644
98867 --- a/sound/aoa/codecs/onyx.h
98868 +++ b/sound/aoa/codecs/onyx.h
98869 @@ -11,6 +11,7 @@
98870 #include <linux/i2c.h>
98871 #include <asm/pmac_low_i2c.h>
98872 #include <asm/prom.h>
98873 +#include <asm/local.h>
98874
98875 /* PCM3052 register definitions */
98876
98877 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
98878 index 4c1cc51..16040040 100644
98879 --- a/sound/core/oss/pcm_oss.c
98880 +++ b/sound/core/oss/pcm_oss.c
98881 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
98882 if (in_kernel) {
98883 mm_segment_t fs;
98884 fs = snd_enter_user();
98885 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98886 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98887 snd_leave_user(fs);
98888 } else {
98889 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98890 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98891 }
98892 if (ret != -EPIPE && ret != -ESTRPIPE)
98893 break;
98894 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
98895 if (in_kernel) {
98896 mm_segment_t fs;
98897 fs = snd_enter_user();
98898 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98899 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98900 snd_leave_user(fs);
98901 } else {
98902 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98903 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98904 }
98905 if (ret == -EPIPE) {
98906 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
98907 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
98908 struct snd_pcm_plugin_channel *channels;
98909 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
98910 if (!in_kernel) {
98911 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
98912 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
98913 return -EFAULT;
98914 buf = runtime->oss.buffer;
98915 }
98916 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
98917 }
98918 } else {
98919 tmp = snd_pcm_oss_write2(substream,
98920 - (const char __force *)buf,
98921 + (const char __force_kernel *)buf,
98922 runtime->oss.period_bytes, 0);
98923 if (tmp <= 0)
98924 goto err;
98925 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
98926 struct snd_pcm_runtime *runtime = substream->runtime;
98927 snd_pcm_sframes_t frames, frames1;
98928 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
98929 - char __user *final_dst = (char __force __user *)buf;
98930 + char __user *final_dst = (char __force_user *)buf;
98931 if (runtime->oss.plugin_first) {
98932 struct snd_pcm_plugin_channel *channels;
98933 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
98934 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
98935 xfer += tmp;
98936 runtime->oss.buffer_used -= tmp;
98937 } else {
98938 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
98939 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
98940 runtime->oss.period_bytes, 0);
98941 if (tmp <= 0)
98942 goto err;
98943 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
98944 size1);
98945 size1 /= runtime->channels; /* frames */
98946 fs = snd_enter_user();
98947 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
98948 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
98949 snd_leave_user(fs);
98950 }
98951 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
98952 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
98953 index af49721..e85058e 100644
98954 --- a/sound/core/pcm_compat.c
98955 +++ b/sound/core/pcm_compat.c
98956 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
98957 int err;
98958
98959 fs = snd_enter_user();
98960 - err = snd_pcm_delay(substream, &delay);
98961 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
98962 snd_leave_user(fs);
98963 if (err < 0)
98964 return err;
98965 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
98966 index a68d4c6..72af3cf 100644
98967 --- a/sound/core/pcm_native.c
98968 +++ b/sound/core/pcm_native.c
98969 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
98970 switch (substream->stream) {
98971 case SNDRV_PCM_STREAM_PLAYBACK:
98972 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
98973 - (void __user *)arg);
98974 + (void __force_user *)arg);
98975 break;
98976 case SNDRV_PCM_STREAM_CAPTURE:
98977 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
98978 - (void __user *)arg);
98979 + (void __force_user *)arg);
98980 break;
98981 default:
98982 result = -EINVAL;
98983 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
98984 index 040c60e..989a19a 100644
98985 --- a/sound/core/seq/seq_device.c
98986 +++ b/sound/core/seq/seq_device.c
98987 @@ -64,7 +64,7 @@ struct ops_list {
98988 int argsize; /* argument size */
98989
98990 /* operators */
98991 - struct snd_seq_dev_ops ops;
98992 + struct snd_seq_dev_ops *ops;
98993
98994 /* registered devices */
98995 struct list_head dev_list; /* list of devices */
98996 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
98997
98998 mutex_lock(&ops->reg_mutex);
98999 /* copy driver operators */
99000 - ops->ops = *entry;
99001 + ops->ops = entry;
99002 ops->driver |= DRIVER_LOADED;
99003 ops->argsize = argsize;
99004
99005 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99006 dev->name, ops->id, ops->argsize, dev->argsize);
99007 return -EINVAL;
99008 }
99009 - if (ops->ops.init_device(dev) >= 0) {
99010 + if (ops->ops->init_device(dev) >= 0) {
99011 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99012 ops->num_init_devices++;
99013 } else {
99014 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99015 dev->name, ops->id, ops->argsize, dev->argsize);
99016 return -EINVAL;
99017 }
99018 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99019 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99020 dev->status = SNDRV_SEQ_DEVICE_FREE;
99021 dev->driver_data = NULL;
99022 ops->num_init_devices--;
99023 diff --git a/sound/core/sound.c b/sound/core/sound.c
99024 index f002bd9..c462985 100644
99025 --- a/sound/core/sound.c
99026 +++ b/sound/core/sound.c
99027 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99028 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99029 default: return;
99030 }
99031 - request_module(str);
99032 + request_module("%s", str);
99033 }
99034
99035 #endif /* modular kernel */
99036 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99037 index 4e0dd22..7a1f32c 100644
99038 --- a/sound/drivers/mts64.c
99039 +++ b/sound/drivers/mts64.c
99040 @@ -29,6 +29,7 @@
99041 #include <sound/initval.h>
99042 #include <sound/rawmidi.h>
99043 #include <sound/control.h>
99044 +#include <asm/local.h>
99045
99046 #define CARD_NAME "Miditerminal 4140"
99047 #define DRIVER_NAME "MTS64"
99048 @@ -67,7 +68,7 @@ struct mts64 {
99049 struct pardevice *pardev;
99050 int pardev_claimed;
99051
99052 - int open_count;
99053 + local_t open_count;
99054 int current_midi_output_port;
99055 int current_midi_input_port;
99056 u8 mode[MTS64_NUM_INPUT_PORTS];
99057 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99058 {
99059 struct mts64 *mts = substream->rmidi->private_data;
99060
99061 - if (mts->open_count == 0) {
99062 + if (local_read(&mts->open_count) == 0) {
99063 /* We don't need a spinlock here, because this is just called
99064 if the device has not been opened before.
99065 So there aren't any IRQs from the device */
99066 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99067
99068 msleep(50);
99069 }
99070 - ++(mts->open_count);
99071 + local_inc(&mts->open_count);
99072
99073 return 0;
99074 }
99075 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99076 struct mts64 *mts = substream->rmidi->private_data;
99077 unsigned long flags;
99078
99079 - --(mts->open_count);
99080 - if (mts->open_count == 0) {
99081 + if (local_dec_return(&mts->open_count) == 0) {
99082 /* We need the spinlock_irqsave here because we can still
99083 have IRQs at this point */
99084 spin_lock_irqsave(&mts->lock, flags);
99085 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99086
99087 msleep(500);
99088
99089 - } else if (mts->open_count < 0)
99090 - mts->open_count = 0;
99091 + } else if (local_read(&mts->open_count) < 0)
99092 + local_set(&mts->open_count, 0);
99093
99094 return 0;
99095 }
99096 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99097 index b953fb4..1999c01 100644
99098 --- a/sound/drivers/opl4/opl4_lib.c
99099 +++ b/sound/drivers/opl4/opl4_lib.c
99100 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99101 MODULE_DESCRIPTION("OPL4 driver");
99102 MODULE_LICENSE("GPL");
99103
99104 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99105 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99106 {
99107 int timeout = 10;
99108 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99109 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99110 index 991018d..8984740 100644
99111 --- a/sound/drivers/portman2x4.c
99112 +++ b/sound/drivers/portman2x4.c
99113 @@ -48,6 +48,7 @@
99114 #include <sound/initval.h>
99115 #include <sound/rawmidi.h>
99116 #include <sound/control.h>
99117 +#include <asm/local.h>
99118
99119 #define CARD_NAME "Portman 2x4"
99120 #define DRIVER_NAME "portman"
99121 @@ -85,7 +86,7 @@ struct portman {
99122 struct pardevice *pardev;
99123 int pardev_claimed;
99124
99125 - int open_count;
99126 + local_t open_count;
99127 int mode[PORTMAN_NUM_INPUT_PORTS];
99128 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99129 };
99130 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99131 index ea995af..f1bfa37 100644
99132 --- a/sound/firewire/amdtp.c
99133 +++ b/sound/firewire/amdtp.c
99134 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99135 ptr = s->pcm_buffer_pointer + data_blocks;
99136 if (ptr >= pcm->runtime->buffer_size)
99137 ptr -= pcm->runtime->buffer_size;
99138 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99139 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99140
99141 s->pcm_period_pointer += data_blocks;
99142 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99143 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99144 */
99145 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99146 {
99147 - ACCESS_ONCE(s->source_node_id_field) =
99148 + ACCESS_ONCE_RW(s->source_node_id_field) =
99149 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99150 }
99151 EXPORT_SYMBOL(amdtp_out_stream_update);
99152 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99153 index f6103d6..4843fbf 100644
99154 --- a/sound/firewire/amdtp.h
99155 +++ b/sound/firewire/amdtp.h
99156 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99157 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99158 struct snd_pcm_substream *pcm)
99159 {
99160 - ACCESS_ONCE(s->pcm) = pcm;
99161 + ACCESS_ONCE_RW(s->pcm) = pcm;
99162 }
99163
99164 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99165 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99166 index 58a5afe..af5bd64 100644
99167 --- a/sound/firewire/isight.c
99168 +++ b/sound/firewire/isight.c
99169 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99170 ptr += count;
99171 if (ptr >= runtime->buffer_size)
99172 ptr -= runtime->buffer_size;
99173 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99174 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99175
99176 isight->period_counter += count;
99177 if (isight->period_counter >= runtime->period_size) {
99178 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99179 if (err < 0)
99180 return err;
99181
99182 - ACCESS_ONCE(isight->pcm_active) = true;
99183 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99184
99185 return 0;
99186 }
99187 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99188 {
99189 struct isight *isight = substream->private_data;
99190
99191 - ACCESS_ONCE(isight->pcm_active) = false;
99192 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99193
99194 mutex_lock(&isight->mutex);
99195 isight_stop_streaming(isight);
99196 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99197
99198 switch (cmd) {
99199 case SNDRV_PCM_TRIGGER_START:
99200 - ACCESS_ONCE(isight->pcm_running) = true;
99201 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99202 break;
99203 case SNDRV_PCM_TRIGGER_STOP:
99204 - ACCESS_ONCE(isight->pcm_running) = false;
99205 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99206 break;
99207 default:
99208 return -EINVAL;
99209 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99210 index 505fc81..62e569e 100644
99211 --- a/sound/firewire/scs1x.c
99212 +++ b/sound/firewire/scs1x.c
99213 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99214 {
99215 struct scs *scs = stream->rmidi->private_data;
99216
99217 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99218 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99219 if (up) {
99220 scs->output_idle = false;
99221 tasklet_schedule(&scs->tasklet);
99222 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99223 {
99224 struct scs *scs = stream->rmidi->private_data;
99225
99226 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99227 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99228 }
99229
99230 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99231 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99232
99233 snd_card_disconnect(scs->card);
99234
99235 - ACCESS_ONCE(scs->output) = NULL;
99236 - ACCESS_ONCE(scs->input) = NULL;
99237 + ACCESS_ONCE_RW(scs->output) = NULL;
99238 + ACCESS_ONCE_RW(scs->input) = NULL;
99239
99240 wait_event(scs->idle_wait, scs->output_idle);
99241
99242 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99243 index 048439a..3be9f6f 100644
99244 --- a/sound/oss/sb_audio.c
99245 +++ b/sound/oss/sb_audio.c
99246 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99247 buf16 = (signed short *)(localbuf + localoffs);
99248 while (c)
99249 {
99250 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99251 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99252 if (copy_from_user(lbuf8,
99253 userbuf+useroffs + p,
99254 locallen))
99255 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99256 index 7d8803a..559f8d0 100644
99257 --- a/sound/oss/swarm_cs4297a.c
99258 +++ b/sound/oss/swarm_cs4297a.c
99259 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99260 {
99261 struct cs4297a_state *s;
99262 u32 pwr, id;
99263 - mm_segment_t fs;
99264 int rval;
99265 #ifndef CONFIG_BCM_CS4297A_CSWARM
99266 u64 cfg;
99267 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99268 if (!rval) {
99269 char *sb1250_duart_present;
99270
99271 +#if 0
99272 + mm_segment_t fs;
99273 fs = get_fs();
99274 set_fs(KERNEL_DS);
99275 -#if 0
99276 val = SOUND_MASK_LINE;
99277 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99278 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99279 val = initvol[i].vol;
99280 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99281 }
99282 + set_fs(fs);
99283 // cs4297a_write_ac97(s, 0x18, 0x0808);
99284 #else
99285 // cs4297a_write_ac97(s, 0x5e, 0x180);
99286 cs4297a_write_ac97(s, 0x02, 0x0808);
99287 cs4297a_write_ac97(s, 0x18, 0x0808);
99288 #endif
99289 - set_fs(fs);
99290
99291 list_add(&s->list, &cs4297a_devs);
99292
99293 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99294 index 8a005f0..4fe3059 100644
99295 --- a/sound/pci/hda/hda_codec.c
99296 +++ b/sound/pci/hda/hda_codec.c
99297 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99298 mutex_unlock(&preset_mutex);
99299
99300 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99301 - char name[32];
99302 if (!mod_requested)
99303 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99304 - codec->vendor_id);
99305 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99306 else
99307 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99308 - (codec->vendor_id >> 16) & 0xffff);
99309 - request_module(name);
99310 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99311 mod_requested++;
99312 goto again;
99313 }
99314 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99315 index 4631a23..001ae57 100644
99316 --- a/sound/pci/ymfpci/ymfpci.h
99317 +++ b/sound/pci/ymfpci/ymfpci.h
99318 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99319 spinlock_t reg_lock;
99320 spinlock_t voice_lock;
99321 wait_queue_head_t interrupt_sleep;
99322 - atomic_t interrupt_sleep_count;
99323 + atomic_unchecked_t interrupt_sleep_count;
99324 struct snd_info_entry *proc_entry;
99325 const struct firmware *dsp_microcode;
99326 const struct firmware *controller_microcode;
99327 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99328 index d591c15..8cb8f94 100644
99329 --- a/sound/pci/ymfpci/ymfpci_main.c
99330 +++ b/sound/pci/ymfpci/ymfpci_main.c
99331 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99332 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99333 break;
99334 }
99335 - if (atomic_read(&chip->interrupt_sleep_count)) {
99336 - atomic_set(&chip->interrupt_sleep_count, 0);
99337 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99338 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99339 wake_up(&chip->interrupt_sleep);
99340 }
99341 __end:
99342 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99343 continue;
99344 init_waitqueue_entry(&wait, current);
99345 add_wait_queue(&chip->interrupt_sleep, &wait);
99346 - atomic_inc(&chip->interrupt_sleep_count);
99347 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99348 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99349 remove_wait_queue(&chip->interrupt_sleep, &wait);
99350 }
99351 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99352 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99353 spin_unlock(&chip->reg_lock);
99354
99355 - if (atomic_read(&chip->interrupt_sleep_count)) {
99356 - atomic_set(&chip->interrupt_sleep_count, 0);
99357 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99358 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99359 wake_up(&chip->interrupt_sleep);
99360 }
99361 }
99362 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99363 spin_lock_init(&chip->reg_lock);
99364 spin_lock_init(&chip->voice_lock);
99365 init_waitqueue_head(&chip->interrupt_sleep);
99366 - atomic_set(&chip->interrupt_sleep_count, 0);
99367 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99368 chip->card = card;
99369 chip->pci = pci;
99370 chip->irq = -1;
99371 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99372 index 2f2d837..3e3f1f6 100644
99373 --- a/sound/soc/fsl/fsl_ssi.c
99374 +++ b/sound/soc/fsl/fsl_ssi.c
99375 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99376 {
99377 struct fsl_ssi_private *ssi_private;
99378 int ret = 0;
99379 - struct device_attribute *dev_attr = NULL;
99380 + device_attribute_no_const *dev_attr = NULL;
99381 struct device_node *np = pdev->dev.of_node;
99382 const char *p, *sprop;
99383 const uint32_t *iprop;
99384 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99385 new file mode 100644
99386 index 0000000..50f2f2f
99387 --- /dev/null
99388 +++ b/tools/gcc/.gitignore
99389 @@ -0,0 +1 @@
99390 +size_overflow_hash.h
99391 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99392 new file mode 100644
99393 index 0000000..144dbee
99394 --- /dev/null
99395 +++ b/tools/gcc/Makefile
99396 @@ -0,0 +1,45 @@
99397 +#CC := gcc
99398 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99399 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99400 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99401 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99402 +
99403 +ifeq ($(PLUGINCC),$(HOSTCC))
99404 +HOSTLIBS := hostlibs
99405 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99406 +else
99407 +HOSTLIBS := hostcxxlibs
99408 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99409 +endif
99410 +
99411 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99412 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99413 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99414 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99415 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99416 +$(HOSTLIBS)-y += colorize_plugin.so
99417 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99418 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99419 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99420 +
99421 +always := $($(HOSTLIBS)-y)
99422 +
99423 +constify_plugin-objs := constify_plugin.o
99424 +stackleak_plugin-objs := stackleak_plugin.o
99425 +kallocstat_plugin-objs := kallocstat_plugin.o
99426 +kernexec_plugin-objs := kernexec_plugin.o
99427 +checker_plugin-objs := checker_plugin.o
99428 +colorize_plugin-objs := colorize_plugin.o
99429 +size_overflow_plugin-objs := size_overflow_plugin.o
99430 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99431 +structleak_plugin-objs := structleak_plugin.o
99432 +
99433 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99434 +
99435 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99436 + cmd_build_size_overflow_hash = \
99437 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99438 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99439 + $(call if_changed,build_size_overflow_hash)
99440 +
99441 +targets += size_overflow_hash.h
99442 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99443 new file mode 100644
99444 index 0000000..22f03c0
99445 --- /dev/null
99446 +++ b/tools/gcc/checker_plugin.c
99447 @@ -0,0 +1,172 @@
99448 +/*
99449 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99450 + * Licensed under the GPL v2
99451 + *
99452 + * Note: the choice of the license means that the compilation process is
99453 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99454 + * but for the kernel it doesn't matter since it doesn't link against
99455 + * any of the gcc libraries
99456 + *
99457 + * gcc plugin to implement various sparse (source code checker) features
99458 + *
99459 + * TODO:
99460 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99461 + *
99462 + * BUGS:
99463 + * - none known
99464 + */
99465 +#include "gcc-plugin.h"
99466 +#include "config.h"
99467 +#include "system.h"
99468 +#include "coretypes.h"
99469 +#include "tree.h"
99470 +#include "tree-pass.h"
99471 +#include "flags.h"
99472 +#include "intl.h"
99473 +#include "toplev.h"
99474 +#include "plugin.h"
99475 +//#include "expr.h" where are you...
99476 +#include "diagnostic.h"
99477 +#include "plugin-version.h"
99478 +#include "tm.h"
99479 +#include "function.h"
99480 +#include "basic-block.h"
99481 +#include "gimple.h"
99482 +#include "rtl.h"
99483 +#include "emit-rtl.h"
99484 +#include "tree-flow.h"
99485 +#include "target.h"
99486 +
99487 +extern void c_register_addr_space (const char *str, addr_space_t as);
99488 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99489 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99490 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99491 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99492 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99493 +
99494 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99495 +extern rtx emit_move_insn(rtx x, rtx y);
99496 +
99497 +int plugin_is_GPL_compatible;
99498 +
99499 +static struct plugin_info checker_plugin_info = {
99500 + .version = "201111150100",
99501 + .help = NULL,
99502 +};
99503 +
99504 +#define ADDR_SPACE_KERNEL 0
99505 +#define ADDR_SPACE_FORCE_KERNEL 1
99506 +#define ADDR_SPACE_USER 2
99507 +#define ADDR_SPACE_FORCE_USER 3
99508 +#define ADDR_SPACE_IOMEM 0
99509 +#define ADDR_SPACE_FORCE_IOMEM 0
99510 +#define ADDR_SPACE_PERCPU 0
99511 +#define ADDR_SPACE_FORCE_PERCPU 0
99512 +#define ADDR_SPACE_RCU 0
99513 +#define ADDR_SPACE_FORCE_RCU 0
99514 +
99515 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99516 +{
99517 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99518 +}
99519 +
99520 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99521 +{
99522 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99523 +}
99524 +
99525 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99526 +{
99527 + return default_addr_space_valid_pointer_mode(mode, as);
99528 +}
99529 +
99530 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99531 +{
99532 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99533 +}
99534 +
99535 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99536 +{
99537 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99538 +}
99539 +
99540 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99541 +{
99542 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99543 + return true;
99544 +
99545 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99546 + return true;
99547 +
99548 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99549 + return true;
99550 +
99551 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99552 + return true;
99553 +
99554 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99555 + return true;
99556 +
99557 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99558 + return true;
99559 +
99560 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99561 + return true;
99562 +
99563 + return subset == superset;
99564 +}
99565 +
99566 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
99567 +{
99568 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
99569 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
99570 +
99571 + return op;
99572 +}
99573 +
99574 +static void register_checker_address_spaces(void *event_data, void *data)
99575 +{
99576 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
99577 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
99578 + c_register_addr_space("__user", ADDR_SPACE_USER);
99579 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
99580 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
99581 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
99582 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
99583 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
99584 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
99585 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
99586 +
99587 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
99588 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
99589 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
99590 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
99591 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
99592 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
99593 + targetm.addr_space.convert = checker_addr_space_convert;
99594 +}
99595 +
99596 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99597 +{
99598 + const char * const plugin_name = plugin_info->base_name;
99599 + const int argc = plugin_info->argc;
99600 + const struct plugin_argument * const argv = plugin_info->argv;
99601 + int i;
99602 +
99603 + if (!plugin_default_version_check(version, &gcc_version)) {
99604 + error(G_("incompatible gcc/plugin versions"));
99605 + return 1;
99606 + }
99607 +
99608 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
99609 +
99610 + for (i = 0; i < argc; ++i)
99611 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99612 +
99613 + if (TARGET_64BIT == 0)
99614 + return 0;
99615 +
99616 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
99617 +
99618 + return 0;
99619 +}
99620 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
99621 new file mode 100644
99622 index 0000000..414fe5e
99623 --- /dev/null
99624 +++ b/tools/gcc/colorize_plugin.c
99625 @@ -0,0 +1,151 @@
99626 +/*
99627 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
99628 + * Licensed under the GPL v2
99629 + *
99630 + * Note: the choice of the license means that the compilation process is
99631 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99632 + * but for the kernel it doesn't matter since it doesn't link against
99633 + * any of the gcc libraries
99634 + *
99635 + * gcc plugin to colorize diagnostic output
99636 + *
99637 + */
99638 +
99639 +#include "gcc-plugin.h"
99640 +#include "config.h"
99641 +#include "system.h"
99642 +#include "coretypes.h"
99643 +#include "tree.h"
99644 +#include "tree-pass.h"
99645 +#include "flags.h"
99646 +#include "intl.h"
99647 +#include "toplev.h"
99648 +#include "plugin.h"
99649 +#include "diagnostic.h"
99650 +#include "plugin-version.h"
99651 +#include "tm.h"
99652 +
99653 +int plugin_is_GPL_compatible;
99654 +
99655 +static struct plugin_info colorize_plugin_info = {
99656 + .version = "201302112000",
99657 + .help = NULL,
99658 +};
99659 +
99660 +#define GREEN "\033[32m\033[2m"
99661 +#define LIGHTGREEN "\033[32m\033[1m"
99662 +#define YELLOW "\033[33m\033[2m"
99663 +#define LIGHTYELLOW "\033[33m\033[1m"
99664 +#define RED "\033[31m\033[2m"
99665 +#define LIGHTRED "\033[31m\033[1m"
99666 +#define BLUE "\033[34m\033[2m"
99667 +#define LIGHTBLUE "\033[34m\033[1m"
99668 +#define BRIGHT "\033[m\033[1m"
99669 +#define NORMAL "\033[m"
99670 +
99671 +static diagnostic_starter_fn old_starter;
99672 +static diagnostic_finalizer_fn old_finalizer;
99673 +
99674 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99675 +{
99676 + const char *color;
99677 + char *newprefix;
99678 +
99679 + switch (diagnostic->kind) {
99680 + case DK_NOTE:
99681 + color = LIGHTBLUE;
99682 + break;
99683 +
99684 + case DK_PEDWARN:
99685 + case DK_WARNING:
99686 + color = LIGHTYELLOW;
99687 + break;
99688 +
99689 + case DK_ERROR:
99690 + case DK_FATAL:
99691 + case DK_ICE:
99692 + case DK_PERMERROR:
99693 + case DK_SORRY:
99694 + color = LIGHTRED;
99695 + break;
99696 +
99697 + default:
99698 + color = NORMAL;
99699 + }
99700 +
99701 + old_starter(context, diagnostic);
99702 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
99703 + return;
99704 + pp_destroy_prefix(context->printer);
99705 + pp_set_prefix(context->printer, newprefix);
99706 +}
99707 +
99708 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99709 +{
99710 + old_finalizer(context, diagnostic);
99711 +}
99712 +
99713 +static void colorize_arm(void)
99714 +{
99715 + old_starter = diagnostic_starter(global_dc);
99716 + old_finalizer = diagnostic_finalizer(global_dc);
99717 +
99718 + diagnostic_starter(global_dc) = start_colorize;
99719 + diagnostic_finalizer(global_dc) = finalize_colorize;
99720 +}
99721 +
99722 +static unsigned int execute_colorize_rearm(void)
99723 +{
99724 + if (diagnostic_starter(global_dc) == start_colorize)
99725 + return 0;
99726 +
99727 + colorize_arm();
99728 + return 0;
99729 +}
99730 +
99731 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
99732 + .pass = {
99733 + .type = SIMPLE_IPA_PASS,
99734 + .name = "colorize_rearm",
99735 +#if BUILDING_GCC_VERSION >= 4008
99736 + .optinfo_flags = OPTGROUP_NONE,
99737 +#endif
99738 + .gate = NULL,
99739 + .execute = execute_colorize_rearm,
99740 + .sub = NULL,
99741 + .next = NULL,
99742 + .static_pass_number = 0,
99743 + .tv_id = TV_NONE,
99744 + .properties_required = 0,
99745 + .properties_provided = 0,
99746 + .properties_destroyed = 0,
99747 + .todo_flags_start = 0,
99748 + .todo_flags_finish = 0
99749 + }
99750 +};
99751 +
99752 +static void colorize_start_unit(void *gcc_data, void *user_data)
99753 +{
99754 + colorize_arm();
99755 +}
99756 +
99757 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99758 +{
99759 + const char * const plugin_name = plugin_info->base_name;
99760 + struct register_pass_info colorize_rearm_pass_info = {
99761 + .pass = &pass_ipa_colorize_rearm.pass,
99762 + .reference_pass_name = "*free_lang_data",
99763 + .ref_pass_instance_number = 1,
99764 + .pos_op = PASS_POS_INSERT_AFTER
99765 + };
99766 +
99767 + if (!plugin_default_version_check(version, &gcc_version)) {
99768 + error(G_("incompatible gcc/plugin versions"));
99769 + return 1;
99770 + }
99771 +
99772 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
99773 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
99774 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
99775 + return 0;
99776 +}
99777 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
99778 new file mode 100644
99779 index 0000000..c17312d
99780 --- /dev/null
99781 +++ b/tools/gcc/constify_plugin.c
99782 @@ -0,0 +1,560 @@
99783 +/*
99784 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
99785 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
99786 + * Licensed under the GPL v2, or (at your option) v3
99787 + *
99788 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
99789 + *
99790 + * Homepage:
99791 + * http://www.grsecurity.net/~ephox/const_plugin/
99792 + *
99793 + * Usage:
99794 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
99795 + * $ gcc -fplugin=constify_plugin.so test.c -O2
99796 + */
99797 +
99798 +#include "gcc-plugin.h"
99799 +#include "config.h"
99800 +#include "system.h"
99801 +#include "coretypes.h"
99802 +#include "tree.h"
99803 +#include "tree-pass.h"
99804 +#include "flags.h"
99805 +#include "intl.h"
99806 +#include "toplev.h"
99807 +#include "plugin.h"
99808 +#include "diagnostic.h"
99809 +#include "plugin-version.h"
99810 +#include "tm.h"
99811 +#include "function.h"
99812 +#include "basic-block.h"
99813 +#include "gimple.h"
99814 +#include "rtl.h"
99815 +#include "emit-rtl.h"
99816 +#include "tree-flow.h"
99817 +#include "target.h"
99818 +#include "langhooks.h"
99819 +
99820 +// should come from c-tree.h if only it were installed for gcc 4.5...
99821 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
99822 +
99823 +// unused type flag in all versions 4.5-4.8
99824 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
99825 +
99826 +int plugin_is_GPL_compatible;
99827 +
99828 +static struct plugin_info const_plugin_info = {
99829 + .version = "201305231310",
99830 + .help = "no-constify\tturn off constification\n",
99831 +};
99832 +
99833 +typedef struct {
99834 + bool has_fptr_field;
99835 + bool has_writable_field;
99836 + bool has_do_const_field;
99837 + bool has_no_const_field;
99838 +} constify_info;
99839 +
99840 +static const_tree get_field_type(const_tree field)
99841 +{
99842 + return strip_array_types(TREE_TYPE(field));
99843 +}
99844 +
99845 +static bool is_fptr(const_tree field)
99846 +{
99847 + const_tree ptr = get_field_type(field);
99848 +
99849 + if (TREE_CODE(ptr) != POINTER_TYPE)
99850 + return false;
99851 +
99852 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
99853 +}
99854 +
99855 +/*
99856 + * determine whether the given structure type meets the requirements for automatic constification,
99857 + * including the constification attributes on nested structure types
99858 + */
99859 +static void constifiable(const_tree node, constify_info *cinfo)
99860 +{
99861 + const_tree field;
99862 +
99863 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99864 +
99865 + // e.g., pointer to structure fields while still constructing the structure type
99866 + if (TYPE_FIELDS(node) == NULL_TREE)
99867 + return;
99868 +
99869 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
99870 + const_tree type = get_field_type(field);
99871 + enum tree_code code = TREE_CODE(type);
99872 +
99873 + if (node == type)
99874 + continue;
99875 +
99876 + if (is_fptr(field))
99877 + cinfo->has_fptr_field = true;
99878 + else if (!TREE_READONLY(field))
99879 + cinfo->has_writable_field = true;
99880 +
99881 + if (code == RECORD_TYPE || code == UNION_TYPE) {
99882 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99883 + cinfo->has_do_const_field = true;
99884 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
99885 + cinfo->has_no_const_field = true;
99886 + else
99887 + constifiable(type, cinfo);
99888 + }
99889 + }
99890 +}
99891 +
99892 +static bool constified(const_tree node)
99893 +{
99894 + constify_info cinfo = {
99895 + .has_fptr_field = false,
99896 + .has_writable_field = false,
99897 + .has_do_const_field = false,
99898 + .has_no_const_field = false
99899 + };
99900 +
99901 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99902 +
99903 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
99904 + gcc_assert(!TYPE_READONLY(node));
99905 + return false;
99906 + }
99907 +
99908 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
99909 + gcc_assert(TYPE_READONLY(node));
99910 + return true;
99911 + }
99912 +
99913 + constifiable(node, &cinfo);
99914 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
99915 + return false;
99916 +
99917 + return TYPE_READONLY(node);
99918 +}
99919 +
99920 +static void deconstify_tree(tree node);
99921 +
99922 +static void deconstify_type(tree type)
99923 +{
99924 + tree field;
99925 +
99926 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
99927 +
99928 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
99929 + const_tree fieldtype = get_field_type(field);
99930 +
99931 + // special case handling of simple ptr-to-same-array-type members
99932 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
99933 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
99934 +
99935 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
99936 + continue;
99937 + if (TREE_TYPE(TREE_TYPE(field)) == type)
99938 + continue;
99939 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
99940 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
99941 + TREE_TYPE(TREE_TYPE(field)) = type;
99942 + }
99943 + continue;
99944 + }
99945 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
99946 + continue;
99947 + if (!constified(fieldtype))
99948 + continue;
99949 +
99950 + deconstify_tree(field);
99951 + TREE_READONLY(field) = 0;
99952 + }
99953 + TYPE_READONLY(type) = 0;
99954 + C_TYPE_FIELDS_READONLY(type) = 0;
99955 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99956 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
99957 +}
99958 +
99959 +static void deconstify_tree(tree node)
99960 +{
99961 + tree old_type, new_type, field;
99962 +
99963 + old_type = TREE_TYPE(node);
99964 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
99965 + node = TREE_TYPE(node) = copy_node(old_type);
99966 + old_type = TREE_TYPE(old_type);
99967 + }
99968 +
99969 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
99970 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
99971 +
99972 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
99973 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
99974 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
99975 + DECL_FIELD_CONTEXT(field) = new_type;
99976 +
99977 + deconstify_type(new_type);
99978 +
99979 + TREE_TYPE(node) = new_type;
99980 +}
99981 +
99982 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99983 +{
99984 + tree type;
99985 + constify_info cinfo = {
99986 + .has_fptr_field = false,
99987 + .has_writable_field = false,
99988 + .has_do_const_field = false,
99989 + .has_no_const_field = false
99990 + };
99991 +
99992 + *no_add_attrs = true;
99993 + if (TREE_CODE(*node) == FUNCTION_DECL) {
99994 + error("%qE attribute does not apply to functions", name);
99995 + return NULL_TREE;
99996 + }
99997 +
99998 + if (TREE_CODE(*node) == PARM_DECL) {
99999 + error("%qE attribute does not apply to function parameters", name);
100000 + return NULL_TREE;
100001 + }
100002 +
100003 + if (TREE_CODE(*node) == VAR_DECL) {
100004 + error("%qE attribute does not apply to variables", name);
100005 + return NULL_TREE;
100006 + }
100007 +
100008 + if (TYPE_P(*node)) {
100009 + *no_add_attrs = false;
100010 + type = *node;
100011 + } else {
100012 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100013 + type = TREE_TYPE(*node);
100014 + }
100015 +
100016 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100017 + error("%qE attribute applies to struct and union types only", name);
100018 + return NULL_TREE;
100019 + }
100020 +
100021 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100022 + error("%qE attribute is already applied to the type", name);
100023 + return NULL_TREE;
100024 + }
100025 +
100026 + if (TYPE_P(*node)) {
100027 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100028 + error("%qE attribute is incompatible with 'do_const'", name);
100029 + return NULL_TREE;
100030 + }
100031 +
100032 + constifiable(type, &cinfo);
100033 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100034 + deconstify_tree(*node);
100035 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100036 + return NULL_TREE;
100037 + }
100038 +
100039 + error("%qE attribute used on type that is not constified", name);
100040 + return NULL_TREE;
100041 +}
100042 +
100043 +static void constify_type(tree type)
100044 +{
100045 + TYPE_READONLY(type) = 1;
100046 + C_TYPE_FIELDS_READONLY(type) = 1;
100047 + TYPE_CONSTIFY_VISITED(type) = 1;
100048 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100049 +}
100050 +
100051 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100052 +{
100053 + *no_add_attrs = true;
100054 + if (!TYPE_P(*node)) {
100055 + error("%qE attribute applies to types only", name);
100056 + return NULL_TREE;
100057 + }
100058 +
100059 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100060 + error("%qE attribute applies to struct and union types only", name);
100061 + return NULL_TREE;
100062 + }
100063 +
100064 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100065 + error("%qE attribute is already applied to the type", name);
100066 + return NULL_TREE;
100067 + }
100068 +
100069 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100070 + error("%qE attribute is incompatible with 'no_const'", name);
100071 + return NULL_TREE;
100072 + }
100073 +
100074 + *no_add_attrs = false;
100075 + return NULL_TREE;
100076 +}
100077 +
100078 +static struct attribute_spec no_const_attr = {
100079 + .name = "no_const",
100080 + .min_length = 0,
100081 + .max_length = 0,
100082 + .decl_required = false,
100083 + .type_required = false,
100084 + .function_type_required = false,
100085 + .handler = handle_no_const_attribute,
100086 +#if BUILDING_GCC_VERSION >= 4007
100087 + .affects_type_identity = true
100088 +#endif
100089 +};
100090 +
100091 +static struct attribute_spec do_const_attr = {
100092 + .name = "do_const",
100093 + .min_length = 0,
100094 + .max_length = 0,
100095 + .decl_required = false,
100096 + .type_required = false,
100097 + .function_type_required = false,
100098 + .handler = handle_do_const_attribute,
100099 +#if BUILDING_GCC_VERSION >= 4007
100100 + .affects_type_identity = true
100101 +#endif
100102 +};
100103 +
100104 +static void register_attributes(void *event_data, void *data)
100105 +{
100106 + register_attribute(&no_const_attr);
100107 + register_attribute(&do_const_attr);
100108 +}
100109 +
100110 +static void finish_type(void *event_data, void *data)
100111 +{
100112 + tree type = (tree)event_data;
100113 + constify_info cinfo = {
100114 + .has_fptr_field = false,
100115 + .has_writable_field = false,
100116 + .has_do_const_field = false,
100117 + .has_no_const_field = false
100118 + };
100119 +
100120 + if (type == NULL_TREE || type == error_mark_node)
100121 + return;
100122 +
100123 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100124 + return;
100125 +
100126 + constifiable(type, &cinfo);
100127 +
100128 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100129 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100130 + return;
100131 + if (cinfo.has_writable_field)
100132 + return;
100133 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100134 + return;
100135 + }
100136 +
100137 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100138 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100139 + deconstify_type(type);
100140 + TYPE_CONSTIFY_VISITED(type) = 1;
100141 + } else
100142 + error("'no_const' attribute used on type that is not constified");
100143 + return;
100144 + }
100145 +
100146 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100147 + constify_type(type);
100148 + return;
100149 + }
100150 +
100151 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100152 + constify_type(type);
100153 + return;
100154 + }
100155 +
100156 + deconstify_type(type);
100157 + TYPE_CONSTIFY_VISITED(type) = 1;
100158 +}
100159 +
100160 +static void check_global_variables(void)
100161 +{
100162 + struct varpool_node *node;
100163 +
100164 +#if BUILDING_GCC_VERSION <= 4007
100165 + for (node = varpool_nodes; node; node = node->next) {
100166 + tree var = node->decl;
100167 +#else
100168 + FOR_EACH_VARIABLE(node) {
100169 + tree var = node->symbol.decl;
100170 +#endif
100171 + tree type = TREE_TYPE(var);
100172 +
100173 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100174 + continue;
100175 +
100176 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100177 + continue;
100178 +
100179 + if (!TYPE_CONSTIFY_VISITED(type))
100180 + continue;
100181 +
100182 + if (DECL_EXTERNAL(var))
100183 + continue;
100184 +
100185 + if (DECL_INITIAL(var))
100186 + continue;
100187 +
100188 + // this works around a gcc bug/feature where uninitialized globals
100189 + // are moved into the .bss section regardless of any constification
100190 + DECL_INITIAL(var) = build_constructor(type, NULL);
100191 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100192 + }
100193 +}
100194 +
100195 +static unsigned int check_local_variables(void)
100196 +{
100197 + unsigned int ret = 0;
100198 + tree var;
100199 +
100200 +#if BUILDING_GCC_VERSION == 4005
100201 + tree vars;
100202 +#else
100203 + unsigned int i;
100204 +#endif
100205 +
100206 +#if BUILDING_GCC_VERSION == 4005
100207 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100208 + var = TREE_VALUE(vars);
100209 +#else
100210 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100211 +#endif
100212 + tree type = TREE_TYPE(var);
100213 +
100214 + gcc_assert(DECL_P(var));
100215 + if (is_global_var(var))
100216 + continue;
100217 +
100218 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100219 + continue;
100220 +
100221 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100222 + continue;
100223 +
100224 + if (!TYPE_CONSTIFY_VISITED(type))
100225 + continue;
100226 +
100227 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100228 + ret = 1;
100229 + }
100230 + return ret;
100231 +}
100232 +
100233 +static unsigned int check_variables(void)
100234 +{
100235 + check_global_variables();
100236 + return check_local_variables();
100237 +}
100238 +
100239 + unsigned int ret = 0;
100240 +static struct gimple_opt_pass pass_local_variable = {
100241 + {
100242 + .type = GIMPLE_PASS,
100243 + .name = "check_variables",
100244 +#if BUILDING_GCC_VERSION >= 4008
100245 + .optinfo_flags = OPTGROUP_NONE,
100246 +#endif
100247 + .gate = NULL,
100248 + .execute = check_variables,
100249 + .sub = NULL,
100250 + .next = NULL,
100251 + .static_pass_number = 0,
100252 + .tv_id = TV_NONE,
100253 + .properties_required = 0,
100254 + .properties_provided = 0,
100255 + .properties_destroyed = 0,
100256 + .todo_flags_start = 0,
100257 + .todo_flags_finish = 0
100258 + }
100259 +};
100260 +
100261 +static struct {
100262 + const char *name;
100263 + const char *asm_op;
100264 +} sections[] = {
100265 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100266 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100267 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100268 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100269 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100270 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100271 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100272 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100273 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100274 +};
100275 +
100276 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100277 +
100278 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100279 +{
100280 + size_t i;
100281 +
100282 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100283 + if (!strcmp(sections[i].name, name))
100284 + return 0;
100285 + return old_section_type_flags(decl, name, reloc);
100286 +}
100287 +
100288 +static void constify_start_unit(void *gcc_data, void *user_data)
100289 +{
100290 +// size_t i;
100291 +
100292 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100293 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100294 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100295 +
100296 + old_section_type_flags = targetm.section_type_flags;
100297 + targetm.section_type_flags = constify_section_type_flags;
100298 +}
100299 +
100300 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100301 +{
100302 + const char * const plugin_name = plugin_info->base_name;
100303 + const int argc = plugin_info->argc;
100304 + const struct plugin_argument * const argv = plugin_info->argv;
100305 + int i;
100306 + bool constify = true;
100307 +
100308 + struct register_pass_info local_variable_pass_info = {
100309 + .pass = &pass_local_variable.pass,
100310 + .reference_pass_name = "ssa",
100311 + .ref_pass_instance_number = 1,
100312 + .pos_op = PASS_POS_INSERT_BEFORE
100313 + };
100314 +
100315 + if (!plugin_default_version_check(version, &gcc_version)) {
100316 + error(G_("incompatible gcc/plugin versions"));
100317 + return 1;
100318 + }
100319 +
100320 + for (i = 0; i < argc; ++i) {
100321 + if (!(strcmp(argv[i].key, "no-constify"))) {
100322 + constify = false;
100323 + continue;
100324 + }
100325 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100326 + }
100327 +
100328 + if (strcmp(lang_hooks.name, "GNU C")) {
100329 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100330 + constify = false;
100331 + }
100332 +
100333 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100334 + if (constify) {
100335 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100336 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100337 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100338 + }
100339 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100340 +
100341 + return 0;
100342 +}
100343 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100344 new file mode 100644
100345 index 0000000..e518932
100346 --- /dev/null
100347 +++ b/tools/gcc/generate_size_overflow_hash.sh
100348 @@ -0,0 +1,94 @@
100349 +#!/bin/bash
100350 +
100351 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100352 +
100353 +header1="size_overflow_hash.h"
100354 +database="size_overflow_hash.data"
100355 +n=65536
100356 +
100357 +usage() {
100358 +cat <<EOF
100359 +usage: $0 options
100360 +OPTIONS:
100361 + -h|--help help
100362 + -o header file
100363 + -d database file
100364 + -n hash array size
100365 +EOF
100366 + return 0
100367 +}
100368 +
100369 +while true
100370 +do
100371 + case "$1" in
100372 + -h|--help) usage && exit 0;;
100373 + -n) n=$2; shift 2;;
100374 + -o) header1="$2"; shift 2;;
100375 + -d) database="$2"; shift 2;;
100376 + --) shift 1; break ;;
100377 + *) break ;;
100378 + esac
100379 +done
100380 +
100381 +create_defines() {
100382 + for i in `seq 0 31`
100383 + do
100384 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100385 + done
100386 + echo >> "$header1"
100387 +}
100388 +
100389 +create_structs() {
100390 + rm -f "$header1"
100391 +
100392 + create_defines
100393 +
100394 + cat "$database" | while read data
100395 + do
100396 + data_array=($data)
100397 + struct_hash_name="${data_array[0]}"
100398 + funcn="${data_array[1]}"
100399 + params="${data_array[2]}"
100400 + next="${data_array[4]}"
100401 +
100402 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100403 +
100404 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100405 + echo -en "\t.param\t= " >> "$header1"
100406 + line=
100407 + for param_num in ${params//-/ };
100408 + do
100409 + line="${line}PARAM"$param_num"|"
100410 + done
100411 +
100412 + echo -e "${line%?},\n};\n" >> "$header1"
100413 + done
100414 +}
100415 +
100416 +create_headers() {
100417 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100418 +}
100419 +
100420 +create_array_elements() {
100421 + index=0
100422 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100423 + do
100424 + data_array=($data)
100425 + i="${data_array[3]}"
100426 + hash="${data_array[0]}"
100427 + while [[ $index -lt $i ]]
100428 + do
100429 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100430 + index=$(($index + 1))
100431 + done
100432 + index=$(($index + 1))
100433 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100434 + done
100435 + echo '};' >> $header1
100436 +}
100437 +
100438 +create_structs
100439 +create_headers
100440 +create_array_elements
100441 +
100442 +exit 0
100443 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100444 new file mode 100644
100445 index 0000000..568b360
100446 --- /dev/null
100447 +++ b/tools/gcc/kallocstat_plugin.c
100448 @@ -0,0 +1,170 @@
100449 +/*
100450 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100451 + * Licensed under the GPL v2
100452 + *
100453 + * Note: the choice of the license means that the compilation process is
100454 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100455 + * but for the kernel it doesn't matter since it doesn't link against
100456 + * any of the gcc libraries
100457 + *
100458 + * gcc plugin to find the distribution of k*alloc sizes
100459 + *
100460 + * TODO:
100461 + *
100462 + * BUGS:
100463 + * - none known
100464 + */
100465 +#include "gcc-plugin.h"
100466 +#include "config.h"
100467 +#include "system.h"
100468 +#include "coretypes.h"
100469 +#include "tree.h"
100470 +#include "tree-pass.h"
100471 +#include "flags.h"
100472 +#include "intl.h"
100473 +#include "toplev.h"
100474 +#include "plugin.h"
100475 +//#include "expr.h" where are you...
100476 +#include "diagnostic.h"
100477 +#include "plugin-version.h"
100478 +#include "tm.h"
100479 +#include "function.h"
100480 +#include "basic-block.h"
100481 +#include "gimple.h"
100482 +#include "rtl.h"
100483 +#include "emit-rtl.h"
100484 +
100485 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100486 +
100487 +int plugin_is_GPL_compatible;
100488 +
100489 +static const char * const kalloc_functions[] = {
100490 + "__kmalloc",
100491 + "kmalloc",
100492 + "kmalloc_large",
100493 + "kmalloc_node",
100494 + "kmalloc_order",
100495 + "kmalloc_order_trace",
100496 + "kmalloc_slab",
100497 + "kzalloc",
100498 + "kzalloc_node",
100499 +};
100500 +
100501 +static struct plugin_info kallocstat_plugin_info = {
100502 + .version = "201302112000",
100503 +};
100504 +
100505 +static unsigned int execute_kallocstat(void);
100506 +
100507 +static struct gimple_opt_pass kallocstat_pass = {
100508 + .pass = {
100509 + .type = GIMPLE_PASS,
100510 + .name = "kallocstat",
100511 +#if BUILDING_GCC_VERSION >= 4008
100512 + .optinfo_flags = OPTGROUP_NONE,
100513 +#endif
100514 + .gate = NULL,
100515 + .execute = execute_kallocstat,
100516 + .sub = NULL,
100517 + .next = NULL,
100518 + .static_pass_number = 0,
100519 + .tv_id = TV_NONE,
100520 + .properties_required = 0,
100521 + .properties_provided = 0,
100522 + .properties_destroyed = 0,
100523 + .todo_flags_start = 0,
100524 + .todo_flags_finish = 0
100525 + }
100526 +};
100527 +
100528 +static bool is_kalloc(const char *fnname)
100529 +{
100530 + size_t i;
100531 +
100532 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100533 + if (!strcmp(fnname, kalloc_functions[i]))
100534 + return true;
100535 + return false;
100536 +}
100537 +
100538 +static unsigned int execute_kallocstat(void)
100539 +{
100540 + basic_block bb;
100541 +
100542 + // 1. loop through BBs and GIMPLE statements
100543 + FOR_EACH_BB(bb) {
100544 + gimple_stmt_iterator gsi;
100545 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100546 + // gimple match:
100547 + tree fndecl, size;
100548 + gimple call_stmt;
100549 + const char *fnname;
100550 +
100551 + // is it a call
100552 + call_stmt = gsi_stmt(gsi);
100553 + if (!is_gimple_call(call_stmt))
100554 + continue;
100555 + fndecl = gimple_call_fndecl(call_stmt);
100556 + if (fndecl == NULL_TREE)
100557 + continue;
100558 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100559 + continue;
100560 +
100561 + // is it a call to k*alloc
100562 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100563 + if (!is_kalloc(fnname))
100564 + continue;
100565 +
100566 + // is the size arg the result of a simple const assignment
100567 + size = gimple_call_arg(call_stmt, 0);
100568 + while (true) {
100569 + gimple def_stmt;
100570 + expanded_location xloc;
100571 + size_t size_val;
100572 +
100573 + if (TREE_CODE(size) != SSA_NAME)
100574 + break;
100575 + def_stmt = SSA_NAME_DEF_STMT(size);
100576 + if (!def_stmt || !is_gimple_assign(def_stmt))
100577 + break;
100578 + if (gimple_num_ops(def_stmt) != 2)
100579 + break;
100580 + size = gimple_assign_rhs1(def_stmt);
100581 + if (!TREE_CONSTANT(size))
100582 + continue;
100583 + xloc = expand_location(gimple_location(def_stmt));
100584 + if (!xloc.file)
100585 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100586 + size_val = TREE_INT_CST_LOW(size);
100587 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
100588 + break;
100589 + }
100590 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100591 +//debug_tree(gimple_call_fn(call_stmt));
100592 +//print_node(stderr, "pax", fndecl, 4);
100593 + }
100594 + }
100595 +
100596 + return 0;
100597 +}
100598 +
100599 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100600 +{
100601 + const char * const plugin_name = plugin_info->base_name;
100602 + struct register_pass_info kallocstat_pass_info = {
100603 + .pass = &kallocstat_pass.pass,
100604 + .reference_pass_name = "ssa",
100605 + .ref_pass_instance_number = 1,
100606 + .pos_op = PASS_POS_INSERT_AFTER
100607 + };
100608 +
100609 + if (!plugin_default_version_check(version, &gcc_version)) {
100610 + error(G_("incompatible gcc/plugin versions"));
100611 + return 1;
100612 + }
100613 +
100614 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
100615 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
100616 +
100617 + return 0;
100618 +}
100619 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
100620 new file mode 100644
100621 index 0000000..698da67
100622 --- /dev/null
100623 +++ b/tools/gcc/kernexec_plugin.c
100624 @@ -0,0 +1,471 @@
100625 +/*
100626 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100627 + * Licensed under the GPL v2
100628 + *
100629 + * Note: the choice of the license means that the compilation process is
100630 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100631 + * but for the kernel it doesn't matter since it doesn't link against
100632 + * any of the gcc libraries
100633 + *
100634 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
100635 + *
100636 + * TODO:
100637 + *
100638 + * BUGS:
100639 + * - none known
100640 + */
100641 +#include "gcc-plugin.h"
100642 +#include "config.h"
100643 +#include "system.h"
100644 +#include "coretypes.h"
100645 +#include "tree.h"
100646 +#include "tree-pass.h"
100647 +#include "flags.h"
100648 +#include "intl.h"
100649 +#include "toplev.h"
100650 +#include "plugin.h"
100651 +//#include "expr.h" where are you...
100652 +#include "diagnostic.h"
100653 +#include "plugin-version.h"
100654 +#include "tm.h"
100655 +#include "function.h"
100656 +#include "basic-block.h"
100657 +#include "gimple.h"
100658 +#include "rtl.h"
100659 +#include "emit-rtl.h"
100660 +#include "tree-flow.h"
100661 +
100662 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100663 +extern rtx emit_move_insn(rtx x, rtx y);
100664 +
100665 +#if BUILDING_GCC_VERSION <= 4006
100666 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
100667 +#endif
100668 +
100669 +#if BUILDING_GCC_VERSION >= 4008
100670 +#define TODO_dump_func 0
100671 +#endif
100672 +
100673 +int plugin_is_GPL_compatible;
100674 +
100675 +static struct plugin_info kernexec_plugin_info = {
100676 + .version = "201308230150",
100677 + .help = "method=[bts|or]\tinstrumentation method\n"
100678 +};
100679 +
100680 +static unsigned int execute_kernexec_reload(void);
100681 +static unsigned int execute_kernexec_fptr(void);
100682 +static unsigned int execute_kernexec_retaddr(void);
100683 +static bool kernexec_cmodel_check(void);
100684 +
100685 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
100686 +static void (*kernexec_instrument_retaddr)(rtx);
100687 +
100688 +static struct gimple_opt_pass kernexec_reload_pass = {
100689 + .pass = {
100690 + .type = GIMPLE_PASS,
100691 + .name = "kernexec_reload",
100692 +#if BUILDING_GCC_VERSION >= 4008
100693 + .optinfo_flags = OPTGROUP_NONE,
100694 +#endif
100695 + .gate = kernexec_cmodel_check,
100696 + .execute = execute_kernexec_reload,
100697 + .sub = NULL,
100698 + .next = NULL,
100699 + .static_pass_number = 0,
100700 + .tv_id = TV_NONE,
100701 + .properties_required = 0,
100702 + .properties_provided = 0,
100703 + .properties_destroyed = 0,
100704 + .todo_flags_start = 0,
100705 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100706 + }
100707 +};
100708 +
100709 +static struct gimple_opt_pass kernexec_fptr_pass = {
100710 + .pass = {
100711 + .type = GIMPLE_PASS,
100712 + .name = "kernexec_fptr",
100713 +#if BUILDING_GCC_VERSION >= 4008
100714 + .optinfo_flags = OPTGROUP_NONE,
100715 +#endif
100716 + .gate = kernexec_cmodel_check,
100717 + .execute = execute_kernexec_fptr,
100718 + .sub = NULL,
100719 + .next = NULL,
100720 + .static_pass_number = 0,
100721 + .tv_id = TV_NONE,
100722 + .properties_required = 0,
100723 + .properties_provided = 0,
100724 + .properties_destroyed = 0,
100725 + .todo_flags_start = 0,
100726 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100727 + }
100728 +};
100729 +
100730 +static struct rtl_opt_pass kernexec_retaddr_pass = {
100731 + .pass = {
100732 + .type = RTL_PASS,
100733 + .name = "kernexec_retaddr",
100734 +#if BUILDING_GCC_VERSION >= 4008
100735 + .optinfo_flags = OPTGROUP_NONE,
100736 +#endif
100737 + .gate = kernexec_cmodel_check,
100738 + .execute = execute_kernexec_retaddr,
100739 + .sub = NULL,
100740 + .next = NULL,
100741 + .static_pass_number = 0,
100742 + .tv_id = TV_NONE,
100743 + .properties_required = 0,
100744 + .properties_provided = 0,
100745 + .properties_destroyed = 0,
100746 + .todo_flags_start = 0,
100747 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
100748 + }
100749 +};
100750 +
100751 +static bool kernexec_cmodel_check(void)
100752 +{
100753 + tree section;
100754 +
100755 + if (ix86_cmodel != CM_KERNEL)
100756 + return false;
100757 +
100758 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
100759 + if (!section || !TREE_VALUE(section))
100760 + return true;
100761 +
100762 + section = TREE_VALUE(TREE_VALUE(section));
100763 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
100764 + return true;
100765 +
100766 + return false;
100767 +}
100768 +
100769 +/*
100770 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
100771 + */
100772 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
100773 +{
100774 + gimple asm_movabs_stmt;
100775 +
100776 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
100777 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
100778 + gimple_asm_set_volatile(asm_movabs_stmt, true);
100779 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
100780 + update_stmt(asm_movabs_stmt);
100781 +}
100782 +
100783 +/*
100784 + * find all asm() stmts that clobber r10 and add a reload of r10
100785 + */
100786 +static unsigned int execute_kernexec_reload(void)
100787 +{
100788 + basic_block bb;
100789 +
100790 + // 1. loop through BBs and GIMPLE statements
100791 + FOR_EACH_BB(bb) {
100792 + gimple_stmt_iterator gsi;
100793 +
100794 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100795 + // gimple match: __asm__ ("" : : : "r10");
100796 + gimple asm_stmt;
100797 + size_t nclobbers;
100798 +
100799 + // is it an asm ...
100800 + asm_stmt = gsi_stmt(gsi);
100801 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
100802 + continue;
100803 +
100804 + // ... clobbering r10
100805 + nclobbers = gimple_asm_nclobbers(asm_stmt);
100806 + while (nclobbers--) {
100807 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
100808 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
100809 + continue;
100810 + kernexec_reload_fptr_mask(&gsi);
100811 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
100812 + break;
100813 + }
100814 + }
100815 + }
100816 +
100817 + return 0;
100818 +}
100819 +
100820 +/*
100821 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
100822 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
100823 + */
100824 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
100825 +{
100826 + gimple assign_intptr, assign_new_fptr, call_stmt;
100827 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
100828 +
100829 + call_stmt = gsi_stmt(*gsi);
100830 + old_fptr = gimple_call_fn(call_stmt);
100831 +
100832 + // create temporary unsigned long variable used for bitops and cast fptr to it
100833 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
100834 +#if BUILDING_GCC_VERSION <= 4007
100835 + add_referenced_var(intptr);
100836 +#endif
100837 + intptr = make_ssa_name(intptr, NULL);
100838 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
100839 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100840 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100841 + update_stmt(assign_intptr);
100842 +
100843 + // apply logical or to temporary unsigned long and bitmask
100844 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
100845 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
100846 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
100847 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
100848 + assign_intptr = gimple_build_assign(intptr, orptr);
100849 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100850 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100851 + update_stmt(assign_intptr);
100852 +
100853 + // cast temporary unsigned long back to a temporary fptr variable
100854 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
100855 +#if BUILDING_GCC_VERSION <= 4007
100856 + add_referenced_var(new_fptr);
100857 +#endif
100858 + new_fptr = make_ssa_name(new_fptr, NULL);
100859 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
100860 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
100861 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
100862 + update_stmt(assign_new_fptr);
100863 +
100864 + // replace call stmt fn with the new fptr
100865 + gimple_call_set_fn(call_stmt, new_fptr);
100866 + update_stmt(call_stmt);
100867 +}
100868 +
100869 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
100870 +{
100871 + gimple asm_or_stmt, call_stmt;
100872 + tree old_fptr, new_fptr, input, output;
100873 +#if BUILDING_GCC_VERSION <= 4007
100874 + VEC(tree, gc) *inputs = NULL;
100875 + VEC(tree, gc) *outputs = NULL;
100876 +#else
100877 + vec<tree, va_gc> *inputs = NULL;
100878 + vec<tree, va_gc> *outputs = NULL;
100879 +#endif
100880 +
100881 + call_stmt = gsi_stmt(*gsi);
100882 + old_fptr = gimple_call_fn(call_stmt);
100883 +
100884 + // create temporary fptr variable
100885 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
100886 +#if BUILDING_GCC_VERSION <= 4007
100887 + add_referenced_var(new_fptr);
100888 +#endif
100889 + new_fptr = make_ssa_name(new_fptr, NULL);
100890 +
100891 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
100892 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
100893 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
100894 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
100895 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
100896 +#if BUILDING_GCC_VERSION <= 4007
100897 + VEC_safe_push(tree, gc, inputs, input);
100898 + VEC_safe_push(tree, gc, outputs, output);
100899 +#else
100900 + vec_safe_push(inputs, input);
100901 + vec_safe_push(outputs, output);
100902 +#endif
100903 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
100904 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
100905 + gimple_asm_set_volatile(asm_or_stmt, true);
100906 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
100907 + update_stmt(asm_or_stmt);
100908 +
100909 + // replace call stmt fn with the new fptr
100910 + gimple_call_set_fn(call_stmt, new_fptr);
100911 + update_stmt(call_stmt);
100912 +}
100913 +
100914 +/*
100915 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
100916 + */
100917 +static unsigned int execute_kernexec_fptr(void)
100918 +{
100919 + basic_block bb;
100920 +
100921 + // 1. loop through BBs and GIMPLE statements
100922 + FOR_EACH_BB(bb) {
100923 + gimple_stmt_iterator gsi;
100924 +
100925 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100926 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
100927 + tree fn;
100928 + gimple call_stmt;
100929 +
100930 + // is it a call ...
100931 + call_stmt = gsi_stmt(gsi);
100932 + if (!is_gimple_call(call_stmt))
100933 + continue;
100934 + fn = gimple_call_fn(call_stmt);
100935 + if (TREE_CODE(fn) == ADDR_EXPR)
100936 + continue;
100937 + if (TREE_CODE(fn) != SSA_NAME)
100938 + gcc_unreachable();
100939 +
100940 + // ... through a function pointer
100941 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
100942 + fn = SSA_NAME_VAR(fn);
100943 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
100944 + debug_tree(fn);
100945 + gcc_unreachable();
100946 + }
100947 + }
100948 + fn = TREE_TYPE(fn);
100949 + if (TREE_CODE(fn) != POINTER_TYPE)
100950 + continue;
100951 + fn = TREE_TYPE(fn);
100952 + if (TREE_CODE(fn) != FUNCTION_TYPE)
100953 + continue;
100954 +
100955 + kernexec_instrument_fptr(&gsi);
100956 +
100957 +//debug_tree(gimple_call_fn(call_stmt));
100958 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100959 + }
100960 + }
100961 +
100962 + return 0;
100963 +}
100964 +
100965 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
100966 +static void kernexec_instrument_retaddr_bts(rtx insn)
100967 +{
100968 + rtx btsq;
100969 + rtvec argvec, constraintvec, labelvec;
100970 + int line;
100971 +
100972 + // create asm volatile("btsq $63,(%%rsp)":::)
100973 + argvec = rtvec_alloc(0);
100974 + constraintvec = rtvec_alloc(0);
100975 + labelvec = rtvec_alloc(0);
100976 + line = expand_location(RTL_LOCATION(insn)).line;
100977 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100978 + MEM_VOLATILE_P(btsq) = 1;
100979 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
100980 + emit_insn_before(btsq, insn);
100981 +}
100982 +
100983 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
100984 +static void kernexec_instrument_retaddr_or(rtx insn)
100985 +{
100986 + rtx orq;
100987 + rtvec argvec, constraintvec, labelvec;
100988 + int line;
100989 +
100990 + // create asm volatile("orq %%r10,(%%rsp)":::)
100991 + argvec = rtvec_alloc(0);
100992 + constraintvec = rtvec_alloc(0);
100993 + labelvec = rtvec_alloc(0);
100994 + line = expand_location(RTL_LOCATION(insn)).line;
100995 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100996 + MEM_VOLATILE_P(orq) = 1;
100997 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
100998 + emit_insn_before(orq, insn);
100999 +}
101000 +
101001 +/*
101002 + * find all asm level function returns and forcibly set the highest bit of the return address
101003 + */
101004 +static unsigned int execute_kernexec_retaddr(void)
101005 +{
101006 + rtx insn;
101007 +
101008 + // 1. find function returns
101009 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101010 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101011 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101012 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101013 + rtx body;
101014 +
101015 + // is it a retn
101016 + if (!JUMP_P(insn))
101017 + continue;
101018 + body = PATTERN(insn);
101019 + if (GET_CODE(body) == PARALLEL)
101020 + body = XVECEXP(body, 0, 0);
101021 + if (!ANY_RETURN_P(body))
101022 + continue;
101023 + kernexec_instrument_retaddr(insn);
101024 + }
101025 +
101026 +// print_simple_rtl(stderr, get_insns());
101027 +// print_rtl(stderr, get_insns());
101028 +
101029 + return 0;
101030 +}
101031 +
101032 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101033 +{
101034 + const char * const plugin_name = plugin_info->base_name;
101035 + const int argc = plugin_info->argc;
101036 + const struct plugin_argument * const argv = plugin_info->argv;
101037 + int i;
101038 + struct register_pass_info kernexec_reload_pass_info = {
101039 + .pass = &kernexec_reload_pass.pass,
101040 + .reference_pass_name = "ssa",
101041 + .ref_pass_instance_number = 1,
101042 + .pos_op = PASS_POS_INSERT_AFTER
101043 + };
101044 + struct register_pass_info kernexec_fptr_pass_info = {
101045 + .pass = &kernexec_fptr_pass.pass,
101046 + .reference_pass_name = "ssa",
101047 + .ref_pass_instance_number = 1,
101048 + .pos_op = PASS_POS_INSERT_AFTER
101049 + };
101050 + struct register_pass_info kernexec_retaddr_pass_info = {
101051 + .pass = &kernexec_retaddr_pass.pass,
101052 + .reference_pass_name = "pro_and_epilogue",
101053 + .ref_pass_instance_number = 1,
101054 + .pos_op = PASS_POS_INSERT_AFTER
101055 + };
101056 +
101057 + if (!plugin_default_version_check(version, &gcc_version)) {
101058 + error(G_("incompatible gcc/plugin versions"));
101059 + return 1;
101060 + }
101061 +
101062 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101063 +
101064 + if (TARGET_64BIT == 0)
101065 + return 0;
101066 +
101067 + for (i = 0; i < argc; ++i) {
101068 + if (!strcmp(argv[i].key, "method")) {
101069 + if (!argv[i].value) {
101070 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101071 + continue;
101072 + }
101073 + if (!strcmp(argv[i].value, "bts")) {
101074 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101075 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101076 + } else if (!strcmp(argv[i].value, "or")) {
101077 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101078 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101079 + fix_register("r10", 1, 1);
101080 + } else
101081 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101082 + continue;
101083 + }
101084 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101085 + }
101086 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101087 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101088 +
101089 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101090 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101091 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101092 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101093 +
101094 + return 0;
101095 +}
101096 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101097 new file mode 100644
101098 index 0000000..cd6c242
101099 --- /dev/null
101100 +++ b/tools/gcc/latent_entropy_plugin.c
101101 @@ -0,0 +1,321 @@
101102 +/*
101103 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101104 + * Licensed under the GPL v2
101105 + *
101106 + * Note: the choice of the license means that the compilation process is
101107 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101108 + * but for the kernel it doesn't matter since it doesn't link against
101109 + * any of the gcc libraries
101110 + *
101111 + * gcc plugin to help generate a little bit of entropy from program state,
101112 + * used during boot in the kernel
101113 + *
101114 + * TODO:
101115 + * - add ipa pass to identify not explicitly marked candidate functions
101116 + * - mix in more program state (function arguments/return values, loop variables, etc)
101117 + * - more instrumentation control via attribute parameters
101118 + *
101119 + * BUGS:
101120 + * - LTO needs -flto-partition=none for now
101121 + */
101122 +#include "gcc-plugin.h"
101123 +#include "config.h"
101124 +#include "system.h"
101125 +#include "coretypes.h"
101126 +#include "tree.h"
101127 +#include "tree-pass.h"
101128 +#include "flags.h"
101129 +#include "intl.h"
101130 +#include "toplev.h"
101131 +#include "plugin.h"
101132 +//#include "expr.h" where are you...
101133 +#include "diagnostic.h"
101134 +#include "plugin-version.h"
101135 +#include "tm.h"
101136 +#include "function.h"
101137 +#include "basic-block.h"
101138 +#include "gimple.h"
101139 +#include "rtl.h"
101140 +#include "emit-rtl.h"
101141 +#include "tree-flow.h"
101142 +#include "langhooks.h"
101143 +
101144 +#if BUILDING_GCC_VERSION >= 4008
101145 +#define TODO_dump_func 0
101146 +#endif
101147 +
101148 +int plugin_is_GPL_compatible;
101149 +
101150 +static tree latent_entropy_decl;
101151 +
101152 +static struct plugin_info latent_entropy_plugin_info = {
101153 + .version = "201308230230",
101154 + .help = NULL
101155 +};
101156 +
101157 +static unsigned int execute_latent_entropy(void);
101158 +static bool gate_latent_entropy(void);
101159 +
101160 +static struct gimple_opt_pass latent_entropy_pass = {
101161 + .pass = {
101162 + .type = GIMPLE_PASS,
101163 + .name = "latent_entropy",
101164 +#if BUILDING_GCC_VERSION >= 4008
101165 + .optinfo_flags = OPTGROUP_NONE,
101166 +#endif
101167 + .gate = gate_latent_entropy,
101168 + .execute = execute_latent_entropy,
101169 + .sub = NULL,
101170 + .next = NULL,
101171 + .static_pass_number = 0,
101172 + .tv_id = TV_NONE,
101173 + .properties_required = PROP_gimple_leh | PROP_cfg,
101174 + .properties_provided = 0,
101175 + .properties_destroyed = 0,
101176 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101177 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101178 + }
101179 +};
101180 +
101181 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101182 +{
101183 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101184 + *no_add_attrs = true;
101185 + error("%qE attribute only applies to functions", name);
101186 + }
101187 + return NULL_TREE;
101188 +}
101189 +
101190 +static struct attribute_spec latent_entropy_attr = {
101191 + .name = "latent_entropy",
101192 + .min_length = 0,
101193 + .max_length = 0,
101194 + .decl_required = true,
101195 + .type_required = false,
101196 + .function_type_required = false,
101197 + .handler = handle_latent_entropy_attribute,
101198 +#if BUILDING_GCC_VERSION >= 4007
101199 + .affects_type_identity = false
101200 +#endif
101201 +};
101202 +
101203 +static void register_attributes(void *event_data, void *data)
101204 +{
101205 + register_attribute(&latent_entropy_attr);
101206 +}
101207 +
101208 +static bool gate_latent_entropy(void)
101209 +{
101210 + tree latent_entropy_attr;
101211 +
101212 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101213 + return latent_entropy_attr != NULL_TREE;
101214 +}
101215 +
101216 +static unsigned HOST_WIDE_INT seed;
101217 +static unsigned HOST_WIDE_INT get_random_const(void)
101218 +{
101219 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101220 + return seed;
101221 +}
101222 +
101223 +static enum tree_code get_op(tree *rhs)
101224 +{
101225 + static enum tree_code op;
101226 + unsigned HOST_WIDE_INT random_const;
101227 +
101228 + random_const = get_random_const();
101229 +
101230 + switch (op) {
101231 + case BIT_XOR_EXPR:
101232 + op = PLUS_EXPR;
101233 + break;
101234 +
101235 + case PLUS_EXPR:
101236 + if (rhs) {
101237 + op = LROTATE_EXPR;
101238 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101239 + break;
101240 + }
101241 +
101242 + case LROTATE_EXPR:
101243 + default:
101244 + op = BIT_XOR_EXPR;
101245 + break;
101246 + }
101247 + if (rhs)
101248 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101249 + return op;
101250 +}
101251 +
101252 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101253 +{
101254 + gimple_stmt_iterator gsi;
101255 + gimple assign;
101256 + tree addxorrol, rhs;
101257 + enum tree_code op;
101258 +
101259 + op = get_op(&rhs);
101260 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101261 + assign = gimple_build_assign(local_entropy, addxorrol);
101262 + gsi = gsi_after_labels(bb);
101263 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101264 + update_stmt(assign);
101265 +//debug_bb(bb);
101266 +}
101267 +
101268 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101269 +{
101270 + gimple_stmt_iterator gsi;
101271 + gimple assign;
101272 + tree addxorrol, temp;
101273 +
101274 + // 1. create temporary copy of latent_entropy
101275 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101276 +#if BUILDING_GCC_VERSION <= 4007
101277 + add_referenced_var(temp);
101278 +#endif
101279 +
101280 + // 2. read...
101281 + temp = make_ssa_name(temp, NULL);
101282 + assign = gimple_build_assign(temp, latent_entropy_decl);
101283 + SSA_NAME_DEF_STMT(temp) = assign;
101284 +#if BUILDING_GCC_VERSION <= 4007
101285 + add_referenced_var(latent_entropy_decl);
101286 +#endif
101287 + gsi = gsi_after_labels(bb);
101288 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101289 + update_stmt(assign);
101290 +
101291 + // 3. ...modify...
101292 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101293 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101294 + assign = gimple_build_assign(temp, addxorrol);
101295 + SSA_NAME_DEF_STMT(temp) = assign;
101296 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101297 + update_stmt(assign);
101298 +
101299 + // 4. ...write latent_entropy
101300 + assign = gimple_build_assign(latent_entropy_decl, temp);
101301 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101302 + update_stmt(assign);
101303 +}
101304 +
101305 +static unsigned int execute_latent_entropy(void)
101306 +{
101307 + basic_block bb;
101308 + gimple assign;
101309 + gimple_stmt_iterator gsi;
101310 + tree local_entropy;
101311 +
101312 + if (!latent_entropy_decl) {
101313 + struct varpool_node *node;
101314 +
101315 +#if BUILDING_GCC_VERSION <= 4007
101316 + for (node = varpool_nodes; node; node = node->next) {
101317 + tree var = node->decl;
101318 +#else
101319 + FOR_EACH_VARIABLE(node) {
101320 + tree var = node->symbol.decl;
101321 +#endif
101322 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101323 + continue;
101324 + latent_entropy_decl = var;
101325 +// debug_tree(var);
101326 + break;
101327 + }
101328 + if (!latent_entropy_decl) {
101329 +// debug_tree(current_function_decl);
101330 + return 0;
101331 + }
101332 + }
101333 +
101334 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101335 +
101336 + // 1. create local entropy variable
101337 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101338 +#if BUILDING_GCC_VERSION <= 4007
101339 + add_referenced_var(local_entropy);
101340 + mark_sym_for_renaming(local_entropy);
101341 +#endif
101342 +
101343 + // 2. initialize local entropy variable
101344 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101345 + if (dom_info_available_p(CDI_DOMINATORS))
101346 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101347 + gsi = gsi_start_bb(bb);
101348 +
101349 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101350 +// gimple_set_location(assign, loc);
101351 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101352 + update_stmt(assign);
101353 +//debug_bb(bb);
101354 + bb = bb->next_bb;
101355 +
101356 + // 3. instrument each BB with an operation on the local entropy variable
101357 + while (bb != EXIT_BLOCK_PTR) {
101358 + perturb_local_entropy(bb, local_entropy);
101359 +//debug_bb(bb);
101360 + bb = bb->next_bb;
101361 + };
101362 +
101363 + // 4. mix local entropy into the global entropy variable
101364 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101365 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101366 + return 0;
101367 +}
101368 +
101369 +static void start_unit_callback(void *gcc_data, void *user_data)
101370 +{
101371 + tree latent_entropy_type;
101372 +
101373 +#if BUILDING_GCC_VERSION >= 4007
101374 + seed = get_random_seed(false);
101375 +#else
101376 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101377 + seed *= seed;
101378 +#endif
101379 +
101380 + if (in_lto_p)
101381 + return;
101382 +
101383 + // extern volatile u64 latent_entropy
101384 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101385 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101386 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101387 +
101388 + TREE_STATIC(latent_entropy_decl) = 1;
101389 + TREE_PUBLIC(latent_entropy_decl) = 1;
101390 + TREE_USED(latent_entropy_decl) = 1;
101391 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101392 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101393 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101394 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101395 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101396 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101397 +// varpool_finalize_decl(latent_entropy_decl);
101398 +// varpool_mark_needed_node(latent_entropy_decl);
101399 +}
101400 +
101401 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101402 +{
101403 + const char * const plugin_name = plugin_info->base_name;
101404 + struct register_pass_info latent_entropy_pass_info = {
101405 + .pass = &latent_entropy_pass.pass,
101406 + .reference_pass_name = "optimized",
101407 + .ref_pass_instance_number = 1,
101408 + .pos_op = PASS_POS_INSERT_BEFORE
101409 + };
101410 +
101411 + if (!plugin_default_version_check(version, &gcc_version)) {
101412 + error(G_("incompatible gcc/plugin versions"));
101413 + return 1;
101414 + }
101415 +
101416 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101417 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101418 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101419 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101420 +
101421 + return 0;
101422 +}
101423 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101424 new file mode 100644
101425 index 0000000..b04803b
101426 --- /dev/null
101427 +++ b/tools/gcc/size_overflow_hash.data
101428 @@ -0,0 +1,6350 @@
101429 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101430 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101431 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101432 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101433 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101434 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101435 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101436 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101437 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101438 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101439 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101440 +load_msg_95 load_msg 2 95 NULL
101441 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101442 +init_q_132 init_q 4 132 NULL
101443 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101444 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101445 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101446 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101447 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101448 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101449 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101450 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101451 +br_port_info_size_268 br_port_info_size 0 268 NULL
101452 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101453 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101454 +SYSC_connect_304 SYSC_connect 3 304 NULL
101455 +syslog_print_307 syslog_print 2 307 NULL
101456 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101457 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101458 +next_node_allowed_318 next_node_allowed 1 318 NULL
101459 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101460 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101461 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101462 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101463 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101464 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101465 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101466 +pidlist_resize_496 pidlist_resize 2 496 NULL
101467 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101468 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101469 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101470 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101471 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101472 +dle_count_543 dle_count 0 543 NULL
101473 +devres_alloc_551 devres_alloc 2 551 NULL
101474 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101475 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101476 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101477 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101478 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101479 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101480 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101481 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101482 +isp1760_register_628 isp1760_register 1-2 628 NULL
101483 +clone_split_bio_633 clone_split_bio 6 633 NULL
101484 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101485 +remap_to_cache_640 remap_to_cache 3 640 NULL
101486 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101487 +unlink_queued_645 unlink_queued 3-4 645 NULL
101488 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101489 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101490 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101491 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101492 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101493 +disk_max_parts_719 disk_max_parts 0 719 NULL
101494 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101495 +dvb_video_write_754 dvb_video_write 3 754 NULL
101496 +if_writecmd_815 if_writecmd 2 815 NULL
101497 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101498 +read_fifo_826 read_fifo 3 826 NULL
101499 +um_idi_read_850 um_idi_read 3 850 NULL
101500 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101501 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101502 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101503 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101504 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101505 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101506 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101507 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101508 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101509 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101510 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101511 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101512 +_do_truncate_1019 _do_truncate 2 1019 NULL
101513 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101514 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101515 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101516 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101517 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101518 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101519 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101520 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101521 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101522 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101523 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101524 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101525 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101526 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101527 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101528 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101529 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101530 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101531 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101532 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101533 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101534 +nested_get_page_1252 nested_get_page 2 1252 NULL
101535 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101536 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101537 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101538 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101539 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101540 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101541 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101542 +ffs_1322 ffs 0 1322 NULL
101543 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101544 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101545 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101546 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101547 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101548 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101549 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101550 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101551 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101552 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101553 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101554 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101555 +zone_page_state_1393 zone_page_state 0 1393 NULL
101556 +file_read_actor_1401 file_read_actor 4 1401 NULL
101557 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101558 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101559 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101560 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101561 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101562 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101563 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
101564 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
101565 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
101566 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
101567 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
101568 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
101569 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
101570 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
101571 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
101572 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
101573 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
101574 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
101575 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
101576 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
101577 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
101578 +rmap_add_1677 rmap_add 3 1677 NULL
101579 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
101580 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
101581 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
101582 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
101583 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
101584 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
101585 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
101586 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
101587 +cosa_write_1774 cosa_write 3 1774 NULL
101588 +update_macheader_1775 update_macheader 7 1775 NULL
101589 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
101590 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
101591 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
101592 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
101593 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
101594 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
101595 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
101596 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
101597 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
101598 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
101599 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
101600 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
101601 +read_swap_header_1957 read_swap_header 0 1957 NULL
101602 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
101603 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
101604 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
101605 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
101606 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
101607 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
101608 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
101609 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
101610 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
101611 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
101612 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
101613 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
101614 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
101615 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
101616 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
101617 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
101618 +audit_expand_2098 audit_expand 2 2098 NULL
101619 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
101620 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
101621 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
101622 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
101623 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
101624 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
101625 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
101626 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
101627 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
101628 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
101629 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
101630 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
101631 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
101632 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
101633 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
101634 +vhci_write_2224 vhci_write 3 2224 NULL
101635 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
101636 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
101637 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
101638 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
101639 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
101640 +do_update_counters_2259 do_update_counters 4 2259 NULL
101641 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
101642 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
101643 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
101644 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
101645 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
101646 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
101647 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
101648 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
101649 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
101650 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
101651 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
101652 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
101653 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
101654 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
101655 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
101656 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
101657 +raid1_size_2419 raid1_size 0-2 2419 NULL
101658 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
101659 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
101660 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
101661 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
101662 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
101663 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
101664 +update_pmkid_2481 update_pmkid 4 2481 NULL
101665 +wiphy_new_2482 wiphy_new 2 2482 NULL
101666 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
101667 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
101668 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
101669 +dm_write_2513 dm_write 3 2513 NULL
101670 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
101671 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
101672 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
101673 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
101674 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
101675 +slot_bytes_2609 slot_bytes 0 2609 NULL
101676 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
101677 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
101678 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
101679 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
101680 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
101681 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
101682 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
101683 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
101684 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
101685 +__next_cpu_2782 __next_cpu 1 2782 NULL
101686 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
101687 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
101688 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
101689 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
101690 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
101691 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
101692 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
101693 +mq_map_2871 mq_map 2 2871 NULL
101694 +nla_padlen_2883 nla_padlen 1 2883 NULL
101695 +cmm_write_2896 cmm_write 3 2896 NULL
101696 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
101697 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
101698 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
101699 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
101700 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
101701 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
101702 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
101703 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
101704 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
101705 +depth_write_3021 depth_write 3 3021 NULL
101706 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
101707 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
101708 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
101709 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
101710 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
101711 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
101712 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
101713 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
101714 +free_coherent_3082 free_coherent 4-2 3082 NULL
101715 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
101716 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
101717 +rb_alloc_3102 rb_alloc 1 3102 NULL
101718 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
101719 +print_time_3132 print_time 0 3132 NULL
101720 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
101721 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
101722 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
101723 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
101724 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
101725 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
101726 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
101727 +alloc_context_3194 alloc_context 1 3194 NULL
101728 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
101729 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
101730 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
101731 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
101732 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
101733 +key_key_read_3241 key_key_read 3 3241 NULL
101734 +number_3243 number 0 3243 NULL
101735 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
101736 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
101737 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
101738 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
101739 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
101740 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
101741 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
101742 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
101743 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
101744 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
101745 +scnprintf_3360 scnprintf 0-2 3360 NULL
101746 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
101747 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
101748 +send_stream_3397 send_stream 4 3397 NULL
101749 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
101750 +msix_map_region_3411 msix_map_region 3 3411 NULL
101751 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
101752 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
101753 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
101754 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
101755 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
101756 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
101757 +map_single_3449 map_single 0-2 3449 NULL
101758 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
101759 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
101760 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
101761 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
101762 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
101763 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
101764 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
101765 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
101766 +SyS_readv_3539 SyS_readv 3 3539 NULL
101767 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
101768 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
101769 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
101770 +evtchn_read_3569 evtchn_read 3 3569 NULL
101771 +vc_resize_3585 vc_resize 2-3 3585 NULL
101772 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
101773 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
101774 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
101775 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
101776 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
101777 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
101778 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
101779 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
101780 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
101781 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
101782 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
101783 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
101784 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
101785 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
101786 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
101787 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
101788 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
101789 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
101790 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
101791 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
101792 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
101793 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
101794 +get_fd_set_3866 get_fd_set 1 3866 NULL
101795 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
101796 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
101797 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
101798 +nvram_write_3894 nvram_write 3 3894 NULL
101799 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
101800 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
101801 +vcs_write_3910 vcs_write 3 3910 NULL
101802 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
101803 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
101804 +do_add_counters_3992 do_add_counters 3 3992 NULL
101805 +userspace_status_4004 userspace_status 4 4004 NULL
101806 +mei_write_4005 mei_write 3 4005 NULL nohasharray
101807 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
101808 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
101809 +mm_populate_4016 mm_populate 1 4016 NULL
101810 +blk_end_request_4024 blk_end_request 3 4024 NULL
101811 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
101812 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
101813 +read_file_queues_4078 read_file_queues 3 4078 NULL
101814 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
101815 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
101816 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
101817 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
101818 +tm6000_read_4151 tm6000_read 3 4151 NULL
101819 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
101820 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
101821 +get_alua_req_4166 get_alua_req 3 4166 NULL
101822 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
101823 +read_file_bool_4180 read_file_bool 3 4180 NULL
101824 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
101825 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
101826 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
101827 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
101828 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
101829 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
101830 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
101831 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
101832 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
101833 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
101834 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
101835 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
101836 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
101837 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
101838 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
101839 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
101840 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
101841 +memparse_4444 memparse 0 4444 NULL
101842 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
101843 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
101844 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
101845 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
101846 +set_link_security_4502 set_link_security 4 4502 NULL
101847 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
101848 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
101849 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
101850 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
101851 +tty_register_device_4544 tty_register_device 2 4544 NULL
101852 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
101853 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
101854 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
101855 +bch_alloc_4593 bch_alloc 1 4593 NULL
101856 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
101857 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
101858 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
101859 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
101860 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
101861 +kone_receive_4690 kone_receive 4 4690 NULL
101862 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
101863 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
101864 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
101865 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
101866 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
101867 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
101868 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
101869 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
101870 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
101871 +create_subvol_4791 create_subvol 4 4791 NULL
101872 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
101873 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
101874 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
101875 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
101876 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
101877 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
101878 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
101879 +sys_ipc_4889 sys_ipc 3 4889 NULL
101880 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
101881 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
101882 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
101883 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
101884 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
101885 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
101886 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
101887 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
101888 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
101889 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
101890 +do_mincore_5018 do_mincore 0-1 5018 NULL
101891 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
101892 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
101893 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
101894 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
101895 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
101896 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
101897 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
101898 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
101899 +sound_write_5102 sound_write 3 5102 NULL
101900 +clear_dirty_5105 clear_dirty 3 5105 NULL
101901 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
101902 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
101903 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
101904 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
101905 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
101906 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
101907 +skb_network_header_5203 skb_network_header 0 5203 NULL
101908 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
101909 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
101910 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
101911 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
101912 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
101913 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
101914 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
101915 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
101916 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
101917 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
101918 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
101919 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
101920 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
101921 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
101922 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
101923 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
101924 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
101925 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
101926 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
101927 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
101928 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
101929 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
101930 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
101931 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
101932 +tty_write_5494 tty_write 3 5494 NULL
101933 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
101934 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
101935 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
101936 +spidev_message_5518 spidev_message 3 5518 NULL
101937 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
101938 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
101939 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
101940 +le_readq_5557 le_readq 0 5557 NULL
101941 +inw_5558 inw 0 5558 NULL
101942 +fir16_create_5574 fir16_create 3 5574 NULL
101943 +bioset_create_5580 bioset_create 1 5580 NULL
101944 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
101945 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
101946 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
101947 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
101948 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
101949 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
101950 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
101951 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
101952 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
101953 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
101954 +get_arg_5694 get_arg 3 5694 NULL
101955 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
101956 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
101957 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
101958 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
101959 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
101960 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
101961 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
101962 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
101963 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
101964 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
101965 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
101966 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
101967 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
101968 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
101969 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
101970 +setup_req_5848 setup_req 3 5848 NULL
101971 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
101972 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
101973 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
101974 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
101975 +port_show_regs_5904 port_show_regs 3 5904 NULL
101976 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
101977 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
101978 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
101979 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
101980 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
101981 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
101982 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
101983 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
101984 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
101985 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
101986 +native_pte_val_5978 native_pte_val 0 5978 NULL
101987 +SyS_semop_5980 SyS_semop 3 5980 NULL
101988 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
101989 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
101990 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
101991 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
101992 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
101993 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
101994 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
101995 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
101996 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
101997 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
101998 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
101999 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102000 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102001 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102002 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102003 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102004 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102005 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102006 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102007 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102008 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102009 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102010 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102011 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102012 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102013 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102014 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102015 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102016 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102017 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102018 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102019 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102020 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102021 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102022 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102023 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102024 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102025 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102026 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102027 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102028 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102029 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102030 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102031 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102032 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102033 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102034 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102035 +mei_read_6507 mei_read 3 6507 NULL
102036 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102037 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102038 +wdm_read_6549 wdm_read 3 6549 NULL
102039 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102040 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102041 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102042 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102043 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102044 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102045 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102046 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102047 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102048 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102049 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102050 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102051 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102052 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102053 +mpeg_read_6708 mpeg_read 3 6708 NULL
102054 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102055 +video_proc_write_6724 video_proc_write 3 6724 NULL
102056 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102057 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102058 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102059 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102060 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102061 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102062 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102063 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102064 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102065 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102066 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102067 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102068 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102069 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102070 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102071 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102072 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102073 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102074 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102075 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102076 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102077 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102078 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102079 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102080 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102081 +request_key_async_6990 request_key_async 4 6990 NULL
102082 +tpl_write_6998 tpl_write 3 6998 NULL
102083 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102084 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102085 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102086 +wimax_msg_7030 wimax_msg 4 7030 NULL
102087 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102088 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102089 +event_enable_read_7074 event_enable_read 3 7074 NULL
102090 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102091 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102092 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102093 +check_header_7108 check_header 0 7108 NULL
102094 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102095 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102096 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102097 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102098 +get_param_h_7247 get_param_h 0 7247 NULL
102099 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102100 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102101 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102102 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102103 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102104 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102105 +mgmt_control_7349 mgmt_control 3 7349 NULL
102106 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102107 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102108 +hweight_long_7388 hweight_long 0-1 7388 NULL
102109 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102110 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102111 +readb_7401 readb 0 7401 NULL
102112 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102113 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102114 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102115 +numa_emulation_7466 numa_emulation 2 7466 NULL
102116 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102117 +garp_request_join_7471 garp_request_join 4 7471 NULL
102118 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102119 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102120 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102121 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102122 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102123 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102124 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102125 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102126 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102127 +groups_alloc_7614 groups_alloc 1 7614 NULL
102128 +sg_virt_7616 sg_virt 0 7616 NULL
102129 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102130 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102131 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102132 +dev_write_7708 dev_write 3 7708 NULL
102133 +unmap_region_7709 unmap_region 1 7709 NULL
102134 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102135 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102136 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102137 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102138 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102139 +ioread32be_7773 ioread32be 0 7773 NULL
102140 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102141 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102142 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102143 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102144 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102145 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102146 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102147 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102148 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102149 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102150 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102151 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102152 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102153 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102154 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102155 +sys_mbind_7990 sys_mbind 5 7990 NULL
102156 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102157 +vcs_read_8017 vcs_read 3 8017 NULL
102158 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102159 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102160 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102161 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102162 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102163 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102164 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102165 +venus_lookup_8121 venus_lookup 4 8121 NULL
102166 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102167 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102168 +ore_truncate_8181 ore_truncate 3 8181 NULL
102169 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102170 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102171 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102172 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102173 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102174 +play_iframe_8219 play_iframe 3 8219 NULL
102175 +create_log_8225 create_log 2 8225 NULL nohasharray
102176 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102177 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102178 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102179 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102180 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102181 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102182 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102183 +init_cdev_8274 init_cdev 1 8274 NULL
102184 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102185 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102186 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102187 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102188 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102189 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102190 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102191 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102192 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102193 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102194 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102195 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102196 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102197 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102198 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102199 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102200 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102201 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102202 +dev_config_8506 dev_config 3 8506 NULL
102203 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102204 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102205 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102206 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102207 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102208 +user_on_off_8552 user_on_off 2 8552 NULL
102209 +profile_remove_8556 profile_remove 3 8556 NULL
102210 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102211 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102212 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102213 +tower_write_8580 tower_write 3 8580 NULL
102214 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102215 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102216 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102217 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102218 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102219 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102220 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102221 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102222 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102223 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102224 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102225 +arcfb_write_8702 arcfb_write 3 8702 NULL
102226 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102227 +init_header_8703 init_header 0 8703 &i_size_read_8703
102228 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102229 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102230 +f_dupfd_8730 f_dupfd 1 8730 NULL
102231 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102232 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102233 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102234 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102235 +sys_prctl_8766 sys_prctl 4 8766 NULL
102236 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102237 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102238 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102239 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102240 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102241 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102242 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102243 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102244 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102245 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102246 +clear_bitset_8840 clear_bitset 2 8840 NULL
102247 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102248 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102249 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102250 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102251 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102252 +layout_commit_8926 layout_commit 3 8926 NULL
102253 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102254 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102255 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102256 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102257 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102258 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102259 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102260 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102261 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102262 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102263 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102264 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102265 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102266 +nla_put_9042 nla_put 3 9042 NULL
102267 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102268 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102269 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102270 +string_9080 string 0 9080 NULL
102271 +create_queues_9088 create_queues 2-3 9088 NULL
102272 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102273 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102274 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102275 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102276 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102277 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102278 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102279 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102280 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102281 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102282 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102283 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102284 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102285 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102286 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102287 +get_pfn_9207 get_pfn 1 9207 NULL
102288 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102289 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102290 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102291 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102292 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102293 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102294 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102295 +flakey_status_9274 flakey_status 5 9274 NULL
102296 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102297 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102298 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102299 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102300 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102301 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102302 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102303 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102304 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102305 +read_9397 read 3 9397 NULL
102306 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102307 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102308 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102309 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102310 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102311 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102312 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102313 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102314 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102315 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102316 +lp_write_9511 lp_write 3 9511 NULL
102317 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102318 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102319 +read_file_dma_9530 read_file_dma 3 9530 NULL
102320 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102321 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102322 +fw_node_create_9559 fw_node_create 2 9559 NULL
102323 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102324 +kobj_map_9566 kobj_map 2-3 9566 NULL
102325 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102326 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102327 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102328 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102329 +do_sync_9604 do_sync 1 9604 NULL
102330 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102331 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102332 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102333 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102334 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102335 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102336 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102337 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102338 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102339 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102340 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102341 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102342 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102343 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102344 +fnb_9703 fnb 2-3 9703 NULL
102345 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102346 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102347 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102348 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102349 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102350 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102351 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102352 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102353 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102354 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102355 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102356 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102357 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102358 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102359 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102360 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102361 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102362 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102363 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102364 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102365 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102366 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102367 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102368 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102369 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102370 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102371 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102372 +read_file_misc_9948 read_file_misc 3 9948 NULL
102373 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102374 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102375 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102376 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102377 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102378 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102379 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102380 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102381 +handle_request_10024 handle_request 9 10024 NULL
102382 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102383 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102384 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102385 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102386 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102387 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102388 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102389 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102390 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102391 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102392 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102393 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102394 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102395 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102396 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102397 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102398 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102399 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102400 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102401 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102402 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102403 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102404 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102405 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102406 +read_emulate_10310 read_emulate 2-4 10310 NULL
102407 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102408 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102409 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102410 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102411 +get_dump_page_10338 get_dump_page 1 10338 NULL
102412 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102413 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102414 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102415 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102416 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102417 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102418 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102419 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102420 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102421 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102422 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102423 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102424 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102425 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102426 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102427 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102428 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102429 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102430 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102431 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102432 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102433 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102434 +otp_read_10594 otp_read 2-4-5 10594 NULL
102435 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102436 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102437 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102438 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102439 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102440 +parport_write_10669 parport_write 0 10669 NULL
102441 +inl_10708 inl 0 10708 NULL nohasharray
102442 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102443 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102444 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102445 +spi_sync_10731 spi_sync 0 10731 NULL
102446 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102447 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102448 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102449 +sys_syslog_10746 sys_syslog 3 10746 NULL
102450 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102451 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102452 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102453 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102454 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102455 +sys_bind_10799 sys_bind 3 10799 NULL
102456 +compat_put_int_10828 compat_put_int 1 10828 NULL
102457 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102458 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102459 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102460 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102461 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102462 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102463 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102464 +get_scq_10897 get_scq 2 10897 NULL
102465 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102466 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102467 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102468 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102469 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102470 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102471 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102472 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102473 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102474 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102475 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102476 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102477 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102478 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102479 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102480 +count_argc_11083 count_argc 0 11083 NULL
102481 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102482 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102483 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102484 +page_offset_11120 page_offset 0 11120 NULL
102485 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102486 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102487 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102488 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102489 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102490 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102491 +__swab16p_11220 __swab16p 0 11220 NULL
102492 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102493 +mmap_region_11247 mmap_region 0-2 11247 NULL
102494 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102495 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102496 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102497 +cru_detect_11272 cru_detect 1 11272 NULL
102498 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102499 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102500 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102501 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102502 +next_segment_11330 next_segment 0-2-1 11330 NULL
102503 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102504 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102505 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102506 +sel_write_create_11353 sel_write_create 3 11353 NULL
102507 +handle_unit_11355 handle_unit 0-1 11355 NULL
102508 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102509 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102510 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102511 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102512 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102513 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102514 +str_to_user_11411 str_to_user 2 11411 NULL
102515 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102516 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102517 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102518 +trace_options_read_11419 trace_options_read 3 11419 NULL
102519 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102520 +prepare_image_11424 prepare_image 0 11424 NULL
102521 +vring_size_11426 vring_size 0-1-2 11426 NULL
102522 +bttv_read_11432 bttv_read 3 11432 NULL
102523 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102524 +swp_offset_11475 swp_offset 0 11475 NULL
102525 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102526 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102527 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102528 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102529 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102530 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102531 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102532 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102533 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102534 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102535 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102536 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102537 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102538 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102539 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102540 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102541 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102542 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102543 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102544 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102545 +split_11691 split 2 11691 NULL
102546 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102547 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102548 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102549 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102550 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102551 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102552 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102553 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102554 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102555 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102556 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102557 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102558 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102559 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102560 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102561 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102562 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102563 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
102564 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
102565 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
102566 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
102567 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
102568 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
102569 +atmel_read16_11981 atmel_read16 0 11981 NULL
102570 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
102571 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
102572 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
102573 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
102574 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
102575 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
102576 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
102577 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
102578 +set_powered_12129 set_powered 4 12129 NULL
102579 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
102580 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
102581 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
102582 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
102583 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
102584 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
102585 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
102586 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
102587 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
102588 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
102589 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
102590 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
102591 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
102592 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
102593 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
102594 +scaled_div_12201 scaled_div 1-2 12201 NULL
102595 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
102596 +receive_copy_12216 receive_copy 3 12216 NULL
102597 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
102598 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
102599 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
102600 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
102601 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
102602 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
102603 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
102604 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
102605 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
102606 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
102607 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
102608 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
102609 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
102610 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
102611 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
102612 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
102613 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
102614 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
102615 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
102616 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
102617 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
102618 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
102619 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
102620 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
102621 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
102622 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
102623 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
102624 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
102625 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
102626 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
102627 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
102628 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
102629 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
102630 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
102631 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
102632 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
102633 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
102634 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
102635 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
102636 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
102637 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
102638 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
102639 +wb_create_12651 wb_create 1 12651 NULL
102640 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
102641 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
102642 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
102643 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
102644 +ivtv_write_12721 ivtv_write 3 12721 NULL
102645 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
102646 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
102647 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
102648 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
102649 +listxattr_12769 listxattr 3 12769 NULL
102650 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
102651 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
102652 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
102653 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
102654 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
102655 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
102656 +readq_12825 readq 0 12825 NULL
102657 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
102658 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
102659 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
102660 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
102661 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
102662 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
102663 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
102664 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
102665 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
102666 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
102667 +bm_status_write_12964 bm_status_write 3 12964 NULL
102668 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
102669 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
102670 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
102671 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
102672 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
102673 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
102674 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
102675 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
102676 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
102677 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
102678 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
102679 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
102680 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
102681 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
102682 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
102683 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
102684 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
102685 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
102686 +blk_update_request_13146 blk_update_request 3 13146 NULL
102687 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
102688 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
102689 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
102690 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
102691 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
102692 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
102693 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
102694 +comedi_read_13199 comedi_read 3 13199 NULL
102695 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
102696 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
102697 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
102698 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
102699 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
102700 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
102701 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
102702 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
102703 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
102704 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
102705 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
102706 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
102707 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
102708 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
102709 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
102710 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
102711 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
102712 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
102713 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
102714 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
102715 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
102716 +cache_ctr_13364 cache_ctr 2 13364 NULL
102717 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
102718 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
102719 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
102720 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
102721 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
102722 +sky2_receive_13407 sky2_receive 2 13407 NULL
102723 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
102724 +keyring_read_13438 keyring_read 3 13438 NULL
102725 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
102726 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
102727 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
102728 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
102729 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
102730 +core_status_13515 core_status 4 13515 NULL
102731 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
102732 +bm_init_13529 bm_init 2 13529 NULL
102733 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
102734 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
102735 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
102736 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
102737 +sys_madvise_13569 sys_madvise 1 13569 NULL
102738 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
102739 +cache_write_13589 cache_write 3 13589 NULL
102740 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
102741 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
102742 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
102743 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
102744 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
102745 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
102746 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
102747 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
102748 +packet_snd_13634 packet_snd 3 13634 NULL
102749 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
102750 +cache_downcall_13666 cache_downcall 3 13666 NULL
102751 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
102752 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
102753 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
102754 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
102755 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
102756 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
102757 +random_read_13815 random_read 3 13815 NULL
102758 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
102759 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
102760 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
102761 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
102762 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
102763 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
102764 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
102765 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
102766 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
102767 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
102768 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
102769 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
102770 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
102771 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
102772 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
102773 +com90xx_found_13974 com90xx_found 3 13974 NULL
102774 +qcam_read_13977 qcam_read 3 13977 NULL
102775 +dsp_read_13980 dsp_read 2 13980 NULL
102776 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
102777 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
102778 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
102779 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
102780 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
102781 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
102782 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
102783 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
102784 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
102785 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
102786 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
102787 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
102788 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
102789 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
102790 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
102791 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
102792 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
102793 +em_canid_change_14150 em_canid_change 3 14150 NULL
102794 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
102795 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
102796 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
102797 +alloc_async_14208 alloc_async 1 14208 NULL
102798 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
102799 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
102800 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
102801 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
102802 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
102803 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
102804 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
102805 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
102806 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
102807 +rr_status_14293 rr_status 5 14293 NULL
102808 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
102809 +oo_objects_14319 oo_objects 0 14319 NULL
102810 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
102811 +scsi2int_14358 scsi2int 0 14358 NULL
102812 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
102813 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
102814 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
102815 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
102816 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
102817 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
102818 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
102819 +block_size_14443 block_size 0 14443 NULL
102820 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
102821 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
102822 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
102823 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
102824 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
102825 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
102826 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
102827 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
102828 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
102829 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
102830 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
102831 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
102832 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
102833 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
102834 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
102835 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
102836 +dbJoin_14644 dbJoin 0 14644 NULL
102837 +profile_replace_14652 profile_replace 3 14652 NULL
102838 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
102839 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
102840 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
102841 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
102842 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
102843 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
102844 +get_bio_block_14714 get_bio_block 0 14714 NULL
102845 +vfd_write_14717 vfd_write 3 14717 NULL
102846 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
102847 +raid1_resize_14740 raid1_resize 2 14740 NULL
102848 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
102849 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
102850 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
102851 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
102852 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
102853 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
102854 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
102855 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
102856 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
102857 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
102858 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
102859 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
102860 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
102861 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
102862 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
102863 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
102864 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
102865 +unifi_read_14899 unifi_read 3 14899 NULL
102866 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
102867 +krealloc_14908 krealloc 2 14908 NULL
102868 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
102869 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
102870 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
102871 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
102872 +queue_cnt_14951 queue_cnt 0 14951 NULL
102873 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
102874 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
102875 +setkey_14987 setkey 3 14987 NULL nohasharray
102876 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
102877 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
102878 +vmap_15025 vmap 2 15025 NULL
102879 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
102880 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
102881 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
102882 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
102883 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
102884 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
102885 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
102886 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
102887 +start_port_15124 start_port 0 15124 NULL
102888 +memchr_15126 memchr 0 15126 NULL
102889 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
102890 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
102891 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
102892 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
102893 +reserve_resources_15194 reserve_resources 3 15194 NULL
102894 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
102895 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
102896 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
102897 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
102898 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
102899 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
102900 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
102901 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
102902 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
102903 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
102904 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
102905 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
102906 +ioread16_15342 ioread16 0 15342 NULL
102907 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
102908 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
102909 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
102910 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
102911 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
102912 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
102913 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
102914 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
102915 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
102916 +get_modalias_15406 get_modalias 2 15406 NULL
102917 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
102918 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
102919 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
102920 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
102921 +memweight_15450 memweight 2 15450 NULL
102922 +vmalloc_15464 vmalloc 1 15464 NULL
102923 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
102924 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
102925 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
102926 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
102927 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
102928 +persistent_status_15574 persistent_status 4 15574 NULL
102929 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
102930 +vme_user_write_15587 vme_user_write 3 15587 NULL
102931 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
102932 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
102933 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
102934 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
102935 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
102936 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
102937 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
102938 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
102939 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
102940 +fs_path_add_15648 fs_path_add 3 15648 NULL
102941 +xsd_read_15653 xsd_read 3 15653 NULL
102942 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
102943 +unix_bind_15668 unix_bind 3 15668 NULL
102944 +dm_read_15674 dm_read 3 15674 NULL
102945 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
102946 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
102947 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
102948 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
102949 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
102950 +do_test_15766 do_test 1 15766 NULL
102951 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
102952 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
102953 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
102954 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
102955 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
102956 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
102957 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
102958 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
102959 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
102960 +table_size_15851 table_size 0-1-2 15851 NULL
102961 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
102962 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
102963 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
102964 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
102965 +native_read_msr_15905 native_read_msr 0 15905 NULL
102966 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
102967 +power_read_15939 power_read 3 15939 NULL
102968 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
102969 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
102970 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
102971 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
102972 +frame_alloc_15981 frame_alloc 4 15981 NULL
102973 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
102974 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
102975 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
102976 +got_frame_16028 got_frame 2 16028 NULL
102977 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
102978 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
102979 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
102980 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
102981 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
102982 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
102983 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
102984 +fsm_init_16134 fsm_init 2 16134 NULL
102985 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
102986 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
102987 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
102988 +mapping_level_16188 mapping_level 2 16188 NULL
102989 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
102990 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
102991 +create_table_16213 create_table 2 16213 NULL
102992 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
102993 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
102994 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
102995 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
102996 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
102997 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
102998 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
102999 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103000 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103001 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103002 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103003 +account_16283 account 0-2-4 16283 NULL nohasharray
103004 +mirror_status_16283 mirror_status 5 16283 &account_16283
103005 +retry_instruction_16285 retry_instruction 2 16285 NULL
103006 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103007 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103008 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103009 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103010 +wb_map_16301 wb_map 2 16301 NULL
103011 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103012 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103013 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103014 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103015 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103016 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103017 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103018 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103019 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103020 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103021 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103022 +raid10_resize_16537 raid10_resize 2 16537 NULL
103023 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103024 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103025 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103026 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103027 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103028 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103029 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103030 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103031 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103032 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103033 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103034 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103035 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103036 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103037 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103038 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103039 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103040 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103041 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103042 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103043 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103044 +st_write_16874 st_write 3 16874 NULL
103045 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103046 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103047 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103048 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103049 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103050 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103051 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103052 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103053 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103054 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103055 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103056 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103057 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103058 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103059 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103060 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103061 +mac_address_string_17091 mac_address_string 0 17091 NULL
103062 +entry_length_17093 entry_length 0 17093 NULL
103063 +sys_preadv_17100 sys_preadv 3 17100 NULL
103064 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103065 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103066 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103067 +sep_read_17161 sep_read 3 17161 NULL
103068 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103069 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103070 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103071 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103072 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103073 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103074 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103075 +to_oblock_17254 to_oblock 0-1 17254 NULL
103076 +unpack_value_17259 unpack_value 1 17259 NULL
103077 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103078 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103079 +alloc_ep_17269 alloc_ep 1 17269 NULL
103080 +pg_read_17276 pg_read 3 17276 NULL
103081 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103082 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103083 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103084 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103085 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103086 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103087 +skb_pad_17302 skb_pad 2 17302 NULL
103088 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103089 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103090 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103091 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103092 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103093 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103094 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103095 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103096 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103097 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103098 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103099 +compat_cmd_17465 compat_cmd 2 17465 NULL
103100 +probe_bios_17467 probe_bios 1 17467 NULL
103101 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103102 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103103 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103104 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103105 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103106 +copy_from_user_17559 copy_from_user 3 17559 NULL
103107 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103108 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103109 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103110 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103111 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103112 +osst_execute_17607 osst_execute 7-6 17607 NULL
103113 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103114 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103115 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103116 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103117 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103118 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103119 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103120 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103121 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103122 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103123 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103124 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103125 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103126 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103127 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103128 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103129 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103130 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103131 +perf_clock_17787 perf_clock 0 17787 NULL
103132 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103133 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103134 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103135 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103136 +count_leafs_17842 count_leafs 0 17842 NULL
103137 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103138 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103139 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103140 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103141 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103142 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103143 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103144 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103145 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103146 +recover_head_17904 recover_head 3 17904 NULL
103147 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103148 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103149 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103150 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103151 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103152 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103153 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103154 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103155 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103156 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103157 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103158 +fill_read_18019 fill_read 0 18019 NULL
103159 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103160 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103161 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103162 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103163 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103164 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103165 +packet_came_18072 packet_came 3 18072 NULL
103166 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103167 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103168 +get_vm_area_18080 get_vm_area 1 18080 NULL
103169 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103170 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103171 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103172 +svc_getnl_18120 svc_getnl 0 18120 NULL
103173 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103174 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103175 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103176 +_has_tag_18169 _has_tag 2 18169 NULL
103177 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103178 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103179 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103180 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103181 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103182 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103183 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103184 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103185 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103186 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103187 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103188 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103189 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103190 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103191 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103192 +um_idi_write_18293 um_idi_write 3 18293 NULL
103193 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103194 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103195 +vga_r_18310 vga_r 0 18310 NULL
103196 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103197 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103198 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103199 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103200 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103201 +ep_io_18367 ep_io 0 18367 NULL
103202 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103203 +ci_role_write_18388 ci_role_write 3 18388 NULL
103204 +__video_register_device_18399 __video_register_device 3 18399 NULL
103205 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103206 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103207 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103208 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103209 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103210 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103211 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103212 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103213 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103214 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103215 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103216 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103217 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103218 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103219 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103220 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103221 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103222 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103223 +debug_output_18575 debug_output 3 18575 NULL
103224 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103225 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103226 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103227 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103228 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103229 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103230 +from_buffer_18625 from_buffer 3 18625 NULL
103231 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103232 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103233 +unmap_page_18665 unmap_page 2-3 18665 NULL
103234 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103235 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103236 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103237 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103238 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103239 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103240 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103241 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103242 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103243 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103244 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103245 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103246 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103247 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103248 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103249 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103250 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103251 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103252 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103253 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103254 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103255 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103256 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103257 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103258 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103259 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103260 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103261 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103262 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103263 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103264 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103265 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103266 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103267 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103268 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103269 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103270 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103271 +huge_page_size_19008 huge_page_size 0 19008 NULL
103272 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103273 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103274 +revalidate_19043 revalidate 2 19043 NULL
103275 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103276 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103277 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103278 +msix_map_region_19072 msix_map_region 2 19072 NULL
103279 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103280 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103281 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103282 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103283 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103284 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103285 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103286 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103287 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103288 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103289 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103290 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103291 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103292 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103293 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103294 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103295 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103296 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103297 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103298 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103299 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103300 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103301 +qc_capture_19298 qc_capture 3 19298 NULL
103302 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103303 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103304 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103305 +debug_read_19322 debug_read 3 19322 NULL
103306 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103307 +closure_sub_19359 closure_sub 2 19359 NULL
103308 +read_zero_19366 read_zero 3 19366 NULL
103309 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103310 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103311 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103312 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103313 +__phys_addr_19434 __phys_addr 0 19434 NULL
103314 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103315 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103316 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103317 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103318 +sky2_read16_19475 sky2_read16 0 19475 NULL
103319 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103320 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103321 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103322 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103323 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103324 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103325 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103326 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103327 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103328 +nfsd_read_19568 nfsd_read 5 19568 NULL
103329 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103330 +bm_status_read_19583 bm_status_read 3 19583 NULL
103331 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103332 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103333 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103334 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103335 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103336 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103337 +bio_detain_19690 bio_detain 2 19690 NULL
103338 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103339 +read_reg_19723 read_reg 0 19723 NULL
103340 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103341 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103342 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103343 +p9_client_read_19750 p9_client_read 5 19750 NULL
103344 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103345 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103346 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103347 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103348 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103349 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103350 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103351 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103352 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103353 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103354 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103355 +__nla_put_19857 __nla_put 3 19857 NULL
103356 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103357 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103358 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103359 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103360 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103361 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103362 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103363 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103364 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103365 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103366 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103367 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103368 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103369 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103370 +team_options_register_20091 team_options_register 3 20091 NULL
103371 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103372 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103373 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103374 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103375 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103376 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103377 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103378 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103379 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103380 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103381 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103382 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103383 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103384 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103385 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103386 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103387 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103388 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103389 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103390 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103391 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103392 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103393 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103394 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103395 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103396 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103397 +read_buf_20469 read_buf 2 20469 NULL
103398 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103399 +fast_user_write_20494 fast_user_write 5 20494 NULL
103400 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103401 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103402 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103403 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103404 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103405 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103406 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103407 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103408 +venus_create_20555 venus_create 4 20555 NULL
103409 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103410 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103411 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103412 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103413 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103414 +lirc_write_20604 lirc_write 3 20604 NULL
103415 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103416 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103417 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103418 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103419 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103420 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103421 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103422 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103423 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103424 +cpumask_size_20683 cpumask_size 0 20683 NULL
103425 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103426 +gru_vtop_20689 gru_vtop 2 20689 NULL
103427 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103428 +__maestro_read_20700 __maestro_read 0 20700 NULL
103429 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103430 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103431 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103432 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103433 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103434 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103435 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103436 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103437 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103438 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103439 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103440 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103441 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103442 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103443 +sys_sendto_20809 sys_sendto 6 20809 NULL
103444 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103445 +strndup_user_20819 strndup_user 2 20819 NULL
103446 +calc_layout_20829 calc_layout 3 20829 NULL
103447 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103448 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103449 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103450 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103451 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103452 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103453 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103454 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103455 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103456 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103457 +htable_bits_20933 htable_bits 0 20933 NULL
103458 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103459 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103460 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103461 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103462 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103463 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103464 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103465 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103466 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103467 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103468 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103469 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103470 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103471 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103472 +multipath_status_21094 multipath_status 5 21094 NULL
103473 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103474 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103475 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103476 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103477 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103478 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103479 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103480 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103481 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103482 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103483 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103484 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103485 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103486 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103487 +input_ff_create_21240 input_ff_create 2 21240 NULL
103488 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103489 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103490 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103491 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103492 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103493 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103494 +add_res_range_21310 add_res_range 4 21310 NULL
103495 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103496 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103497 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103498 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103499 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103500 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103501 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103502 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103503 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103504 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103505 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103506 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103507 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103508 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103509 +concat_writev_21451 concat_writev 3 21451 NULL
103510 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103511 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103512 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103513 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103514 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103515 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103516 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103517 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103518 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103519 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103520 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103521 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103522 +validate_nnode_21638 validate_nnode 0 21638 NULL
103523 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103524 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103525 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103526 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103527 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103528 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103529 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103530 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103531 +vm_brk_21739 vm_brk 1 21739 NULL
103532 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103533 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103534 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103535 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103536 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103537 +min_odd_21802 min_odd 0 21802 NULL
103538 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103539 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103540 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103541 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103542 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103543 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103544 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103545 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103546 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103547 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103548 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103549 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103550 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103551 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103552 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103553 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103554 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103555 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103556 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103557 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103558 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103559 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103560 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103561 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103562 +write_opcode_22082 write_opcode 2 22082 NULL
103563 +mem_rw_22085 mem_rw 3 22085 NULL
103564 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
103565 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
103566 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
103567 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
103568 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
103569 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
103570 +compat_insn_22142 compat_insn 2 22142 NULL
103571 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
103572 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
103573 +fls_22210 fls 0 22210 NULL
103574 +mem_write_22232 mem_write 3 22232 NULL
103575 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
103576 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
103577 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
103578 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
103579 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
103580 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
103581 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
103582 +extend_brk_22301 extend_brk 0 22301 NULL
103583 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
103584 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
103585 +get_segment_base_22324 get_segment_base 0 22324 NULL
103586 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
103587 +atomic_read_22342 atomic_read 0 22342 NULL
103588 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
103589 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
103590 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
103591 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
103592 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
103593 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
103594 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
103595 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
103596 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
103597 +zoran_write_22404 zoran_write 3 22404 NULL
103598 +queue_reply_22416 queue_reply 3 22416 NULL
103599 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
103600 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
103601 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
103602 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
103603 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
103604 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
103605 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
103606 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
103607 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
103608 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
103609 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
103610 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
103611 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
103612 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
103613 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
103614 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
103615 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
103616 +snapshot_read_22601 snapshot_read 3 22601 NULL
103617 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
103618 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
103619 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
103620 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
103621 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
103622 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
103623 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
103624 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
103625 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
103626 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
103627 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
103628 +map_22700 map 2 22700 NULL
103629 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
103630 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
103631 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
103632 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
103633 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
103634 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
103635 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
103636 +print_frame_22769 print_frame 0 22769 NULL
103637 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
103638 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
103639 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
103640 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
103641 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
103642 +create_attr_set_22861 create_attr_set 1 22861 NULL
103643 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
103644 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
103645 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
103646 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
103647 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
103648 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
103649 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
103650 +vme_get_size_22964 vme_get_size 0 22964 NULL
103651 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
103652 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
103653 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
103654 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
103655 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
103656 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
103657 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
103658 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
103659 +st_status_23032 st_status 5 23032 NULL
103660 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
103661 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
103662 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
103663 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
103664 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
103665 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
103666 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
103667 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
103668 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
103669 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
103670 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
103671 +fls_long_23096 fls_long 0 23096 NULL
103672 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
103673 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
103674 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
103675 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
103676 +__clear_user_23118 __clear_user 0 23118 NULL
103677 +dm_write_async_23120 dm_write_async 3 23120 NULL
103678 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
103679 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
103680 +read_file_ani_23161 read_file_ani 3 23161 NULL
103681 +ioremap_23172 ioremap 1-2 23172 NULL
103682 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
103683 +usblp_write_23178 usblp_write 3 23178 NULL
103684 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
103685 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
103686 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
103687 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
103688 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
103689 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
103690 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
103691 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
103692 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
103693 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
103694 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
103695 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
103696 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
103697 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
103698 +doc_probe_23285 doc_probe 1 23285 NULL
103699 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
103700 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
103701 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
103702 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
103703 +page_readlink_23346 page_readlink 3 23346 NULL
103704 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
103705 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
103706 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
103707 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
103708 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
103709 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
103710 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
103711 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
103712 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
103713 +event_filter_read_23494 event_filter_read 3 23494 NULL
103714 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
103715 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
103716 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
103717 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
103718 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
103719 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
103720 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
103721 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
103722 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
103723 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
103724 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
103725 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
103726 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
103727 +sInW_23663 sInW 0 23663 NULL
103728 +SyS_connect_23669 SyS_connect 3 23669 NULL
103729 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
103730 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
103731 +cx18_read_23699 cx18_read 3 23699 NULL
103732 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
103733 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
103734 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
103735 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
103736 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
103737 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
103738 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
103739 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
103740 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
103741 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
103742 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
103743 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
103744 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
103745 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
103746 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
103747 +p54_init_common_23850 p54_init_common 1 23850 NULL
103748 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
103749 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
103750 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
103751 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
103752 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
103753 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
103754 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
103755 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
103756 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
103757 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
103758 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
103759 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
103760 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
103761 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
103762 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
103763 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
103764 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
103765 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
103766 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
103767 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
103768 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
103769 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
103770 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
103771 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
103772 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
103773 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
103774 +mpu401_read_24126 mpu401_read 3 24126 NULL
103775 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
103776 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
103777 +set_discard_24162 set_discard 2 24162 NULL
103778 +adu_read_24177 adu_read 3 24177 NULL
103779 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
103780 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
103781 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
103782 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
103783 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
103784 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
103785 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
103786 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
103787 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
103788 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
103789 +thin_status_24278 thin_status 5 24278 NULL
103790 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
103791 +msg_size_24288 msg_size 0 24288 NULL
103792 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
103793 +map_page_24298 map_page 3-4 24298 NULL
103794 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
103795 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
103796 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
103797 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
103798 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
103799 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
103800 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
103801 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
103802 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
103803 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
103804 +igetword_24373 igetword 0 24373 NULL
103805 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
103806 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
103807 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
103808 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
103809 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
103810 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
103811 +smk_user_access_24440 smk_user_access 3 24440 NULL
103812 +page_address_24444 page_address 0 24444 NULL
103813 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
103814 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
103815 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
103816 +pd_video_read_24510 pd_video_read 3 24510 NULL
103817 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
103818 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
103819 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
103820 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
103821 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
103822 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
103823 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
103824 +count_preds_24600 count_preds 0 24600 NULL
103825 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
103826 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
103827 +context_alloc_24645 context_alloc 3 24645 NULL
103828 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
103829 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
103830 +read_fs_24717 read_fs 0 24717 NULL
103831 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
103832 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
103833 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
103834 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
103835 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
103836 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
103837 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
103838 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
103839 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
103840 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
103841 +cache_read_24790 cache_read 3 24790 NULL
103842 +unpack_str_24798 unpack_str 0 24798 NULL
103843 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
103844 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
103845 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
103846 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
103847 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
103848 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
103849 +setup_buffering_24872 setup_buffering 3 24872 NULL
103850 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
103851 +queues_read_24877 queues_read 3 24877 NULL nohasharray
103852 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
103853 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
103854 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
103855 +next_token_24929 next_token 0 24929 NULL
103856 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
103857 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
103858 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
103859 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
103860 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
103861 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
103862 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
103863 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
103864 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
103865 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
103866 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
103867 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
103868 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
103869 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
103870 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
103871 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
103872 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
103873 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
103874 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
103875 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
103876 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
103877 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
103878 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
103879 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
103880 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
103881 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
103882 +stripe_status_25259 stripe_status 5 25259 NULL
103883 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
103884 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
103885 +vfs_writev_25278 vfs_writev 3 25278 NULL
103886 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
103887 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
103888 +help_25316 help 5 25316 NULL nohasharray
103889 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
103890 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
103891 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
103892 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
103893 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
103894 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
103895 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
103896 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
103897 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
103898 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
103899 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
103900 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
103901 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
103902 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
103903 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
103904 +sb_permission_25523 sb_permission 0 25523 NULL
103905 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
103906 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
103907 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
103908 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
103909 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
103910 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
103911 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
103912 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
103913 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
103914 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
103915 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
103916 +__direct_map_25647 __direct_map 5-6 25647 NULL
103917 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
103918 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
103919 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
103920 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
103921 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
103922 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
103923 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
103924 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
103925 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
103926 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
103927 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
103928 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
103929 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
103930 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
103931 +sg_read_25799 sg_read 3 25799 NULL
103932 +system_enable_read_25815 system_enable_read 3 25815 NULL
103933 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
103934 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
103935 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
103936 +parport_read_25855 parport_read 0 25855 NULL
103937 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
103938 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
103939 +key_attr_size_25865 key_attr_size 0 25865 NULL
103940 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
103941 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
103942 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
103943 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
103944 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
103945 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
103946 +rcname_read_25919 rcname_read 3 25919 NULL
103947 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
103948 +key_flags_read_25931 key_flags_read 3 25931 NULL
103949 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
103950 +flush_25957 flush 2 25957 NULL
103951 +video_register_device_25971 video_register_device 3 25971 NULL
103952 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
103953 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
103954 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
103955 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
103956 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
103957 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
103958 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
103959 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
103960 +tun_do_read_26047 tun_do_read 5 26047 NULL
103961 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
103962 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
103963 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
103964 +skb_cow_26138 skb_cow 2 26138 NULL
103965 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
103966 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
103967 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
103968 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
103969 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
103970 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
103971 +disk_devt_26180 disk_devt 0 26180 NULL
103972 +get_registers_26187 get_registers 3 26187 NULL
103973 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
103974 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
103975 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
103976 +mce_write_26201 mce_write 3 26201 NULL
103977 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
103978 +bio_split_26235 bio_split 2 26235 NULL
103979 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
103980 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
103981 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
103982 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
103983 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
103984 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
103985 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
103986 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
103987 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
103988 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
103989 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
103990 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
103991 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
103992 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
103993 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
103994 +read_vmcore_26501 read_vmcore 3 26501 NULL
103995 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
103996 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
103997 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
103998 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
103999 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104000 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104001 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104002 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104003 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104004 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104005 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104006 +pack_value_26625 pack_value 1 26625 NULL
104007 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104008 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104009 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104010 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104011 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104012 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104013 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104014 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104015 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104016 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104017 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104018 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104019 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104020 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104021 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104022 +smk_write_load_26829 smk_write_load 3 26829 NULL
104023 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104024 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104025 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104026 +scnprint_id_26842 scnprint_id 3 26842 NULL
104027 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104028 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104029 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104030 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104031 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104032 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104033 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104034 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104035 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104036 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104037 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104038 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104039 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104040 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104041 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104042 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104043 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104044 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104045 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104046 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104047 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104048 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104049 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104050 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104051 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104052 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104053 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104054 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104055 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104056 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104057 +pms_capture_27142 pms_capture 4 27142 NULL
104058 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104059 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104060 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104061 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104062 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104063 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104064 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104065 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104066 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104067 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104068 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104069 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104070 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104071 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104072 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104073 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104074 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104075 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104076 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104077 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104078 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104079 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104080 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104081 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104082 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104083 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104084 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104085 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104086 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104087 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104088 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104089 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104090 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104091 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104092 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104093 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104094 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104095 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104096 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104097 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104098 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104099 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104100 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104101 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104102 +qword_get_27670 qword_get 0 27670 NULL
104103 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104104 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104105 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104106 +evm_write_key_27715 evm_write_key 3 27715 NULL
104107 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104108 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104109 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104110 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104111 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104112 +kcalloc_27770 kcalloc 1-2 27770 NULL
104113 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104114 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104115 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104116 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104117 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104118 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104119 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104120 +read_profile_27859 read_profile 3 27859 NULL
104121 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104122 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104123 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104124 +gluebi_write_27905 gluebi_write 3 27905 NULL
104125 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104126 +bm_find_next_27929 bm_find_next 2 27929 NULL
104127 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104128 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104129 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104130 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104131 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104132 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104133 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104134 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104135 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104136 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104137 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104138 +pool_status_28055 pool_status 5 28055 NULL
104139 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104140 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104141 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104142 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104143 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104144 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104145 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104146 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104147 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104148 +video_read_28148 video_read 3 28148 NULL
104149 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104150 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104151 +vread_28173 vread 0 28173 NULL
104152 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104153 +d_path_28198 d_path 0 28198 NULL
104154 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104155 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104156 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104157 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104158 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104159 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104160 +usemap_size_28281 usemap_size 0 28281 NULL
104161 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104162 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104163 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104164 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104165 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104166 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104167 +snapshot_write_28351 snapshot_write 3 28351 NULL
104168 +sys_writev_28384 sys_writev 3 28384 NULL
104169 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104170 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104171 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104172 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104173 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104174 +__split_large_page_28429 __split_large_page 2 28429 NULL
104175 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104176 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104177 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104178 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104179 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104180 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104181 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104182 +max_response_pages_28492 max_response_pages 0 28492 NULL
104183 +clear_discard_28494 clear_discard 2 28494 NULL
104184 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104185 +__next_node_28521 __next_node 1 28521 NULL
104186 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104187 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104188 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104189 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104190 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104191 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104192 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104193 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104194 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104195 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104196 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104197 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104198 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104199 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104200 +_set_range_28627 _set_range 3 28627 NULL
104201 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104202 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104203 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104204 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104205 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104206 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104207 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104208 +spi_execute_28736 spi_execute 5 28736 NULL
104209 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104210 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104211 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104212 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104213 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104214 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104215 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104216 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104217 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104218 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104219 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104220 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104221 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104222 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104223 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104224 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104225 +to_cblock_28899 to_cblock 0-1 28899 NULL
104226 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104227 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104228 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104229 +push_rx_28939 push_rx 3 28939 NULL
104230 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104231 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104232 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104233 +bin_uuid_28999 bin_uuid 3 28999 NULL
104234 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104235 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104236 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104237 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104238 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104239 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104240 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104241 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104242 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104243 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104244 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104245 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104246 +snprintf_29125 snprintf 0 29125 NULL
104247 +iov_shorten_29130 iov_shorten 0 29130 NULL
104248 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104249 +reshape_ring_29147 reshape_ring 2 29147 NULL
104250 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104251 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104252 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104253 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104254 +__mm_populate_29204 __mm_populate 1 29204 NULL
104255 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104256 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104257 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104258 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104259 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104260 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104261 +recover_peb_29238 recover_peb 6-7 29238 NULL
104262 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104263 +block_div_29268 block_div 0-1-2 29268 NULL
104264 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104265 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104266 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104267 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104268 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104269 +tun_put_user_29337 tun_put_user 5 29337 NULL
104270 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104271 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104272 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104273 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104274 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104275 +mempool_create_29437 mempool_create 1 29437 NULL
104276 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104277 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104278 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104279 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104280 +do_register_entry_29478 do_register_entry 4 29478 NULL
104281 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104282 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104283 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104284 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104285 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104286 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104287 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104288 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104289 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104290 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104291 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104292 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104293 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104294 +slots_per_page_29601 slots_per_page 0 29601 NULL
104295 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104296 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104297 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104298 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104299 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104300 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104301 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104302 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104303 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104304 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104305 +probes_write_29711 probes_write 3 29711 NULL
104306 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104307 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104308 +std_nic_write_29752 std_nic_write 3 29752 NULL
104309 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104310 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104311 +dbAlloc_29794 dbAlloc 0 29794 NULL
104312 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104313 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104314 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104315 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104316 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104317 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104318 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104319 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104320 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104321 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104322 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104323 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104324 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104325 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104326 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104327 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104328 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104329 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104330 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104331 +drp_wmove_30043 drp_wmove 4 30043 NULL
104332 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104333 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104334 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104335 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104336 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104337 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104338 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104339 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104340 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104341 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104342 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104343 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104344 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104345 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104346 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104347 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104348 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104349 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104350 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104351 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104352 +compat_readv_30273 compat_readv 3 30273 NULL
104353 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104354 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104355 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104356 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104357 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104358 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104359 +resource_from_user_30341 resource_from_user 3 30341 NULL
104360 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104361 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104362 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104363 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104364 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104365 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104366 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104367 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104368 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104369 +mq_create_30425 mq_create 1 30425 NULL
104370 +enable_write_30456 enable_write 3 30456 NULL
104371 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104372 +urandom_read_30462 urandom_read 3 30462 NULL
104373 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104374 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104375 +write_head_30481 write_head 4 30481 NULL
104376 +adu_write_30487 adu_write 3 30487 NULL
104377 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104378 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104379 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104380 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104381 +set_le_30581 set_le 4 30581 NULL
104382 +from_cblock_30582 from_cblock 0-1 30582 NULL
104383 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104384 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104385 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104386 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104387 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104388 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104389 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104390 +agp_remap_30665 agp_remap 2 30665 NULL
104391 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104392 +il_free_pages_30692 il_free_pages 2 30692 NULL
104393 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104394 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104395 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104396 +snapshot_status_30744 snapshot_status 5 30744 NULL
104397 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104398 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104399 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104400 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104401 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104402 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104403 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104404 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104405 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104406 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104407 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104408 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104409 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104410 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104411 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104412 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104413 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104414 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104415 +sys_mincore_31079 sys_mincore 1 31079 NULL
104416 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104417 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104418 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104419 +depth_read_31112 depth_read 3 31112 NULL
104420 +ssb_read16_31139 ssb_read16 0 31139 NULL
104421 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104422 +size_inside_page_31141 size_inside_page 0 31141 NULL
104423 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104424 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104425 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104426 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104427 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104428 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104429 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104430 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104431 +__read_reg_31216 __read_reg 0 31216 NULL
104432 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104433 +cyy_readb_31240 cyy_readb 0 31240 NULL
104434 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104435 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104436 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104437 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104438 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104439 +command_file_write_31318 command_file_write 3 31318 NULL
104440 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104441 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104442 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104443 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104444 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104445 +inb_31388 inb 0 31388 NULL
104446 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104447 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104448 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104449 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104450 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104451 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104452 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104453 +do_fcntl_31468 do_fcntl 3 31468 NULL
104454 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104455 +alg_setkey_31485 alg_setkey 3 31485 NULL
104456 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104457 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104458 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104459 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104460 +hidraw_write_31536 hidraw_write 3 31536 NULL
104461 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104462 +usbvision_read_31555 usbvision_read 3 31555 NULL
104463 +normalize_31566 normalize 0-1-2 31566 NULL
104464 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104465 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104466 +osst_write_31581 osst_write 3 31581 NULL
104467 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104468 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104469 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104470 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104471 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104472 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104473 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104474 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104475 +__lgread_31668 __lgread 4 31668 NULL
104476 +symbol_string_31670 symbol_string 0 31670 NULL
104477 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104478 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104479 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104480 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104481 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104482 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104483 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104484 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104485 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104486 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104487 +muldiv64_31743 muldiv64 2-3 31743 NULL
104488 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104489 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104490 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104491 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104492 +get_count_order_31800 get_count_order 0 31800 NULL
104493 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104494 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104495 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104496 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104497 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104498 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104499 +xattr_permission_31907 xattr_permission 0 31907 NULL
104500 +new_dir_31919 new_dir 3 31919 NULL
104501 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104502 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104503 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104504 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104505 +vb2_write_31948 vb2_write 3 31948 NULL
104506 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104507 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104508 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104509 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104510 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104511 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104512 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104513 +calc_hmac_32010 calc_hmac 3 32010 NULL
104514 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104515 +aead_len_32021 aead_len 0 32021 NULL
104516 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104517 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104518 +stk_read_32038 stk_read 3 32038 NULL
104519 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104520 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104521 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104522 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104523 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104524 +bio_alloc_32095 bio_alloc 2 32095 NULL
104525 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104526 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104527 +disk_status_32120 disk_status 4 32120 NULL
104528 +venus_link_32165 venus_link 5 32165 NULL
104529 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104530 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104531 +load_header_32183 load_header 0 32183 NULL
104532 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104533 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104534 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104535 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104536 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104537 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104538 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104539 +hex_string_32310 hex_string 0 32310 NULL
104540 +SyS_select_32319 SyS_select 1 32319 NULL
104541 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104542 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104543 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104544 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104545 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104546 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104547 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104548 +local_clock_32385 local_clock 0 32385 NULL
104549 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104550 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104551 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104552 +log_text_32428 log_text 0 32428 NULL
104553 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104554 +hid_input_report_32458 hid_input_report 4 32458 NULL
104555 +cache_status_32462 cache_status 5 32462 NULL
104556 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104557 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104558 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104559 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104560 +disconnect_32521 disconnect 4 32521 NULL
104561 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104562 +ilo_read_32531 ilo_read 3 32531 NULL
104563 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
104564 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
104565 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
104566 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
104567 +__first_node_32558 __first_node 0 32558 NULL
104568 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
104569 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
104570 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
104571 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
104572 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
104573 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
104574 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
104575 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
104576 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
104577 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
104578 +kvmalloc_32646 kvmalloc 1 32646 NULL
104579 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
104580 +generic_readlink_32654 generic_readlink 3 32654 NULL
104581 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
104582 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
104583 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
104584 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
104585 +get_arg_page_32746 get_arg_page 2 32746 NULL
104586 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
104587 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
104588 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
104589 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
104590 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
104591 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
104592 +vga_rseq_32848 vga_rseq 0 32848 NULL
104593 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
104594 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
104595 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
104596 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
104597 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
104598 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
104599 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
104600 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
104601 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
104602 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
104603 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
104604 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
104605 +compat_filldir_32999 compat_filldir 3 32999 NULL
104606 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
104607 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
104608 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
104609 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
104610 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
104611 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
104612 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
104613 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
104614 +alloc_tio_33077 alloc_tio 3 33077 NULL
104615 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
104616 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
104617 +write_node_33121 write_node 4 33121 NULL
104618 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
104619 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
104620 +__len_within_target_33132 __len_within_target 0 33132 NULL
104621 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
104622 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
104623 +pp_read_33210 pp_read 3 33210 NULL
104624 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
104625 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
104626 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
104627 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
104628 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
104629 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
104630 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
104631 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
104632 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
104633 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
104634 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
104635 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
104636 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
104637 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
104638 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
104639 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
104640 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
104641 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
104642 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
104643 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
104644 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
104645 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
104646 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
104647 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
104648 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
104649 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
104650 +create_entry_33479 create_entry 2 33479 NULL
104651 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
104652 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
104653 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
104654 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
104655 +res_counter_read_33499 res_counter_read 4 33499 NULL
104656 +fb_read_33506 fb_read 3 33506 NULL
104657 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
104658 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
104659 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
104660 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
104661 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
104662 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
104663 +dup_array_33551 dup_array 3 33551 NULL
104664 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
104665 +count_subheaders_33591 count_subheaders 0 33591 NULL
104666 +scsi_execute_33596 scsi_execute 5 33596 NULL
104667 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
104668 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
104669 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
104670 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
104671 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
104672 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
104673 +inw_p_33668 inw_p 0 33668 NULL
104674 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
104675 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
104676 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
104677 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
104678 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
104679 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
104680 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
104681 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
104682 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
104683 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
104684 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
104685 +Read_hfc_33755 Read_hfc 0 33755 NULL
104686 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
104687 +hashtab_create_33769 hashtab_create 3 33769 NULL
104688 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
104689 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
104690 +find_next_offset_33804 find_next_offset 3 33804 NULL
104691 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
104692 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
104693 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
104694 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
104695 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
104696 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
104697 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
104698 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
104699 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
104700 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
104701 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
104702 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
104703 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
104704 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
104705 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
104706 +ppp_write_34034 ppp_write 3 34034 NULL
104707 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
104708 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
104709 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
104710 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
104711 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
104712 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
104713 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
104714 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
104715 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
104716 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
104717 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
104718 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
104719 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
104720 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
104721 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
104722 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
104723 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
104724 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
104725 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
104726 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
104727 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
104728 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
104729 +__insert_34349 __insert 2-3 34349 NULL
104730 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
104731 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
104732 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
104733 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
104734 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
104735 +ea_read_34378 ea_read 0 34378 NULL
104736 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
104737 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
104738 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
104739 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
104740 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
104741 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
104742 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
104743 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
104744 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
104745 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
104746 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
104747 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
104748 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
104749 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
104750 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
104751 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
104752 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
104753 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
104754 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
104755 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
104756 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
104757 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
104758 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
104759 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
104760 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
104761 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
104762 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
104763 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
104764 +port_print_34704 port_print 3 34704 NULL
104765 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
104766 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
104767 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
104768 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
104769 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
104770 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
104771 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
104772 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
104773 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
104774 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
104775 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
104776 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
104777 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
104778 +msg_print_text_34889 msg_print_text 0 34889 NULL
104779 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
104780 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
104781 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
104782 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
104783 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
104784 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
104785 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
104786 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
104787 +Realloc_34961 Realloc 2 34961 NULL
104788 +mq_lookup_34990 mq_lookup 2 34990 NULL
104789 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
104790 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
104791 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
104792 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
104793 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
104794 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
104795 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
104796 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
104797 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
104798 +store_ifalias_35088 store_ifalias 4 35088 NULL
104799 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
104800 +capi_write_35104 capi_write 3 35104 NULL nohasharray
104801 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
104802 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
104803 +pointer_35138 pointer 0 35138 NULL
104804 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
104805 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
104806 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
104807 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
104808 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
104809 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
104810 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
104811 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
104812 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
104813 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
104814 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
104815 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
104816 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
104817 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
104818 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
104819 +set_fd_set_35249 set_fd_set 1 35249 NULL
104820 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
104821 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
104822 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
104823 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
104824 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
104825 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
104826 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
104827 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
104828 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
104829 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
104830 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
104831 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
104832 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
104833 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
104834 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
104835 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
104836 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
104837 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
104838 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
104839 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
104840 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
104841 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
104842 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
104843 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
104844 +async_setkey_35521 async_setkey 3 35521 NULL
104845 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
104846 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
104847 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
104848 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
104849 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
104850 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
104851 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
104852 +ReadZReg_35604 ReadZReg 0 35604 NULL
104853 +kernel_readv_35617 kernel_readv 3 35617 NULL
104854 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
104855 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
104856 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
104857 +store_debug_level_35652 store_debug_level 3 35652 NULL
104858 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
104859 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
104860 +dm_table_create_35687 dm_table_create 3 35687 NULL
104861 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
104862 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
104863 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
104864 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
104865 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
104866 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
104867 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
104868 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
104869 +fls64_35862 fls64 0 35862 NULL
104870 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
104871 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
104872 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
104873 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
104874 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
104875 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
104876 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
104877 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
104878 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
104879 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
104880 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
104881 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
104882 +acl_alloc_35979 acl_alloc 1 35979 NULL
104883 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
104884 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
104885 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
104886 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
104887 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
104888 +account_shadowed_36048 account_shadowed 2 36048 NULL
104889 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
104890 +write_emulate_36065 write_emulate 2-4 36065 NULL
104891 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
104892 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
104893 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
104894 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
104895 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
104896 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
104897 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
104898 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
104899 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
104900 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
104901 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
104902 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
104903 +twl_set_36154 twl_set 2 36154 NULL
104904 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
104905 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
104906 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
104907 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
104908 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
104909 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
104910 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
104911 +is_dirty_36223 is_dirty 2 36223 NULL
104912 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
104913 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
104914 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
104915 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
104916 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
104917 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
104918 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
104919 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
104920 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
104921 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
104922 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
104923 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
104924 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
104925 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
104926 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
104927 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
104928 +lc_create_36332 lc_create 4 36332 NULL
104929 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
104930 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
104931 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
104932 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
104933 +to_sector_36361 to_sector 0-1 36361 NULL
104934 +tunables_read_36385 tunables_read 3 36385 NULL
104935 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
104936 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
104937 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
104938 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
104939 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
104940 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
104941 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
104942 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
104943 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
104944 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
104945 +get_param_l_36518 get_param_l 0 36518 NULL
104946 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
104947 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
104948 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
104949 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
104950 +get_entry_len_36549 get_entry_len 0 36549 NULL
104951 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
104952 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
104953 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
104954 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
104955 +__erst_read_36579 __erst_read 0 36579 NULL
104956 +put_cmsg_36589 put_cmsg 4 36589 NULL
104957 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
104958 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
104959 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
104960 +format_decode_36638 format_decode 0 36638 NULL
104961 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
104962 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
104963 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
104964 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
104965 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
104966 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
104967 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
104968 +sched_clock_36717 sched_clock 0 36717 NULL
104969 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
104970 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
104971 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
104972 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
104973 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
104974 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
104975 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
104976 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
104977 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
104978 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
104979 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
104980 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
104981 +cm_write_36858 cm_write 3 36858 NULL
104982 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
104983 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
104984 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
104985 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
104986 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
104987 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
104988 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
104989 +build_key_36931 build_key 1 36931 NULL
104990 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
104991 +write_leb_36957 write_leb 5 36957 NULL
104992 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
104993 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
104994 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
104995 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
104996 +setxattr_37006 setxattr 4 37006 NULL
104997 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
104998 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
104999 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105000 +parse_command_37079 parse_command 2 37079 NULL
105001 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105002 +tun_get_user_37094 tun_get_user 5 37094 NULL
105003 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105004 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105005 +msg_word_37164 msg_word 0 37164 NULL
105006 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105007 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105008 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105009 +__do_replace_37227 __do_replace 5 37227 NULL
105010 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105011 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105012 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105013 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105014 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105015 +c101_run_37279 c101_run 2 37279 NULL
105016 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105017 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105018 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105019 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105020 +send_msg_37323 send_msg 4 37323 NULL
105021 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105022 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105023 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105024 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105025 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105026 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105027 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105028 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105029 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105030 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105031 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105032 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105033 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105034 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105035 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105036 +__remove_37457 __remove 2 37457 NULL
105037 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105038 +get_est_timing_37484 get_est_timing 0 37484 NULL
105039 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105040 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105041 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105042 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105043 +hdr_size_37536 hdr_size 0 37536 NULL
105044 +a2p_37544 a2p 0-1 37544 NULL
105045 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105046 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105047 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105048 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105049 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105050 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105051 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105052 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105053 +check_pt_base_37635 check_pt_base 3 37635 NULL
105054 +alloc_fd_37637 alloc_fd 1 37637 NULL
105055 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105056 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105057 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105058 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105059 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105060 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105061 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105062 +nametbl_header_37698 nametbl_header 2 37698 NULL
105063 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105064 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105065 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105066 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105067 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105068 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105069 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105070 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105071 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105072 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105073 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105074 +deny_write_access_37813 deny_write_access 0 37813 NULL
105075 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105076 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105077 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105078 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105079 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105080 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105081 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105082 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105083 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105084 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105085 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105086 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105087 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105088 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105089 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105090 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105091 +vfs_readv_38011 vfs_readv 3 38011 NULL
105092 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105093 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105094 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105095 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105096 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105097 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105098 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105099 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105100 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105101 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105102 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105103 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105104 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105105 +ep0_read_38095 ep0_read 3 38095 NULL
105106 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105107 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105108 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105109 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105110 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105111 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105112 +cdev_add_38176 cdev_add 2-3 38176 NULL
105113 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105114 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105115 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105116 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105117 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105118 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105119 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105120 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105121 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105122 +from_dblock_38256 from_dblock 0-1 38256 NULL
105123 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105124 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105125 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105126 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105127 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105128 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105129 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105130 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105131 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105132 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105133 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105134 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105135 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105136 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105137 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105138 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105139 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105140 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105141 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105142 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105143 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105144 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105145 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105146 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105147 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105148 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105149 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105150 +dev_names_read_38509 dev_names_read 3 38509 NULL
105151 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105152 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105153 +set_queue_count_38519 set_queue_count 0 38519 NULL
105154 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105155 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105156 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105157 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105158 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105159 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105160 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105161 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105162 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105163 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105164 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105165 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105166 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105167 +cma_create_area_38642 cma_create_area 2 38642 NULL
105168 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105169 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105170 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105171 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105172 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105173 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105174 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105175 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105176 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105177 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105178 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105179 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105180 +udf_readpages_38761 udf_readpages 4 38761 NULL
105181 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105182 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105183 +err_decode_38804 err_decode 2 38804 NULL
105184 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105185 +sys_select_38827 sys_select 1 38827 NULL
105186 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105187 +direct_entry_38836 direct_entry 3 38836 NULL
105188 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105189 +interfaces_38859 interfaces 2 38859 NULL
105190 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105191 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105192 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105193 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105194 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105195 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105196 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105197 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105198 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105199 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105200 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105201 +udf_new_block_38999 udf_new_block 4 38999 NULL
105202 +get_nodes_39012 get_nodes 3 39012 NULL
105203 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105204 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105205 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105206 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105207 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105208 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105209 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105210 +ea_foreach_39133 ea_foreach 0 39133 NULL
105211 +generic_permission_39150 generic_permission 0 39150 NULL
105212 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105213 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105214 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105215 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105216 +init_list_set_39188 init_list_set 2-3 39188 NULL
105217 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105218 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105219 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105220 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105221 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105222 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105223 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105224 +drm_order_39244 drm_order 0 39244 NULL
105225 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105226 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105227 +__skb_cow_39254 __skb_cow 2 39254 NULL
105228 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105229 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105230 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105231 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105232 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105233 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105234 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105235 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105236 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105237 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105238 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105239 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105240 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105241 +__send_to_port_39386 __send_to_port 3 39386 NULL
105242 +user_power_read_39414 user_power_read 3 39414 NULL
105243 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105244 +sys_semop_39457 sys_semop 3 39457 NULL
105245 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105246 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105247 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105248 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105249 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105250 +int_proc_write_39542 int_proc_write 3 39542 NULL
105251 +pp_write_39554 pp_write 3 39554 NULL
105252 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105253 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105254 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105255 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105256 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105257 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105258 +ext_depth_39607 ext_depth 0 39607 NULL
105259 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105260 +sdio_readb_39618 sdio_readb 0 39618 NULL
105261 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105262 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105263 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105264 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105265 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105266 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105267 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105268 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105269 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105270 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105271 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105272 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105273 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105274 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105275 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105276 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105277 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105278 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105279 +pkt_add_39897 pkt_add 3 39897 NULL
105280 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105281 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105282 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105283 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105284 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105285 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105286 +__spi_async_39932 __spi_async 0 39932 NULL
105287 +__get_order_39935 __get_order 0 39935 NULL
105288 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105289 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105290 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105291 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105292 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105293 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105294 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105295 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105296 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105297 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105298 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105299 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105300 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105301 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105302 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105303 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105304 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105305 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105306 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105307 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105308 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105309 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105310 +pt_write_40159 pt_write 3 40159 NULL
105311 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105312 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105313 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105314 +allocate_probes_40204 allocate_probes 1 40204 NULL
105315 +compat_put_long_40214 compat_put_long 1 40214 NULL
105316 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105317 +osst_read_40237 osst_read 3 40237 NULL
105318 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105319 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105320 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105321 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105322 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105323 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105324 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105325 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105326 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105327 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105328 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105329 +mmio_read_40348 mmio_read 4 40348 NULL
105330 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105331 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105332 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105333 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105334 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105335 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105336 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105337 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105338 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105339 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105340 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105341 +tty_write_room_40495 tty_write_room 0 40495 NULL
105342 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105343 +sg_phys_40507 sg_phys 0 40507 NULL
105344 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105345 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105346 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105347 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105348 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105349 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105350 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105351 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105352 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105353 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105354 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105355 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105356 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105357 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105358 +fops_read_40672 fops_read 3 40672 NULL
105359 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105360 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105361 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105362 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105363 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105364 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105365 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105366 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105367 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105368 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105369 +card_send_command_40757 card_send_command 3 40757 NULL
105370 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105371 +pg_write_40766 pg_write 3 40766 NULL
105372 +show_list_40775 show_list 3 40775 NULL
105373 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105374 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105375 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105376 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105377 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105378 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105379 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105380 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105381 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105382 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105383 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105384 +read_file_queue_40895 read_file_queue 3 40895 NULL
105385 +waiters_read_40902 waiters_read 3 40902 NULL
105386 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105387 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105388 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105389 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105390 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105391 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105392 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105393 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105394 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105395 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105396 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105397 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105398 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105399 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105400 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105401 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105402 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105403 +dma_attach_41094 dma_attach 5-6 41094 NULL
105404 +provide_user_output_41105 provide_user_output 3 41105 NULL
105405 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105406 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105407 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105408 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105409 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105410 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105411 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105412 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105413 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105414 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105415 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105416 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105417 +erst_read_41260 erst_read 0 41260 NULL
105418 +__fprog_create_41263 __fprog_create 2 41263 NULL
105419 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105420 +alloc_context_41283 alloc_context 1 41283 NULL
105421 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105422 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105423 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105424 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105425 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105426 +kmp_init_41373 kmp_init 2 41373 NULL
105427 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105428 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105429 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105430 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105431 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105432 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105433 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105434 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105435 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105436 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105437 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105438 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105439 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105440 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105441 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105442 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105443 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105444 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105445 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105446 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105447 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105448 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105449 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105450 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105451 +vga_io_r_41609 vga_io_r 0 41609 NULL
105452 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105453 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105454 +a2mp_send_41615 a2mp_send 4 41615 NULL
105455 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105456 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105457 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105458 +get_std_timing_41654 get_std_timing 0 41654 NULL
105459 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105460 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105461 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105462 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105463 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105464 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105465 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105466 +fillonedir_41746 fillonedir 3 41746 NULL
105467 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105468 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105469 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105470 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105471 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105472 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105473 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105474 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105475 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105476 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105477 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105478 +get_packet_41914 get_packet 3 41914 NULL
105479 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105480 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105481 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105482 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105483 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105484 +read_gssp_41947 read_gssp 3 41947 NULL
105485 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105486 +portnames_read_41958 portnames_read 3 41958 NULL
105487 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105488 +dst_mtu_41969 dst_mtu 0 41969 NULL
105489 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105490 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105491 +lguest_map_42008 lguest_map 1-2 42008 NULL
105492 +pool_allocate_42012 pool_allocate 3 42012 NULL
105493 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105494 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105495 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105496 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105497 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105498 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105499 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105500 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105501 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105502 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105503 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105504 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105505 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105506 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105507 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105508 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105509 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105510 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105511 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105512 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105513 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105514 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105515 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105516 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105517 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105518 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105519 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105520 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105521 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105522 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105523 +free_cblock_42318 free_cblock 2 42318 NULL
105524 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105525 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105526 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105527 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105528 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105529 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105530 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105531 +krng_get_random_42420 krng_get_random 3 42420 NULL
105532 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105533 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105534 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105535 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105536 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105537 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105538 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105539 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105540 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105541 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105542 +bypass_write_42498 bypass_write 3 42498 NULL
105543 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105544 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105545 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105546 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105547 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105548 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105549 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105550 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105551 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105552 +map_state_42602 map_state 1 42602 NULL nohasharray
105553 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105554 +nd_get_link_42603 nd_get_link 0 42603 NULL
105555 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105556 +resp_write_42628 resp_write 2 42628 NULL
105557 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105558 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105559 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105560 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105561 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105562 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105563 +vb2_read_42703 vb2_read 3 42703 NULL
105564 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
105565 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
105566 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
105567 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
105568 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
105569 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
105570 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
105571 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
105572 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
105573 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
105574 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
105575 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
105576 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
105577 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
105578 +set_arg_42824 set_arg 3 42824 NULL
105579 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
105580 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
105581 +prandom_u32_42853 prandom_u32 0 42853 NULL
105582 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
105583 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
105584 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
105585 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
105586 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
105587 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
105588 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
105589 +hd_end_request_42904 hd_end_request 2 42904 NULL
105590 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
105591 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
105592 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
105593 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
105594 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
105595 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
105596 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
105597 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
105598 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
105599 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
105600 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
105601 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
105602 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
105603 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
105604 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
105605 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
105606 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
105607 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
105608 +uuid_string_43154 uuid_string 0 43154 NULL
105609 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
105610 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
105611 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
105612 +process_measurement_43190 process_measurement 0 43190 NULL
105613 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
105614 +uio_write_43202 uio_write 3 43202 NULL
105615 +iso_callback_43208 iso_callback 3 43208 NULL
105616 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
105617 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
105618 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
105619 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
105620 +fixup_leb_43256 fixup_leb 3 43256 NULL
105621 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
105622 +evtchn_write_43278 evtchn_write 3 43278 NULL
105623 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
105624 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
105625 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
105626 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
105627 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
105628 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
105629 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
105630 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
105631 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
105632 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
105633 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
105634 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
105635 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
105636 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
105637 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
105638 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
105639 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
105640 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
105641 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
105642 +do_readlink_43518 do_readlink 2 43518 NULL
105643 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
105644 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
105645 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
105646 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
105647 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
105648 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
105649 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
105650 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
105651 +proc_read_43614 proc_read 3 43614 NULL
105652 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
105653 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
105654 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
105655 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
105656 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
105657 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
105658 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
105659 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
105660 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
105661 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
105662 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
105663 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
105664 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
105665 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
105666 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
105667 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
105668 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
105669 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
105670 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
105671 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
105672 +read_flush_43851 read_flush 3 43851 NULL
105673 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
105674 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
105675 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
105676 +SendString_43928 SendString 3 43928 NULL
105677 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
105678 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
105679 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
105680 +nla_reserve_43984 nla_reserve 3 43984 NULL
105681 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
105682 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
105683 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
105684 +emit_flags_44006 emit_flags 4-3 44006 NULL
105685 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
105686 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
105687 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
105688 +load_discard_44083 load_discard 3 44083 NULL
105689 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
105690 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
105691 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
105692 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
105693 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
105694 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
105695 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
105696 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
105697 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
105698 +__set_free_44211 __set_free 2 44211 NULL
105699 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
105700 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
105701 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
105702 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
105703 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
105704 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
105705 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
105706 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
105707 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
105708 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
105709 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
105710 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
105711 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
105712 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
105713 +__is_discarded_44359 __is_discarded 2 44359 NULL
105714 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
105715 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
105716 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
105717 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
105718 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
105719 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
105720 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
105721 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
105722 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
105723 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
105724 +bio_advance_44496 bio_advance 2 44496 NULL
105725 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
105726 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
105727 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
105728 +spidev_write_44510 spidev_write 3 44510 NULL
105729 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
105730 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
105731 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
105732 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
105733 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
105734 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
105735 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
105736 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
105737 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
105738 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
105739 +mpi_resize_44674 mpi_resize 2 44674 NULL
105740 +ts_read_44687 ts_read 3 44687 NULL
105741 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
105742 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
105743 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
105744 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
105745 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
105746 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
105747 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
105748 +set_brk_44749 set_brk 1 44749 NULL
105749 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
105750 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
105751 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
105752 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
105753 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
105754 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
105755 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
105756 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
105757 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
105758 +sisusb_write_44834 sisusb_write 3 44834 NULL
105759 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
105760 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
105761 +cubic_root_44848 cubic_root 1 44848 NULL
105762 +copydesc_user_44855 copydesc_user 3 44855 NULL
105763 +skb_availroom_44883 skb_availroom 0 44883 NULL
105764 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
105765 +do_tty_write_44896 do_tty_write 5 44896 NULL
105766 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
105767 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
105768 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
105769 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
105770 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
105771 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
105772 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
105773 +sel_write_user_45060 sel_write_user 3 45060 NULL
105774 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
105775 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
105776 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
105777 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
105778 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
105779 +usbdev_read_45114 usbdev_read 3 45114 NULL
105780 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
105781 +send_to_tty_45141 send_to_tty 3 45141 NULL
105782 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
105783 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
105784 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
105785 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
105786 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
105787 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
105788 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
105789 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
105790 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
105791 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
105792 +add_child_45201 add_child 4 45201 NULL
105793 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
105794 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
105795 +__dirty_45228 __dirty 2 45228 NULL
105796 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
105797 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
105798 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
105799 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
105800 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
105801 +pte_val_45313 pte_val 0 45313 NULL
105802 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
105803 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
105804 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
105805 +keymap_store_45406 keymap_store 4 45406 NULL
105806 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
105807 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
105808 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
105809 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
105810 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
105811 +__node_remap_45458 __node_remap 4 45458 NULL
105812 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
105813 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
105814 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
105815 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
105816 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
105817 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
105818 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
105819 +copy_macs_45534 copy_macs 4 45534 NULL
105820 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
105821 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
105822 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
105823 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
105824 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
105825 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
105826 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
105827 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
105828 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
105829 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
105830 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
105831 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
105832 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
105833 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
105834 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
105835 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
105836 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
105837 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
105838 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
105839 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
105840 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
105841 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
105842 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
105843 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
105844 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
105845 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
105846 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
105847 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
105848 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
105849 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
105850 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
105851 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
105852 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
105853 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
105854 +isdn_write_45863 isdn_write 3 45863 NULL
105855 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
105856 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
105857 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
105858 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
105859 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
105860 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
105861 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
105862 +alloc_mr_45935 alloc_mr 1 45935 NULL
105863 +split_large_page_45941 split_large_page 2 45941 NULL
105864 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
105865 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
105866 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
105867 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
105868 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
105869 +get_free_entries_46030 get_free_entries 1 46030 NULL
105870 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
105871 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
105872 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
105873 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
105874 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
105875 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
105876 +slhc_toss_46066 slhc_toss 0 46066 NULL
105877 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
105878 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
105879 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
105880 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
105881 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
105882 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
105883 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
105884 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
105885 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
105886 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
105887 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
105888 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
105889 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
105890 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
105891 +add_conn_list_46197 add_conn_list 3 46197 NULL
105892 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
105893 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
105894 +dsp_write_46218 dsp_write 2 46218 NULL
105895 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
105896 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
105897 +ReadReg_46277 ReadReg 0 46277 NULL
105898 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
105899 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
105900 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
105901 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
105902 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
105903 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
105904 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
105905 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
105906 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
105907 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
105908 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
105909 +filldir64_46469 filldir64 3 46469 NULL
105910 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
105911 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
105912 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
105913 +kmsg_read_46514 kmsg_read 3 46514 NULL
105914 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
105915 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
105916 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
105917 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
105918 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
105919 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
105920 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
105921 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
105922 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
105923 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
105924 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
105925 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
105926 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
105927 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
105928 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
105929 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
105930 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
105931 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
105932 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
105933 +prepare_copy_46725 prepare_copy 2 46725 NULL
105934 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
105935 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
105936 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
105937 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
105938 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
105939 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
105940 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
105941 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
105942 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
105943 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
105944 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
105945 +spi_async_46857 spi_async 0 46857 NULL
105946 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
105947 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
105948 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
105949 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
105950 +rvmalloc_46873 rvmalloc 1 46873 NULL
105951 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
105952 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
105953 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
105954 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
105955 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
105956 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
105957 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
105958 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
105959 +fb_write_46924 fb_write 3 46924 NULL
105960 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
105961 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
105962 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
105963 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
105964 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
105965 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
105966 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
105967 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
105968 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
105969 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
105970 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
105971 +__map_single_47020 __map_single 3-4-7 47020 NULL
105972 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
105973 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
105974 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
105975 +fs_path_len_47060 fs_path_len 0 47060 NULL
105976 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
105977 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
105978 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
105979 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
105980 +mousedev_read_47123 mousedev_read 3 47123 NULL
105981 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
105982 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
105983 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
105984 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
105985 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
105986 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
105987 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
105988 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
105989 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
105990 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
105991 +l2headersize_47238 l2headersize 0 47238 NULL
105992 +options_write_47243 options_write 3 47243 NULL
105993 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
105994 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
105995 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
105996 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
105997 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
105998 +vsnprintf_47291 vsnprintf 0 47291 NULL
105999 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106000 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106001 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106002 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106003 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106004 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106005 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106006 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106007 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106008 +nametbl_list_47391 nametbl_list 2 47391 NULL
106009 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106010 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106011 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106012 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106013 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106014 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106015 +vzalloc_47421 vzalloc 1 47421 NULL
106016 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106017 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106018 +__load_mapping_47460 __load_mapping 2 47460 NULL
106019 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106020 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106021 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106022 +core_sys_select_47494 core_sys_select 1 47494 NULL
106023 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106024 +unlink_simple_47506 unlink_simple 3 47506 NULL
106025 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106026 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106027 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106028 +oz_events_read_47535 oz_events_read 3 47535 NULL
106029 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106030 +read_ldt_47570 read_ldt 2 47570 NULL
106031 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106032 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106033 +pci_iomap_47575 pci_iomap 3 47575 NULL
106034 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106035 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106036 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106037 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106038 +uea_request_47613 uea_request 4 47613 NULL
106039 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106040 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106041 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106042 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106043 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106044 +save_microcode_47717 save_microcode 3 47717 NULL
106045 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106046 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106047 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106048 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106049 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106050 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106051 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106052 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106053 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106054 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106055 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106056 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106057 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106058 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106059 +vhci_read_47878 vhci_read 3 47878 NULL
106060 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106061 +load_mapping_47904 load_mapping 3 47904 NULL
106062 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106063 +comedi_write_47926 comedi_write 3 47926 NULL
106064 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106065 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106066 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106067 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106068 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106069 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106070 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106071 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106072 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106073 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106074 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106075 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106076 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106077 +disc_write_48070 disc_write 3 48070 NULL
106078 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106079 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106080 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106081 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106082 +set_discoverable_48141 set_discoverable 4 48141 NULL
106083 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106084 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106085 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106086 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106087 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106088 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106089 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106090 +init_ipath_48187 init_ipath 1 48187 NULL
106091 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106092 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106093 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106094 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106095 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106096 +read_file_recv_48232 read_file_recv 3 48232 NULL
106097 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106098 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106099 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106100 +send_set_info_48288 send_set_info 7 48288 NULL
106101 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106102 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106103 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106104 +hash_setkey_48310 hash_setkey 3 48310 NULL
106105 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106106 +skb_add_data_48363 skb_add_data 3 48363 NULL
106107 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106108 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106109 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106110 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106111 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106112 +print_filtered_48442 print_filtered 2-0 48442 NULL
106113 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106114 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106115 +send_control_msg_48498 send_control_msg 6 48498 NULL
106116 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106117 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106118 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106119 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106120 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106121 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106122 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106123 +named_distribute_48544 named_distribute 4 48544 NULL
106124 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106125 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106126 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106127 +mtd_read_48655 mtd_read 0 48655 NULL
106128 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106129 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106130 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106131 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106132 +altera_drscan_48698 altera_drscan 2 48698 NULL
106133 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106134 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106135 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106136 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106137 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106138 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106139 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106140 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106141 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106142 +azx_get_position_48841 azx_get_position 0 48841 NULL
106143 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106144 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106145 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106146 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106147 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106148 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106149 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106150 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106151 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106152 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106153 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106154 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106155 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106156 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106157 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106158 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106159 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106160 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106161 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106162 +transient_status_49027 transient_status 4 49027 NULL
106163 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106164 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106165 +ubi_read_49061 ubi_read 0 49061 NULL
106166 +scsi_register_49094 scsi_register 2 49094 NULL
106167 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106168 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106169 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106170 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106171 +pt_read_49136 pt_read 3 49136 NULL
106172 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106173 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106174 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106175 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106176 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106177 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106178 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106179 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106180 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106181 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106182 +resp_write_same_49217 resp_write_same 2 49217 NULL
106183 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106184 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106185 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106186 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106187 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106188 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106189 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106190 +uio_read_49300 uio_read 3 49300 NULL
106191 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106192 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106193 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106194 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106195 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106196 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106197 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106198 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106199 +px_raw_event_49371 px_raw_event 4 49371 NULL
106200 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106201 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106202 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106203 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106204 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106205 +md_domain_init_49432 md_domain_init 2 49432 NULL
106206 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106207 +get_lru_size_49441 get_lru_size 0 49441 NULL
106208 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106209 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106210 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106211 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106212 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106213 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106214 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106215 +smk_write_access_49561 smk_write_access 3 49561 NULL
106216 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106217 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106218 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106219 +tap_write_49595 tap_write 3 49595 NULL
106220 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106221 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106222 +heap_init_49617 heap_init 2 49617 NULL
106223 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106224 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106225 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106226 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106227 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106228 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106229 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106230 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106231 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106232 +check_frame_49741 check_frame 0 49741 NULL
106233 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106234 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106235 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106236 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106237 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106238 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106239 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106240 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106241 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106242 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106243 +add_uuid_49831 add_uuid 4 49831 NULL
106244 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106245 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106246 +twl4030_write_49846 twl4030_write 2 49846 NULL
106247 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106248 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106249 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106250 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106251 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106252 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106253 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106254 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106255 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106256 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106257 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106258 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106259 +__module_alloc_50004 __module_alloc 1 50004 NULL
106260 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106261 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106262 +isdn_read_50021 isdn_read 3 50021 NULL
106263 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106264 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106265 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106266 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106267 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106268 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106269 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106270 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106271 +read_file_slot_50111 read_file_slot 3 50111 NULL
106272 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106273 +copy_items_50140 copy_items 6 50140 NULL
106274 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106275 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106276 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106277 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106278 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106279 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106280 +odev_update_50169 odev_update 2 50169 NULL
106281 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106282 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106283 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106284 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106285 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106286 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106287 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106288 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106289 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106290 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106291 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106292 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106293 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106294 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106295 +do_launder_page_50329 do_launder_page 0 50329 NULL
106296 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106297 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106298 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106299 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106300 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106301 +tpm_read_50344 tpm_read 3 50344 NULL
106302 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106303 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106304 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106305 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106306 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106307 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106308 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106309 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106310 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106311 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106312 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106313 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106314 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106315 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106316 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106317 +force_mapping_50464 force_mapping 2 50464 NULL
106318 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106319 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106320 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106321 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106322 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106323 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106324 +fat_readpages_50582 fat_readpages 4 50582 NULL
106325 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106326 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106327 +sge_rx_50594 sge_rx 3 50594 NULL
106328 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106329 +__ffs_50625 __ffs 0 50625 NULL
106330 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106331 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106332 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106333 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106334 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106335 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106336 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106337 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106338 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106339 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106340 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106341 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106342 +skb_padto_50759 skb_padto 2 50759 NULL
106343 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106344 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106345 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106346 +tpm_write_50798 tpm_write 3 50798 NULL
106347 +write_flush_50803 write_flush 3 50803 NULL
106348 +dvb_play_50814 dvb_play 3 50814 NULL
106349 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106350 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106351 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106352 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106353 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106354 +self_check_write_50856 self_check_write 5 50856 NULL
106355 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106356 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106357 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106358 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106359 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106360 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106361 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106362 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106363 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106364 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106365 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106366 +timeout_write_50991 timeout_write 3 50991 NULL
106367 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106368 +proc_write_51003 proc_write 3 51003 NULL
106369 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106370 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106371 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106372 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106373 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106374 +dump_midi_51040 dump_midi 3 51040 NULL
106375 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106376 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106377 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106378 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106379 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106380 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106381 +ti_recv_51110 ti_recv 3 51110 NULL
106382 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106383 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106384 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106385 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106386 +set_dirty_51144 set_dirty 3 51144 NULL
106387 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106388 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106389 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106390 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106391 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106392 +tipc_send_51238 tipc_send 4 51238 NULL
106393 +drm_property_create_51239 drm_property_create 4 51239 NULL
106394 +st_read_51251 st_read 3 51251 NULL
106395 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106396 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106397 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106398 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106399 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106400 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106401 +get_cell_51316 get_cell 2 51316 NULL
106402 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106403 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106404 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106405 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106406 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106407 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106408 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106409 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106410 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106411 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106412 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106413 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106414 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106415 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106416 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106417 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106418 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106419 +vaddr_51480 vaddr 0 51480 NULL
106420 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106421 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106422 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106423 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106424 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106425 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106426 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106427 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106428 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106429 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106430 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106431 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106432 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106433 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106434 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106435 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106436 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106437 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106438 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106439 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106440 +sel_write_access_51704 sel_write_access 3 51704 NULL
106441 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106442 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106443 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106444 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106445 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106446 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106447 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106448 +if_write_51756 if_write 3 51756 NULL
106449 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106450 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106451 +to_ratio_51809 to_ratio 2-1 51809 NULL
106452 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106453 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106454 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106455 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106456 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106457 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106458 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106459 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106460 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106461 +user_read_51881 user_read 3 51881 NULL
106462 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106463 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106464 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106465 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106466 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106467 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106468 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106469 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106470 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106471 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106472 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106473 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106474 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106475 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106476 +rdmalt_52022 rdmalt 0 52022 NULL
106477 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106478 +override_release_52032 override_release 2 52032 NULL
106479 +end_port_52042 end_port 0 52042 NULL
106480 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106481 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106482 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106483 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106484 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106485 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106486 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106487 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106488 +retry_count_read_52129 retry_count_read 3 52129 NULL
106489 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106490 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106491 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106492 +htable_size_52148 htable_size 0-1 52148 NULL
106493 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106494 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106495 +alix_present_52165 alix_present 1 52165 NULL
106496 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106497 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106498 +print_prefix_52176 print_prefix 0 52176 NULL
106499 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106500 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106501 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106502 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106503 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106504 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106505 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106506 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106507 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106508 +atomic64_read_52300 atomic64_read 0 52300 NULL
106509 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106510 +read_file_reset_52310 read_file_reset 3 52310 NULL
106511 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106512 +hwflags_read_52318 hwflags_read 3 52318 NULL
106513 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106514 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106515 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106516 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106517 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106518 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106519 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106520 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106521 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106522 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106523 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106524 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106525 +delay_status_52431 delay_status 5 52431 NULL
106526 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106527 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106528 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106529 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106530 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106531 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106532 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106533 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106534 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106535 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106536 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106537 +from_oblock_52546 from_oblock 0-1 52546 NULL
106538 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106539 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106540 +emit_code_52583 emit_code 0-3 52583 NULL
106541 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106542 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106543 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106544 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106545 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106546 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106547 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106548 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106549 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106550 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106551 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106552 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106553 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106554 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106555 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106556 +twlreg_write_52880 twlreg_write 3 52880 NULL
106557 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106558 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106559 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106560 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106561 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106562 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106563 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
106564 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
106565 +send_packet_52960 send_packet 4 52960 NULL
106566 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
106567 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
106568 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
106569 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
106570 +num_node_state_52989 num_node_state 0 52989 NULL
106571 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
106572 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
106573 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
106574 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
106575 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
106576 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
106577 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
106578 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
106579 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
106580 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
106581 +verity_status_53120 verity_status 5 53120 NULL
106582 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
106583 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
106584 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
106585 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
106586 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
106587 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
106588 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
106589 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
106590 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
106591 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
106592 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
106593 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
106594 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
106595 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
106596 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
106597 +vm_mmap_53339 vm_mmap 0 53339 NULL
106598 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
106599 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
106600 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
106601 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
106602 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
106603 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
106604 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
106605 +n2_run_53459 n2_run 3 53459 NULL
106606 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
106607 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
106608 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
106609 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
106610 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
106611 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
106612 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
106613 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
106614 +check_acl_53512 check_acl 0 53512 NULL
106615 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
106616 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
106617 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
106618 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
106619 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
106620 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
106621 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
106622 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
106623 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
106624 +_preload_range_53676 _preload_range 2-3 53676 NULL
106625 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
106626 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
106627 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
106628 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
106629 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
106630 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
106631 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
106632 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
106633 +wdm_write_53735 wdm_write 3 53735 NULL
106634 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
106635 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
106636 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
106637 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
106638 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
106639 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
106640 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
106641 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
106642 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
106643 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
106644 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
106645 +pms_read_53873 pms_read 3 53873 NULL
106646 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
106647 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
106648 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
106649 +proc_file_read_53905 proc_file_read 3 53905 NULL
106650 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
106651 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
106652 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
106653 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
106654 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
106655 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
106656 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
106657 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
106658 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
106659 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
106660 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
106661 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
106662 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
106663 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
106664 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
106665 +_malloc_54077 _malloc 1 54077 NULL
106666 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
106667 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
106668 +create_xattr_54106 create_xattr 5 54106 NULL
106669 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
106670 +strn_len_54122 strn_len 0 54122 NULL
106671 +isku_receive_54130 isku_receive 4 54130 NULL
106672 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
106673 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
106674 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
106675 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
106676 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
106677 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
106678 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
106679 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
106680 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
106681 +reada_add_block_54247 reada_add_block 2 54247 NULL
106682 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
106683 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
106684 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
106685 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
106686 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
106687 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
106688 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
106689 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
106690 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
106691 +sprintf_54306 sprintf 0 54306 NULL
106692 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
106693 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
106694 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
106695 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
106696 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
106697 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
106698 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
106699 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
106700 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
106701 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
106702 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
106703 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
106704 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
106705 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
106706 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
106707 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
106708 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
106709 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
106710 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
106711 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
106712 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
106713 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
106714 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
106715 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
106716 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
106717 +viacam_read_54526 viacam_read 3 54526 NULL
106718 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
106719 +setsockopt_54539 setsockopt 5 54539 NULL
106720 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
106721 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
106722 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
106723 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
106724 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
106725 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
106726 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
106727 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
106728 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
106729 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
106730 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
106731 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
106732 +evm_read_key_54674 evm_read_key 3 54674 NULL
106733 +resource_string_54699 resource_string 0 54699 NULL
106734 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
106735 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
106736 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
106737 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
106738 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
106739 +kzalloc_54740 kzalloc 1 54740 NULL
106740 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
106741 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
106742 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
106743 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
106744 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
106745 +domain_init_54797 domain_init 2 54797 NULL
106746 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
106747 +get_dev_size_54807 get_dev_size 0 54807 NULL
106748 +nfsd_write_54809 nfsd_write 6 54809 NULL
106749 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
106750 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
106751 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
106752 +write_rio_54837 write_rio 3 54837 NULL
106753 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
106754 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
106755 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
106756 +printer_read_54851 printer_read 3 54851 NULL
106757 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
106758 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
106759 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
106760 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
106761 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
106762 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
106763 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
106764 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
106765 +add_port_54941 add_port 2 54941 NULL
106766 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
106767 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
106768 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
106769 +c4_add_card_54968 c4_add_card 3 54968 NULL
106770 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
106771 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
106772 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
106773 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
106774 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
106775 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
106776 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
106777 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
106778 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
106779 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
106780 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
106781 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
106782 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
106783 +corrupt_data_55120 corrupt_data 0 55120 NULL
106784 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
106785 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
106786 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
106787 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
106788 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
106789 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
106790 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
106791 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
106792 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
106793 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
106794 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
106795 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
106796 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
106797 +dump_command_55220 dump_command 1 55220 NULL
106798 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
106799 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
106800 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
106801 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
106802 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
106803 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
106804 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
106805 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
106806 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
106807 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
106808 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
106809 +do_shmat_55336 do_shmat 5 55336 NULL
106810 +vme_user_read_55338 vme_user_read 3 55338 NULL
106811 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
106812 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
106813 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
106814 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
106815 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
106816 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
106817 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
106818 +alloc_skb_55439 alloc_skb 1 55439 NULL
106819 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
106820 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
106821 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
106822 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
106823 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
106824 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
106825 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
106826 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
106827 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
106828 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
106829 +ea_get_55522 ea_get 0 55522 NULL
106830 +buffer_size_55534 buffer_size 0 55534 NULL
106831 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
106832 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
106833 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
106834 +add_partition_55588 add_partition 2 55588 NULL
106835 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
106836 +free_pages_55603 free_pages 1 55603 NULL
106837 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
106838 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
106839 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
106840 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
106841 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
106842 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
106843 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
106844 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
106845 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
106846 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
106847 +read_oldmem_55658 read_oldmem 3 55658 NULL
106848 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
106849 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
106850 +get_info_55681 get_info 3 55681 NULL
106851 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
106852 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
106853 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
106854 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
106855 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
106856 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
106857 +set_local_name_55757 set_local_name 4 55757 NULL
106858 +strlen_55778 strlen 0 55778 NULL
106859 +set_spte_55783 set_spte 5-4 55783 NULL
106860 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
106861 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
106862 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
106863 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
106864 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
106865 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
106866 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
106867 +hsc_write_55875 hsc_write 3 55875 NULL
106868 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
106869 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
106870 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
106871 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
106872 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
106873 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
106874 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
106875 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
106876 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
106877 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
106878 +__set_discard_56081 __set_discard 2 56081 NULL
106879 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
106880 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
106881 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
106882 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
106883 +map_addr_56144 map_addr 7 56144 NULL
106884 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
106885 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
106886 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
106887 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
106888 +skb_headroom_56200 skb_headroom 0 56200 NULL
106889 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
106890 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
106891 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
106892 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
106893 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
106894 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
106895 +fd_copyin_56247 fd_copyin 3 56247 NULL
106896 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
106897 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
106898 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
106899 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
106900 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
106901 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
106902 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
106903 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
106904 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
106905 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
106906 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
106907 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
106908 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
106909 +dev_read_56369 dev_read 3 56369 NULL
106910 +write_gssp_56404 write_gssp 3 56404 NULL
106911 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
106912 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
106913 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
106914 +store_msg_56417 store_msg 3 56417 NULL
106915 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
106916 +fl_create_56435 fl_create 5 56435 NULL
106917 +gnttab_map_56439 gnttab_map 2 56439 NULL
106918 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
106919 +set_connectable_56458 set_connectable 4 56458 NULL
106920 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
106921 +putused_user_56467 putused_user 3 56467 NULL
106922 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
106923 +global_rt_period_56476 global_rt_period 0 56476 NULL
106924 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
106925 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
106926 +init_map_ip_56508 init_map_ip 5 56508 NULL
106927 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
106928 +ip_options_get_56538 ip_options_get 4 56538 NULL
106929 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
106930 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
106931 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
106932 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
106933 +event_filter_write_56609 event_filter_write 3 56609 NULL
106934 +gather_array_56641 gather_array 3 56641 NULL
106935 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
106936 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
106937 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
106938 +build_map_info_56696 build_map_info 2 56696 NULL
106939 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
106940 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
106941 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
106942 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
106943 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
106944 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
106945 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
106946 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
106947 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
106948 +hash_lookup_56792 hash_lookup 2 56792 NULL
106949 +do_syslog_56807 do_syslog 3 56807 NULL
106950 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
106951 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
106952 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
106953 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
106954 +wb_lookup_56858 wb_lookup 2 56858 NULL
106955 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
106956 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
106957 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
106958 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
106959 +strcspn_56913 strcspn 0 56913 NULL
106960 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
106961 +check_header_56930 check_header 2 56930 NULL
106962 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
106963 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
106964 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
106965 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
106966 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
106967 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
106968 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
106969 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
106970 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
106971 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
106972 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
106973 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
106974 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
106975 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
106976 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
106977 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
106978 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
106979 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
106980 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
106981 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
106982 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
106983 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
106984 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
106985 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
106986 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
106987 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
106988 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
106989 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
106990 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
106991 +flush_space_57241 flush_space 3 57241 NULL
106992 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
106993 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
106994 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
106995 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
106996 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
106997 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
106998 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
106999 +fw_file_size_57307 fw_file_size 0 57307 NULL
107000 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107001 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107002 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107003 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107004 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107005 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107006 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107007 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107008 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107009 +read_file_blob_57406 read_file_blob 3 57406 NULL
107010 +enclosure_register_57412 enclosure_register 3 57412 NULL
107011 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107012 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107013 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107014 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107015 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107016 +ReadReg_57453 ReadReg 0 57453 NULL
107017 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107018 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107019 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107020 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107021 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107022 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107023 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107024 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107025 +skb_headlen_57501 skb_headlen 0 57501 NULL
107026 +copy_in_user_57502 copy_in_user 3 57502 NULL
107027 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107028 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107029 +init_tag_map_57515 init_tag_map 3 57515 NULL
107030 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107031 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107032 +inode_permission_57531 inode_permission 0 57531 NULL
107033 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107034 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107035 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107036 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107037 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107038 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107039 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107040 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107041 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107042 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107043 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107044 +mem_read_57631 mem_read 3 57631 NULL
107045 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107046 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107047 +r3964_write_57662 r3964_write 4 57662 NULL
107048 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107049 +__lgwrite_57669 __lgwrite 4 57669 NULL
107050 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107051 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107052 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107053 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107054 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107055 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107056 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107057 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107058 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107059 +ld2_57794 ld2 0 57794 NULL
107060 +ivtv_read_57796 ivtv_read 3 57796 NULL
107061 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107062 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107063 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107064 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107065 +copy_to_user_57835 copy_to_user 3 57835 NULL
107066 +flash_read_57843 flash_read 3 57843 NULL
107067 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107068 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107069 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107070 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107071 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107072 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107073 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107074 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107075 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107076 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107077 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107078 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107079 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107080 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107081 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107082 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107083 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107084 +mce_async_out_58056 mce_async_out 3 58056 NULL
107085 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107086 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107087 +cm4040_write_58079 cm4040_write 3 58079 NULL
107088 +udi_log_event_58105 udi_log_event 3 58105 NULL
107089 +savemem_58129 savemem 3 58129 NULL
107090 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107091 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107092 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107093 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107094 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107095 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107096 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107097 +read_file_debug_58256 read_file_debug 3 58256 NULL
107098 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107099 +profile_load_58267 profile_load 3 58267 NULL
107100 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107101 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107102 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107103 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107104 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107105 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107106 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107107 +next_pidmap_58347 next_pidmap 2 58347 NULL
107108 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107109 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107110 +save_hint_58359 save_hint 2 58359 NULL
107111 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107112 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107113 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107114 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107115 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107116 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107117 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107118 +capabilities_read_58457 capabilities_read 3 58457 NULL
107119 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107120 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107121 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107122 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107123 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107124 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107125 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107126 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107127 +__clear_discard_58546 __clear_discard 2 58546 NULL
107128 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107129 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107130 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107131 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107132 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107133 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107134 +xip_file_read_58592 xip_file_read 3 58592 NULL
107135 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107136 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107137 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107138 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107139 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107140 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107141 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107142 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107143 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107144 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107145 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107146 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107147 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107148 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107149 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107150 +acpi_map_58725 acpi_map 1-2 58725 NULL
107151 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107152 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107153 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107154 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107155 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107156 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107157 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107158 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107159 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107160 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107161 +ep_read_58813 ep_read 3 58813 NULL
107162 +command_write_58841 command_write 3 58841 NULL
107163 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107164 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107165 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107166 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107167 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107168 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107169 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107170 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107171 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107172 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107173 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107174 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107175 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107176 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107177 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107178 +ep_write_59008 ep_write 3 59008 NULL
107179 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107180 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107181 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107182 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107183 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107184 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107185 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107186 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107187 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107188 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107189 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107190 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107191 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107192 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107193 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107194 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107195 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107196 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107197 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107198 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107199 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107200 +dt3155_read_59226 dt3155_read 3 59226 NULL
107201 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107202 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107203 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107204 +nla_len_59258 nla_len 0 59258 NULL
107205 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107206 +fd_copyout_59323 fd_copyout 3 59323 NULL
107207 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107208 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107209 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107210 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107211 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107212 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107213 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107214 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107215 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107216 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107217 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107218 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107219 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107220 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107221 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107222 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107223 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107224 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107225 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107226 +tunables_write_59563 tunables_write 3 59563 NULL
107227 +memdup_user_59590 memdup_user 2 59590 NULL
107228 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107229 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107230 +mtrr_write_59622 mtrr_write 3 59622 NULL
107231 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107232 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107233 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107234 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107235 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107236 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107237 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107238 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107239 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107240 +sriov_enable_59689 sriov_enable 2 59689 NULL
107241 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107242 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107243 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107244 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107245 +strnlen_59746 strnlen 0 59746 NULL
107246 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107247 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107248 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107249 +venus_remove_59781 venus_remove 4 59781 NULL
107250 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107251 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107252 +ipw_write_59807 ipw_write 3 59807 NULL
107253 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107254 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107255 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107256 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107257 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107258 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107259 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107260 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107261 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107262 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107263 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107264 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107265 +lookup_node_59953 lookup_node 2 59953 NULL
107266 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107267 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107268 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107269 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107270 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107271 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107272 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107273 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107274 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107275 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107276 +register_device_60015 register_device 2-3 60015 NULL
107277 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107278 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107279 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107280 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107281 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107282 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107283 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107284 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107285 +compat_writev_60063 compat_writev 3 60063 NULL
107286 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107287 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107288 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107289 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107290 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107291 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107292 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107293 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107294 +init_state_60165 init_state 2 60165 NULL
107295 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107296 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107297 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107298 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107299 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107300 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107301 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107302 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107303 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107304 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107305 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107306 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107307 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107308 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107309 +printer_write_60276 printer_write 3 60276 NULL
107310 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107311 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107312 +getDataLength_60301 getDataLength 0 60301 NULL
107313 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107314 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107315 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107316 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107317 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107318 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107319 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107320 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107321 +driver_names_read_60399 driver_names_read 3 60399 NULL
107322 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107323 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107324 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107325 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107326 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107327 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107328 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107329 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107330 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107331 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107332 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107333 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107334 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107335 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107336 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107337 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107338 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107339 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107340 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107341 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107342 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107343 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107344 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107345 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107346 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107347 +init_data_container_60709 init_data_container 1 60709 NULL
107348 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107349 +raid_status_60755 raid_status 5 60755 NULL
107350 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107351 +opticon_write_60775 opticon_write 4 60775 NULL
107352 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107353 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107354 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107355 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107356 +generic_writepages_60871 generic_writepages 0 60871 NULL
107357 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107358 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107359 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107360 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107361 +sys_mlock_60932 sys_mlock 1 60932 NULL
107362 +pti_char_write_60960 pti_char_write 3 60960 NULL
107363 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107364 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107365 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107366 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107367 +symtab_init_61050 symtab_init 2 61050 NULL
107368 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107369 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107370 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107371 +get_derived_key_61100 get_derived_key 4 61100 NULL
107372 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107373 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107374 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107375 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107376 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107377 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107378 +__vmalloc_61168 __vmalloc 1 61168 NULL
107379 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107380 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107381 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107382 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107383 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107384 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107385 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107386 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107387 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107388 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107389 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107390 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107391 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107392 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107393 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107394 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107395 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107396 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107397 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107398 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107399 +change_xattr_61390 change_xattr 5 61390 NULL
107400 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107401 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107402 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107403 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107404 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107405 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107406 +erst_errno_61526 erst_errno 0 61526 NULL
107407 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107408 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107409 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107410 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107411 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107412 +seq_open_private_61589 seq_open_private 3 61589 NULL
107413 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107414 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107415 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107416 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107417 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107418 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107419 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107420 +resize_stripes_61650 resize_stripes 2 61650 NULL
107421 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107422 +insert_one_name_61668 insert_one_name 7 61668 NULL
107423 +lock_loop_61681 lock_loop 1 61681 NULL
107424 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107425 +filter_read_61692 filter_read 3 61692 NULL
107426 +iov_length_61716 iov_length 0 61716 NULL
107427 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107428 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107429 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107430 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107431 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107432 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107433 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107434 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107435 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107436 +get_fw_name_61874 get_fw_name 3 61874 NULL
107437 +free_init_pages_61875 free_init_pages 2 61875 NULL
107438 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107439 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107440 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107441 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107442 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107443 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107444 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107445 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107446 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107447 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107448 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107449 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107450 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107451 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107452 +cow_file_range_61979 cow_file_range 3 61979 NULL
107453 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107454 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107455 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107456 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107457 +SYSC_select_62024 SYSC_select 1 62024 NULL
107458 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107459 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107460 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107461 +do_pselect_62061 do_pselect 1 62061 NULL
107462 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107463 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107464 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107465 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107466 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107467 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107468 +ql_status_62135 ql_status 5 62135 NULL
107469 +video_usercopy_62151 video_usercopy 2 62151 NULL
107470 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107471 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107472 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107473 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107474 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107475 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107476 +allocate_partition_62245 allocate_partition 4 62245 NULL
107477 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107478 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107479 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107480 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107481 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107482 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107483 +subseq_list_62332 subseq_list 3-0 62332 NULL
107484 +flash_write_62354 flash_write 3 62354 NULL
107485 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107486 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107487 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107488 +altera_irscan_62396 altera_irscan 2 62396 NULL
107489 +set_ssp_62411 set_ssp 4 62411 NULL
107490 +unmap_single_62423 unmap_single 2 62423 NULL
107491 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107492 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107493 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107494 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107495 +remove_mapping_62491 remove_mapping 2 62491 NULL
107496 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107497 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107498 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107499 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107500 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107501 +debugfs_read_62535 debugfs_read 3 62535 NULL
107502 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107503 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107504 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107505 +get_subdir_62581 get_subdir 3 62581 NULL
107506 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107507 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107508 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107509 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107510 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107511 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107512 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107513 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107514 +write_62671 write 3 62671 NULL
107515 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107516 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107517 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107518 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107519 +rdm_62719 rdm 0 62719 NULL
107520 +key_replays_read_62746 key_replays_read 3 62746 NULL
107521 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107522 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107523 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107524 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107525 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107526 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107527 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107528 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107529 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107530 +set_swbp_62853 set_swbp 3 62853 NULL
107531 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107532 +aoechr_write_62883 aoechr_write 3 62883 NULL
107533 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107534 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107535 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107536 +getdqbuf_62908 getdqbuf 1 62908 NULL
107537 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107538 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107539 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107540 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107541 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107542 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107543 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107544 +unlink1_63059 unlink1 3 63059 NULL
107545 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107546 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107547 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107548 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107549 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107550 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107551 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107552 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107553 +vme_master_read_63221 vme_master_read 0 63221 NULL
107554 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107555 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107556 +ptp_read_63251 ptp_read 4 63251 NULL
107557 +raid5_resize_63306 raid5_resize 2 63306 NULL
107558 +proc_info_read_63344 proc_info_read 3 63344 NULL
107559 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107560 +idmouse_read_63374 idmouse_read 3 63374 NULL
107561 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107562 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107563 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
107564 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
107565 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
107566 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
107567 +kone_send_63435 kone_send 4 63435 NULL
107568 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
107569 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
107570 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
107571 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
107572 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
107573 +read_kcore_63488 read_kcore 3 63488 NULL
107574 +save_hint_63497 save_hint 2 63497 NULL
107575 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
107576 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
107577 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
107578 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
107579 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
107580 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
107581 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
107582 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
107583 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
107584 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
107585 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
107586 +module_alloc_63630 module_alloc 1 63630 NULL
107587 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
107588 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
107589 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
107590 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
107591 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
107592 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
107593 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
107594 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
107595 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
107596 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
107597 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
107598 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
107599 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
107600 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
107601 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
107602 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
107603 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
107604 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
107605 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
107606 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
107607 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
107608 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
107609 +prepare_copy_63826 prepare_copy 2 63826 NULL
107610 +sel_write_load_63830 sel_write_load 3 63830 NULL
107611 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
107612 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
107613 +divas_write_63901 divas_write 3 63901 NULL
107614 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
107615 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
107616 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
107617 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
107618 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
107619 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
107620 +__team_options_register_63941 __team_options_register 3 63941 NULL
107621 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
107622 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
107623 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
107624 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
107625 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
107626 +kmemdup_64015 kmemdup 2 64015 NULL
107627 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
107628 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
107629 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
107630 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
107631 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
107632 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
107633 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
107634 +get_u8_64076 get_u8 0 64076 NULL
107635 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
107636 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
107637 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
107638 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
107639 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
107640 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
107641 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
107642 +init_bch_64130 init_bch 1-2 64130 NULL
107643 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
107644 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
107645 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
107646 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
107647 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
107648 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
107649 +read_pulse_64227 read_pulse 0-3 64227 NULL
107650 +header_len_64232 header_len 0 64232 NULL
107651 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
107652 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
107653 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
107654 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
107655 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
107656 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
107657 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
107658 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
107659 +ffz_64324 ffz 0 64324 NULL
107660 +map_region_64328 map_region 1 64328 NULL
107661 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
107662 +ts_write_64336 ts_write 3 64336 NULL
107663 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
107664 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
107665 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
107666 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
107667 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
107668 +ilo_write_64378 ilo_write 3 64378 NULL
107669 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
107670 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
107671 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
107672 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
107673 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
107674 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
107675 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
107676 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
107677 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
107678 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
107679 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
107680 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
107681 +cap_capable_64462 cap_capable 0 64462 NULL
107682 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
107683 +single_open_size_64483 single_open_size 4 64483 NULL
107684 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
107685 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
107686 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
107687 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
107688 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
107689 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
107690 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
107691 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
107692 +SyS_bind_64544 SyS_bind 3 64544 NULL
107693 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
107694 +__spi_sync_64561 __spi_sync 0 64561 NULL
107695 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
107696 +fanotify_write_64623 fanotify_write 3 64623 NULL
107697 +to_dblock_64655 to_dblock 0-1 64655 NULL
107698 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
107699 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
107700 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
107701 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
107702 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
107703 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
107704 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
107705 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
107706 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
107707 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
107708 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
107709 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
107710 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
107711 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
107712 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
107713 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
107714 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
107715 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
107716 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
107717 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
107718 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
107719 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
107720 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
107721 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
107722 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
107723 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
107724 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
107725 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
107726 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
107727 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
107728 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
107729 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
107730 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
107731 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
107732 +pskb_pull_65005 pskb_pull 2 65005 NULL
107733 +unifi_write_65012 unifi_write 3 65012 NULL
107734 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
107735 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
107736 +insert_dent_65034 insert_dent 7 65034 NULL
107737 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
107738 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
107739 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
107740 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
107741 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
107742 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
107743 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
107744 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
107745 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
107746 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
107747 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
107748 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
107749 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
107750 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
107751 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
107752 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
107753 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
107754 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
107755 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
107756 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
107757 +get_var_len_65304 get_var_len 0 65304 NULL
107758 +unpack_array_65318 unpack_array 0 65318 NULL
107759 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
107760 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
107761 +init_list_set_65351 init_list_set 2-3 65351 NULL
107762 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
107763 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
107764 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
107765 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
107766 +strchr_65372 strchr 0 65372 NULL nohasharray
107767 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
107768 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
107769 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
107770 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
107771 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
107772 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
107773 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
107774 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
107775 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
107776 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
107777 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
107778 +alloc_dr_65495 alloc_dr 2 65495 NULL
107779 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
107780 new file mode 100644
107781 index 0000000..03d0c84
107782 --- /dev/null
107783 +++ b/tools/gcc/size_overflow_plugin.c
107784 @@ -0,0 +1,2113 @@
107785 +/*
107786 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
107787 + * Licensed under the GPL v2, or (at your option) v3
107788 + *
107789 + * Homepage:
107790 + * http://www.grsecurity.net/~ephox/overflow_plugin/
107791 + *
107792 + * Documentation:
107793 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
107794 + *
107795 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
107796 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
107797 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
107798 + *
107799 + * Usage:
107800 + * $ 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
107801 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
107802 + */
107803 +
107804 +#include "gcc-plugin.h"
107805 +#include "config.h"
107806 +#include "system.h"
107807 +#include "coretypes.h"
107808 +#include "tree.h"
107809 +#include "tree-pass.h"
107810 +#include "intl.h"
107811 +#include "plugin-version.h"
107812 +#include "tm.h"
107813 +#include "toplev.h"
107814 +#include "function.h"
107815 +#include "tree-flow.h"
107816 +#include "plugin.h"
107817 +#include "gimple.h"
107818 +#include "diagnostic.h"
107819 +#include "cfgloop.h"
107820 +
107821 +#if BUILDING_GCC_VERSION >= 4008
107822 +#define TODO_dump_func 0
107823 +#endif
107824 +
107825 +struct size_overflow_hash {
107826 + const struct size_overflow_hash * const next;
107827 + const char * const name;
107828 + const unsigned int param;
107829 +};
107830 +
107831 +#include "size_overflow_hash.h"
107832 +
107833 +enum mark {
107834 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
107835 +};
107836 +
107837 +enum err_code_conditions {
107838 + CAST_ONLY, FROM_CONST
107839 +};
107840 +
107841 +static unsigned int call_count = 0;
107842 +
107843 +#define __unused __attribute__((__unused__))
107844 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
107845 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
107846 +#define BEFORE_STMT true
107847 +#define AFTER_STMT false
107848 +#define CREATE_NEW_VAR NULL_TREE
107849 +#define CODES_LIMIT 32
107850 +#define MAX_PARAM 31
107851 +#define MY_STMT GF_PLF_1
107852 +#define NO_CAST_CHECK GF_PLF_2
107853 +#define FROM_ARG true
107854 +#define FROM_RET false
107855 +
107856 +#if BUILDING_GCC_VERSION == 4005
107857 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
107858 +#endif
107859 +
107860 +int plugin_is_GPL_compatible;
107861 +void debug_gimple_stmt(gimple gs);
107862 +
107863 +static tree expand(struct pointer_set_t *visited, tree lhs);
107864 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
107865 +static tree report_size_overflow_decl;
107866 +static const_tree const_char_ptr_type_node;
107867 +static unsigned int handle_function(void);
107868 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
107869 +static tree get_size_overflow_type(gimple stmt, const_tree node);
107870 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
107871 +static void print_missing_msg(tree func, unsigned int argnum);
107872 +
107873 +static struct plugin_info size_overflow_plugin_info = {
107874 + .version = "20130822beta",
107875 + .help = "no-size-overflow\tturn off size overflow checking\n",
107876 +};
107877 +
107878 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107879 +{
107880 + unsigned int arg_count;
107881 + enum tree_code code = TREE_CODE(*node);
107882 +
107883 + switch (code) {
107884 + case FUNCTION_DECL:
107885 + arg_count = type_num_arguments(TREE_TYPE(*node));
107886 + break;
107887 + case FUNCTION_TYPE:
107888 + case METHOD_TYPE:
107889 + arg_count = type_num_arguments(*node);
107890 + break;
107891 + default:
107892 + *no_add_attrs = true;
107893 + error("%s: %qE attribute only applies to functions", __func__, name);
107894 + return NULL_TREE;
107895 + }
107896 +
107897 + for (; args; args = TREE_CHAIN(args)) {
107898 + tree position = TREE_VALUE(args);
107899 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107900 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107901 + *no_add_attrs = true;
107902 + }
107903 + }
107904 + return NULL_TREE;
107905 +}
107906 +
107907 +static const char* get_asm_name(tree node)
107908 +{
107909 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
107910 +}
107911 +
107912 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107913 +{
107914 + unsigned int arg_count, arg_num;
107915 + enum tree_code code = TREE_CODE(*node);
107916 +
107917 + switch (code) {
107918 + case FUNCTION_DECL:
107919 + arg_count = type_num_arguments(TREE_TYPE(*node));
107920 + break;
107921 + case FUNCTION_TYPE:
107922 + case METHOD_TYPE:
107923 + arg_count = type_num_arguments(*node);
107924 + break;
107925 + case FIELD_DECL:
107926 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
107927 + if (arg_num != 0) {
107928 + *no_add_attrs = true;
107929 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
107930 + }
107931 + return NULL_TREE;
107932 + default:
107933 + *no_add_attrs = true;
107934 + error("%qE attribute only applies to functions", name);
107935 + return NULL_TREE;
107936 + }
107937 +
107938 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
107939 + return NULL_TREE;
107940 +
107941 + for (; args; args = TREE_CHAIN(args)) {
107942 + tree position = TREE_VALUE(args);
107943 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107944 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107945 + *no_add_attrs = true;
107946 + }
107947 + }
107948 + return NULL_TREE;
107949 +}
107950 +
107951 +static struct attribute_spec size_overflow_attr = {
107952 + .name = "size_overflow",
107953 + .min_length = 1,
107954 + .max_length = -1,
107955 + .decl_required = true,
107956 + .type_required = false,
107957 + .function_type_required = false,
107958 + .handler = handle_size_overflow_attribute,
107959 +#if BUILDING_GCC_VERSION >= 4007
107960 + .affects_type_identity = false
107961 +#endif
107962 +};
107963 +
107964 +static struct attribute_spec intentional_overflow_attr = {
107965 + .name = "intentional_overflow",
107966 + .min_length = 1,
107967 + .max_length = -1,
107968 + .decl_required = true,
107969 + .type_required = false,
107970 + .function_type_required = false,
107971 + .handler = handle_intentional_overflow_attribute,
107972 +#if BUILDING_GCC_VERSION >= 4007
107973 + .affects_type_identity = false
107974 +#endif
107975 +};
107976 +
107977 +static void register_attributes(void __unused *event_data, void __unused *data)
107978 +{
107979 + register_attribute(&size_overflow_attr);
107980 + register_attribute(&intentional_overflow_attr);
107981 +}
107982 +
107983 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
107984 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
107985 +{
107986 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
107987 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
107988 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
107989 +
107990 + unsigned int m = 0x57559429;
107991 + unsigned int n = 0x5052acdb;
107992 + const unsigned int *key4 = (const unsigned int *)key;
107993 + unsigned int h = len;
107994 + unsigned int k = len + seed + n;
107995 + unsigned long long p;
107996 +
107997 + while (len >= 8) {
107998 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
107999 + len -= 8;
108000 + }
108001 + if (len >= 4) {
108002 + cwmixb(key4[0]) key4 += 1;
108003 + len -= 4;
108004 + }
108005 + if (len)
108006 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108007 + cwmixb(h ^ (k + n));
108008 + return k ^ h;
108009 +
108010 +#undef cwfold
108011 +#undef cwmixa
108012 +#undef cwmixb
108013 +}
108014 +
108015 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108016 +{
108017 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108018 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108019 + return fn ^ codes;
108020 +}
108021 +
108022 +static inline tree get_original_function_decl(tree fndecl)
108023 +{
108024 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108025 + return DECL_ABSTRACT_ORIGIN(fndecl);
108026 + return fndecl;
108027 +}
108028 +
108029 +static inline gimple get_def_stmt(const_tree node)
108030 +{
108031 + gcc_assert(node != NULL_TREE);
108032 + if (TREE_CODE(node) != SSA_NAME)
108033 + return NULL;
108034 + return SSA_NAME_DEF_STMT(node);
108035 +}
108036 +
108037 +static unsigned char get_tree_code(const_tree type)
108038 +{
108039 + switch (TREE_CODE(type)) {
108040 + case ARRAY_TYPE:
108041 + return 0;
108042 + case BOOLEAN_TYPE:
108043 + return 1;
108044 + case ENUMERAL_TYPE:
108045 + return 2;
108046 + case FUNCTION_TYPE:
108047 + return 3;
108048 + case INTEGER_TYPE:
108049 + return 4;
108050 + case POINTER_TYPE:
108051 + return 5;
108052 + case RECORD_TYPE:
108053 + return 6;
108054 + case UNION_TYPE:
108055 + return 7;
108056 + case VOID_TYPE:
108057 + return 8;
108058 + case REAL_TYPE:
108059 + return 9;
108060 + case VECTOR_TYPE:
108061 + return 10;
108062 + case REFERENCE_TYPE:
108063 + return 11;
108064 + case OFFSET_TYPE:
108065 + return 12;
108066 + case COMPLEX_TYPE:
108067 + return 13;
108068 + default:
108069 + debug_tree((tree)type);
108070 + gcc_unreachable();
108071 + }
108072 +}
108073 +
108074 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108075 +{
108076 + gcc_assert(type != NULL_TREE);
108077 +
108078 + while (type && len < CODES_LIMIT) {
108079 + tree_codes[len] = get_tree_code(type);
108080 + len++;
108081 + type = TREE_TYPE(type);
108082 + }
108083 + return len;
108084 +}
108085 +
108086 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108087 +{
108088 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108089 + enum tree_code code = TREE_CODE(type);
108090 + size_t len = 0;
108091 +
108092 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108093 +
108094 + arg = TYPE_ARG_TYPES(type);
108095 + // skip builtins __builtin_constant_p
108096 + if (!arg && DECL_BUILT_IN(fndecl))
108097 + return 0;
108098 +
108099 + if (TREE_CODE_CLASS(code) == tcc_type)
108100 + result = type;
108101 + else
108102 + result = DECL_RESULT(fndecl);
108103 +
108104 + gcc_assert(result != NULL_TREE);
108105 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108106 +
108107 + if (arg == NULL_TREE) {
108108 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108109 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108110 + if (arg_field == NULL_TREE)
108111 + return 0;
108112 + arg = TREE_TYPE(arg_field);
108113 + len = add_type_codes(arg, tree_codes, len);
108114 + gcc_assert(len != 0);
108115 + return len;
108116 + }
108117 +
108118 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108119 + while (arg && len < CODES_LIMIT) {
108120 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108121 + arg = TREE_CHAIN(arg);
108122 + }
108123 +
108124 + gcc_assert(len != 0);
108125 + return len;
108126 +}
108127 +
108128 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108129 +{
108130 + unsigned int hash;
108131 + const struct size_overflow_hash *entry;
108132 + unsigned char tree_codes[CODES_LIMIT];
108133 + size_t len;
108134 + const char *func_name;
108135 +
108136 + fndecl = get_original_function_decl(fndecl);
108137 + len = get_function_decl(fndecl, tree_codes);
108138 + if (len == 0)
108139 + return NULL;
108140 +
108141 + func_name = get_asm_name(fndecl);
108142 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108143 +
108144 + entry = size_overflow_hash[hash];
108145 + while (entry) {
108146 + if (!strcmp(entry->name, func_name))
108147 + return entry;
108148 + entry = entry->next;
108149 + }
108150 +
108151 + return NULL;
108152 +}
108153 +
108154 +static bool is_bool(const_tree node)
108155 +{
108156 + const_tree type;
108157 +
108158 + if (node == NULL_TREE)
108159 + return false;
108160 +
108161 + type = TREE_TYPE(node);
108162 + if (!INTEGRAL_TYPE_P(type))
108163 + return false;
108164 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108165 + return true;
108166 + if (TYPE_PRECISION(type) == 1)
108167 + return true;
108168 + return false;
108169 +}
108170 +
108171 +static bool skip_types(const_tree var)
108172 +{
108173 + tree type;
108174 +
108175 + if (is_gimple_constant(var))
108176 + return true;
108177 +
108178 + switch (TREE_CODE(var)) {
108179 + case ADDR_EXPR:
108180 +#if BUILDING_GCC_VERSION >= 4006
108181 + case MEM_REF:
108182 +#endif
108183 + case ARRAY_REF:
108184 + case BIT_FIELD_REF:
108185 + case INDIRECT_REF:
108186 + case TARGET_MEM_REF:
108187 + return true;
108188 + case PARM_DECL:
108189 + case VAR_DECL:
108190 + case COMPONENT_REF:
108191 + return false;
108192 + default:
108193 + break;
108194 + }
108195 +
108196 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108197 +
108198 + type = TREE_TYPE(var);
108199 + switch (TREE_CODE(type)) {
108200 + case INTEGER_TYPE:
108201 + case ENUMERAL_TYPE:
108202 + return false;
108203 + case BOOLEAN_TYPE:
108204 + return is_bool(var);
108205 + default:
108206 + break;
108207 + }
108208 +
108209 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108210 +
108211 + type = TREE_TYPE(type);
108212 + gcc_assert(type != NULL_TREE);
108213 + switch (TREE_CODE(type)) {
108214 + case RECORD_TYPE:
108215 + case POINTER_TYPE:
108216 + case ARRAY_TYPE:
108217 + return true;
108218 + case VOID_TYPE:
108219 + case INTEGER_TYPE:
108220 + case UNION_TYPE:
108221 + return false;
108222 + default:
108223 + break;
108224 + }
108225 +
108226 + debug_tree((tree)var);
108227 + gcc_unreachable();
108228 +}
108229 +
108230 +static unsigned int find_arg_number(const_tree arg, tree func)
108231 +{
108232 + tree var;
108233 + unsigned int argnum = 1;
108234 +
108235 + if (TREE_CODE(arg) == SSA_NAME)
108236 + arg = SSA_NAME_VAR(arg);
108237 +
108238 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108239 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108240 + continue;
108241 + if (!skip_types(var))
108242 + return argnum;
108243 + }
108244 +
108245 + return 0;
108246 +}
108247 +
108248 +static tree create_new_var(tree type)
108249 +{
108250 + tree new_var = create_tmp_var(type, "cicus");
108251 +
108252 +#if BUILDING_GCC_VERSION <= 4007
108253 + add_referenced_var(new_var);
108254 +#endif
108255 + return new_var;
108256 +}
108257 +
108258 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108259 +{
108260 + gimple assign;
108261 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108262 + tree type = TREE_TYPE(rhs1);
108263 + tree lhs = create_new_var(type);
108264 +
108265 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108266 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108267 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108268 +
108269 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108270 + update_stmt(assign);
108271 + gimple_set_plf(assign, MY_STMT, true);
108272 + return assign;
108273 +}
108274 +
108275 +static tree cast_a_tree(tree type, tree var)
108276 +{
108277 + gcc_assert(type != NULL_TREE);
108278 + gcc_assert(var != NULL_TREE);
108279 + gcc_assert(fold_convertible_p(type, var));
108280 +
108281 + return fold_convert(type, var);
108282 +}
108283 +
108284 +static tree get_lhs(const_gimple stmt)
108285 +{
108286 + switch (gimple_code(stmt)) {
108287 + case GIMPLE_ASSIGN:
108288 + return gimple_get_lhs(stmt);
108289 + case GIMPLE_PHI:
108290 + return gimple_phi_result(stmt);
108291 + case GIMPLE_CALL:
108292 + return gimple_call_lhs(stmt);
108293 + default:
108294 + return NULL_TREE;
108295 + }
108296 +}
108297 +
108298 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108299 +{
108300 + const_gimple def_stmt = get_def_stmt(rhs);
108301 +
108302 + if (force)
108303 + return false;
108304 +
108305 + if (is_gimple_constant(rhs))
108306 + return false;
108307 +
108308 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108309 + return false;
108310 +
108311 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108312 + return false;
108313 +
108314 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108315 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108316 + return false;
108317 +
108318 + return true;
108319 +}
108320 +
108321 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108322 +{
108323 + gimple assign, def_stmt;
108324 +
108325 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108326 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108327 + gcc_unreachable();
108328 +
108329 + def_stmt = get_def_stmt(rhs);
108330 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108331 + return def_stmt;
108332 +
108333 + if (lhs == CREATE_NEW_VAR)
108334 + lhs = create_new_var(dst_type);
108335 +
108336 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108337 +
108338 + if (!gsi_end_p(*gsi)) {
108339 + location_t loc = gimple_location(gsi_stmt(*gsi));
108340 + gimple_set_location(assign, loc);
108341 + }
108342 +
108343 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108344 +
108345 + if (before)
108346 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108347 + else
108348 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108349 + update_stmt(assign);
108350 + gimple_set_plf(assign, MY_STMT, true);
108351 +
108352 + return assign;
108353 +}
108354 +
108355 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108356 +{
108357 + gimple_stmt_iterator gsi;
108358 + tree lhs;
108359 + const_gimple new_stmt;
108360 +
108361 + if (rhs == NULL_TREE)
108362 + return NULL_TREE;
108363 +
108364 + gsi = gsi_for_stmt(stmt);
108365 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108366 +
108367 + lhs = get_lhs(new_stmt);
108368 + gcc_assert(lhs != NULL_TREE);
108369 + return lhs;
108370 +}
108371 +
108372 +static tree cast_to_TI_type(gimple stmt, tree node)
108373 +{
108374 + gimple_stmt_iterator gsi;
108375 + gimple cast_stmt;
108376 + tree type = TREE_TYPE(node);
108377 +
108378 + if (types_compatible_p(type, intTI_type_node))
108379 + return node;
108380 +
108381 + gsi = gsi_for_stmt(stmt);
108382 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108383 + return gimple_get_lhs(cast_stmt);
108384 +}
108385 +
108386 +static void check_function_hash(const_gimple stmt)
108387 +{
108388 + tree func;
108389 + const struct size_overflow_hash *hash;
108390 +
108391 + if (gimple_code(stmt) != GIMPLE_CALL)
108392 + return;
108393 +
108394 + func = gimple_call_fndecl(stmt);
108395 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108396 + if (func == NULL_TREE)
108397 + return;
108398 +
108399 + hash = get_function_hash(func);
108400 + if (!hash)
108401 + print_missing_msg(func, 0);
108402 +}
108403 +
108404 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108405 +{
108406 + tree lhs, new_lhs;
108407 + gimple_stmt_iterator gsi;
108408 +
108409 + if (rhs1 == NULL_TREE) {
108410 + debug_gimple_stmt(oldstmt);
108411 + error("%s: rhs1 is NULL_TREE", __func__);
108412 + gcc_unreachable();
108413 + }
108414 +
108415 + switch (gimple_code(oldstmt)) {
108416 + case GIMPLE_ASM:
108417 + lhs = rhs1;
108418 + break;
108419 + case GIMPLE_CALL:
108420 + lhs = gimple_call_lhs(oldstmt);
108421 + break;
108422 + case GIMPLE_ASSIGN:
108423 + lhs = gimple_get_lhs(oldstmt);
108424 + break;
108425 + default:
108426 + debug_gimple_stmt(oldstmt);
108427 + gcc_unreachable();
108428 + }
108429 +
108430 + gsi = gsi_for_stmt(oldstmt);
108431 + pointer_set_insert(visited, oldstmt);
108432 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108433 + basic_block next_bb, cur_bb;
108434 + const_edge e;
108435 +
108436 + gcc_assert(before == false);
108437 + gcc_assert(stmt_can_throw_internal(oldstmt));
108438 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108439 + gcc_assert(!gsi_end_p(gsi));
108440 +
108441 + cur_bb = gimple_bb(oldstmt);
108442 + next_bb = cur_bb->next_bb;
108443 + e = find_edge(cur_bb, next_bb);
108444 + gcc_assert(e != NULL);
108445 + gcc_assert(e->flags & EDGE_FALLTHRU);
108446 +
108447 + gsi = gsi_after_labels(next_bb);
108448 + gcc_assert(!gsi_end_p(gsi));
108449 +
108450 + before = true;
108451 + oldstmt = gsi_stmt(gsi);
108452 + }
108453 +
108454 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108455 + return new_lhs;
108456 +}
108457 +
108458 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108459 +{
108460 + gimple stmt;
108461 + gimple_stmt_iterator gsi;
108462 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108463 +
108464 + if (gimple_plf(oldstmt, MY_STMT))
108465 + return lhs;
108466 +
108467 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108468 + rhs1 = gimple_assign_rhs1(oldstmt);
108469 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108470 + }
108471 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108472 + rhs2 = gimple_assign_rhs2(oldstmt);
108473 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108474 + }
108475 +
108476 + stmt = gimple_copy(oldstmt);
108477 + gimple_set_location(stmt, gimple_location(oldstmt));
108478 + gimple_set_plf(stmt, MY_STMT, true);
108479 +
108480 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108481 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108482 +
108483 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108484 +
108485 + new_var = create_new_var(size_overflow_type);
108486 + new_var = make_ssa_name(new_var, stmt);
108487 + gimple_set_lhs(stmt, new_var);
108488 +
108489 + if (rhs1 != NULL_TREE)
108490 + gimple_assign_set_rhs1(stmt, rhs1);
108491 +
108492 + if (rhs2 != NULL_TREE)
108493 + gimple_assign_set_rhs2(stmt, rhs2);
108494 +#if BUILDING_GCC_VERSION >= 4007
108495 + if (rhs3 != NULL_TREE)
108496 + gimple_assign_set_rhs3(stmt, rhs3);
108497 +#endif
108498 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108499 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108500 +
108501 + gsi = gsi_for_stmt(oldstmt);
108502 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108503 + update_stmt(stmt);
108504 + pointer_set_insert(visited, oldstmt);
108505 + return gimple_get_lhs(stmt);
108506 +}
108507 +
108508 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108509 +{
108510 + basic_block first_bb;
108511 + gimple assign;
108512 + gimple_stmt_iterator gsi;
108513 +
108514 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108515 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108516 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108517 +
108518 + gsi = gsi_start_bb(first_bb);
108519 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108520 + return gimple_get_lhs(assign);
108521 +}
108522 +
108523 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108524 +{
108525 + gimple_stmt_iterator gsi;
108526 + const_gimple assign;
108527 + gimple def_stmt = get_def_stmt(new_arg);
108528 +
108529 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108530 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108531 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108532 + } else {
108533 + gsi = gsi_for_stmt(def_stmt);
108534 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108535 + }
108536 +
108537 + return gimple_get_lhs(assign);
108538 +}
108539 +
108540 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108541 +{
108542 + basic_block bb;
108543 + gimple_stmt_iterator gsi;
108544 + const_gimple assign, def_stmt;
108545 +
108546 + def_stmt = get_def_stmt(arg);
108547 + bb = gimple_bb(def_stmt);
108548 + gcc_assert(bb->index != 0);
108549 + gsi = gsi_after_labels(bb);
108550 +
108551 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108552 + return gimple_get_lhs(assign);
108553 +}
108554 +
108555 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108556 +{
108557 + tree size_overflow_type;
108558 + const_gimple def_stmt = get_def_stmt(arg);
108559 +
108560 + if (phi_ssa_name != NULL_TREE)
108561 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108562 +
108563 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
108564 +
108565 + if (new_arg != NULL_TREE) {
108566 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
108567 + return use_phi_ssa_name(phi_ssa_name, new_arg);
108568 + }
108569 +
108570 + switch(gimple_code(def_stmt)) {
108571 + case GIMPLE_PHI:
108572 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
108573 + case GIMPLE_NOP:
108574 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
108575 + default:
108576 + debug_gimple_stmt((gimple)def_stmt);
108577 + gcc_unreachable();
108578 + }
108579 +}
108580 +
108581 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
108582 +{
108583 + basic_block bb;
108584 + gimple phi;
108585 + gimple_seq seq;
108586 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
108587 +
108588 + bb = gsi_bb(gsi);
108589 +
108590 + phi = create_phi_node(result, bb);
108591 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
108592 + seq = phi_nodes(bb);
108593 + gsi = gsi_last(seq);
108594 + gsi_remove(&gsi, false);
108595 +
108596 + gsi = gsi_for_stmt(oldstmt);
108597 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
108598 + gimple_set_bb(phi, bb);
108599 + gimple_set_plf(phi, MY_STMT, true);
108600 + return phi;
108601 +}
108602 +
108603 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
108604 +{
108605 + gimple new_phi = NULL;
108606 + gimple oldstmt = get_def_stmt(orig_result);
108607 + tree phi_ssa_name = NULL_TREE;
108608 + unsigned int i;
108609 +
108610 + pointer_set_insert(visited, oldstmt);
108611 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
108612 + tree arg, new_arg;
108613 +
108614 + arg = gimple_phi_arg_def(oldstmt, i);
108615 +
108616 + new_arg = expand(visited, arg);
108617 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
108618 + if (i == 0) {
108619 + phi_ssa_name = new_arg;
108620 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
108621 + }
108622 +
108623 + gcc_assert(new_phi != NULL);
108624 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
108625 + }
108626 +
108627 + gcc_assert(new_phi != NULL);
108628 + update_stmt(new_phi);
108629 + return gimple_phi_result(new_phi);
108630 +}
108631 +
108632 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
108633 +{
108634 + const_gimple assign;
108635 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108636 + tree origtype = TREE_TYPE(orig_rhs);
108637 +
108638 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
108639 +
108640 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108641 + return gimple_get_lhs(assign);
108642 +}
108643 +
108644 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
108645 +{
108646 + const_tree rhs1, lhs, rhs1_type, lhs_type;
108647 + enum machine_mode lhs_mode, rhs_mode;
108648 + gimple def_stmt = get_def_stmt(no_const_rhs);
108649 +
108650 + if (!gimple_assign_cast_p(def_stmt))
108651 + return false;
108652 +
108653 + rhs1 = gimple_assign_rhs1(def_stmt);
108654 + lhs = gimple_get_lhs(def_stmt);
108655 + rhs1_type = TREE_TYPE(rhs1);
108656 + lhs_type = TREE_TYPE(lhs);
108657 + rhs_mode = TYPE_MODE(rhs1_type);
108658 + lhs_mode = TYPE_MODE(lhs_type);
108659 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
108660 + return false;
108661 +
108662 + return true;
108663 +}
108664 +
108665 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
108666 +{
108667 + tree rhs1 = gimple_assign_rhs1(stmt);
108668 + tree lhs = gimple_get_lhs(stmt);
108669 + const_tree rhs1_type = TREE_TYPE(rhs1);
108670 + const_tree lhs_type = TREE_TYPE(lhs);
108671 +
108672 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
108673 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108674 +
108675 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
108676 +}
108677 +
108678 +static bool no_uses(tree node)
108679 +{
108680 + imm_use_iterator imm_iter;
108681 + use_operand_p use_p;
108682 +
108683 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
108684 + const_gimple use_stmt = USE_STMT(use_p);
108685 + if (use_stmt == NULL)
108686 + return true;
108687 + if (is_gimple_debug(use_stmt))
108688 + continue;
108689 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
108690 + continue;
108691 + return false;
108692 + }
108693 + return true;
108694 +}
108695 +
108696 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
108697 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
108698 +{
108699 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
108700 + gimple def_stmt = get_def_stmt(lhs);
108701 +
108702 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108703 + return false;
108704 +
108705 + rhs1 = gimple_assign_rhs1(def_stmt);
108706 + rhs_type = TREE_TYPE(rhs1);
108707 + lhs_type = TREE_TYPE(lhs);
108708 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
108709 + return false;
108710 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
108711 + return false;
108712 +
108713 + def_stmt = get_def_stmt(rhs1);
108714 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
108715 + return false;
108716 +
108717 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
108718 + return false;
108719 +
108720 + rhs1 = gimple_assign_rhs1(def_stmt);
108721 + rhs2 = gimple_assign_rhs2(def_stmt);
108722 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
108723 + return false;
108724 +
108725 + if (is_gimple_constant(rhs2))
108726 + not_const_rhs = rhs1;
108727 + else
108728 + not_const_rhs = rhs2;
108729 +
108730 + return no_uses(not_const_rhs);
108731 +}
108732 +
108733 +static bool skip_lhs_cast_check(const_gimple stmt)
108734 +{
108735 + const_tree rhs = gimple_assign_rhs1(stmt);
108736 + const_gimple def_stmt = get_def_stmt(rhs);
108737 +
108738 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
108739 + if (gimple_code(def_stmt) == GIMPLE_ASM)
108740 + return true;
108741 +
108742 + if (is_const_plus_unsigned_signed_truncation(rhs))
108743 + return true;
108744 +
108745 + return false;
108746 +}
108747 +
108748 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
108749 +{
108750 + bool cast_lhs, cast_rhs;
108751 + tree lhs = gimple_get_lhs(stmt);
108752 + tree rhs = gimple_assign_rhs1(stmt);
108753 + const_tree lhs_type = TREE_TYPE(lhs);
108754 + const_tree rhs_type = TREE_TYPE(rhs);
108755 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
108756 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
108757 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
108758 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
108759 +
108760 + static bool check_lhs[3][4] = {
108761 + // ss su us uu
108762 + { false, true, true, false }, // lhs > rhs
108763 + { false, false, false, false }, // lhs = rhs
108764 + { true, true, true, true }, // lhs < rhs
108765 + };
108766 +
108767 + static bool check_rhs[3][4] = {
108768 + // ss su us uu
108769 + { true, false, true, true }, // lhs > rhs
108770 + { true, false, true, true }, // lhs = rhs
108771 + { true, false, true, true }, // lhs < rhs
108772 + };
108773 +
108774 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
108775 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
108776 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108777 +
108778 + if (lhs_size > rhs_size) {
108779 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108780 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108781 + } else if (lhs_size == rhs_size) {
108782 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108783 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108784 + } else {
108785 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108786 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108787 + }
108788 +
108789 + if (!cast_lhs && !cast_rhs)
108790 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108791 +
108792 + if (cast_lhs && !skip_lhs_cast_check(stmt))
108793 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
108794 +
108795 + if (cast_rhs)
108796 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
108797 +
108798 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108799 +}
108800 +
108801 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
108802 +{
108803 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
108804 +
108805 + if (gimple_plf(stmt, MY_STMT))
108806 + return lhs;
108807 +
108808 + rhs1 = gimple_assign_rhs1(stmt);
108809 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
108810 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108811 +
108812 + new_rhs1 = expand(visited, rhs1);
108813 +
108814 + if (new_rhs1 == NULL_TREE)
108815 + return create_cast_assign(visited, stmt);
108816 +
108817 + if (gimple_plf(stmt, NO_CAST_CHECK))
108818 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108819 +
108820 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
108821 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
108822 +
108823 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
108824 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
108825 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108826 + }
108827 +
108828 + if (!gimple_assign_cast_p(stmt))
108829 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108830 +
108831 + return create_cast_overflow_check(visited, new_rhs1, stmt);
108832 +}
108833 +
108834 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
108835 +{
108836 + tree rhs1, lhs = gimple_get_lhs(stmt);
108837 + gimple def_stmt = get_def_stmt(lhs);
108838 +
108839 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
108840 + rhs1 = gimple_assign_rhs1(def_stmt);
108841 +
108842 + if (is_gimple_constant(rhs1))
108843 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108844 +
108845 + switch (TREE_CODE(rhs1)) {
108846 + case SSA_NAME:
108847 + return handle_unary_rhs(visited, def_stmt);
108848 + case ARRAY_REF:
108849 + case BIT_FIELD_REF:
108850 + case ADDR_EXPR:
108851 + case COMPONENT_REF:
108852 + case INDIRECT_REF:
108853 +#if BUILDING_GCC_VERSION >= 4006
108854 + case MEM_REF:
108855 +#endif
108856 + case TARGET_MEM_REF:
108857 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108858 + case PARM_DECL:
108859 + case VAR_DECL:
108860 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108861 +
108862 + default:
108863 + debug_gimple_stmt(def_stmt);
108864 + debug_tree(rhs1);
108865 + gcc_unreachable();
108866 + }
108867 +}
108868 +
108869 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
108870 +{
108871 + gimple cond_stmt;
108872 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
108873 +
108874 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
108875 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
108876 + update_stmt(cond_stmt);
108877 +}
108878 +
108879 +static tree create_string_param(tree string)
108880 +{
108881 + tree i_type, a_type;
108882 + const int length = TREE_STRING_LENGTH(string);
108883 +
108884 + gcc_assert(length > 0);
108885 +
108886 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
108887 + a_type = build_array_type(char_type_node, i_type);
108888 +
108889 + TREE_TYPE(string) = a_type;
108890 + TREE_CONSTANT(string) = 1;
108891 + TREE_READONLY(string) = 1;
108892 +
108893 + return build1(ADDR_EXPR, ptr_type_node, string);
108894 +}
108895 +
108896 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
108897 +{
108898 + gimple func_stmt;
108899 + const_gimple def_stmt;
108900 + const_tree loc_line;
108901 + tree loc_file, ssa_name, current_func;
108902 + expanded_location xloc;
108903 + char *ssa_name_buf;
108904 + int len;
108905 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
108906 +
108907 + def_stmt = get_def_stmt(arg);
108908 + xloc = expand_location(gimple_location(def_stmt));
108909 +
108910 + if (!gimple_has_location(def_stmt)) {
108911 + xloc = expand_location(gimple_location(stmt));
108912 + if (!gimple_has_location(stmt))
108913 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
108914 + }
108915 +
108916 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
108917 +
108918 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
108919 + loc_file = create_string_param(loc_file);
108920 +
108921 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
108922 + current_func = create_string_param(current_func);
108923 +
108924 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
108925 + call_count++;
108926 + 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);
108927 + gcc_assert(len > 0);
108928 + ssa_name = build_string(len + 1, ssa_name_buf);
108929 + free(ssa_name_buf);
108930 + ssa_name = create_string_param(ssa_name);
108931 +
108932 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
108933 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
108934 +
108935 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
108936 +}
108937 +
108938 +static void __unused print_the_code_insertions(const_gimple stmt)
108939 +{
108940 + location_t loc = gimple_location(stmt);
108941 +
108942 + inform(loc, "Integer size_overflow check applied here.");
108943 +}
108944 +
108945 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
108946 +{
108947 + basic_block cond_bb, join_bb, bb_true;
108948 + edge e;
108949 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108950 +
108951 + cond_bb = gimple_bb(stmt);
108952 + if (before)
108953 + gsi_prev(&gsi);
108954 + if (gsi_end_p(gsi))
108955 + e = split_block_after_labels(cond_bb);
108956 + else
108957 + e = split_block(cond_bb, gsi_stmt(gsi));
108958 + cond_bb = e->src;
108959 + join_bb = e->dest;
108960 + e->flags = EDGE_FALSE_VALUE;
108961 + e->probability = REG_BR_PROB_BASE;
108962 +
108963 + bb_true = create_empty_bb(cond_bb);
108964 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
108965 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
108966 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
108967 +
108968 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108969 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
108970 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
108971 +
108972 + if (current_loops != NULL) {
108973 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
108974 + add_bb_to_loop(bb_true, cond_bb->loop_father);
108975 + }
108976 +
108977 + insert_cond(cond_bb, arg, cond_code, type_value);
108978 + insert_cond_result(bb_true, stmt, arg, min);
108979 +
108980 +// print_the_code_insertions(stmt);
108981 +}
108982 +
108983 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
108984 +{
108985 + const_tree rhs_type = TREE_TYPE(rhs);
108986 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
108987 +
108988 + gcc_assert(rhs_type != NULL_TREE);
108989 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
108990 + return;
108991 +
108992 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
108993 +
108994 + if (is_const_plus_unsigned_signed_truncation(rhs))
108995 + return;
108996 +
108997 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
108998 + // typemax (-1) < typemin (0)
108999 + if (TREE_OVERFLOW(type_max))
109000 + return;
109001 +
109002 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109003 +
109004 + cast_rhs_type = TREE_TYPE(cast_rhs);
109005 + type_max_type = TREE_TYPE(type_max);
109006 + type_min_type = TREE_TYPE(type_min);
109007 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109008 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109009 +
109010 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109011 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109012 +}
109013 +
109014 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109015 +{
109016 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109017 + return false;
109018 + if (!is_gimple_constant(rhs))
109019 + return false;
109020 + return true;
109021 +}
109022 +
109023 +static tree get_def_stmt_rhs(const_tree var)
109024 +{
109025 + tree rhs1, def_stmt_rhs1;
109026 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109027 +
109028 + def_stmt = get_def_stmt(var);
109029 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109030 +
109031 + rhs1 = gimple_assign_rhs1(def_stmt);
109032 + rhs1_def_stmt = get_def_stmt(rhs1);
109033 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109034 + return rhs1;
109035 +
109036 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109037 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109038 +
109039 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109040 + case GIMPLE_CALL:
109041 + case GIMPLE_NOP:
109042 + case GIMPLE_ASM:
109043 + case GIMPLE_PHI:
109044 + return def_stmt_rhs1;
109045 + case GIMPLE_ASSIGN:
109046 + return rhs1;
109047 + default:
109048 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109049 + gcc_unreachable();
109050 + }
109051 +}
109052 +
109053 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109054 +{
109055 + tree new_rhs, orig_rhs;
109056 + void (*gimple_assign_set_rhs)(gimple, tree);
109057 + tree rhs1 = gimple_assign_rhs1(stmt);
109058 + tree rhs2 = gimple_assign_rhs2(stmt);
109059 + tree lhs = gimple_get_lhs(stmt);
109060 +
109061 + if (!check_overflow)
109062 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109063 +
109064 + if (change_rhs == NULL_TREE)
109065 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109066 +
109067 + if (new_rhs2 == NULL_TREE) {
109068 + orig_rhs = rhs1;
109069 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109070 + } else {
109071 + orig_rhs = rhs2;
109072 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109073 + }
109074 +
109075 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109076 +
109077 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109078 + gimple_assign_set_rhs(stmt, new_rhs);
109079 + update_stmt(stmt);
109080 +
109081 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109082 +}
109083 +
109084 +static bool is_subtraction_special(const_gimple stmt)
109085 +{
109086 + gimple rhs1_def_stmt, rhs2_def_stmt;
109087 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109088 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109089 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109090 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109091 +
109092 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109093 + return false;
109094 +
109095 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109096 +
109097 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109098 + return false;
109099 +
109100 + rhs1_def_stmt = get_def_stmt(rhs1);
109101 + rhs2_def_stmt = get_def_stmt(rhs2);
109102 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109103 + return false;
109104 +
109105 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109106 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109107 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109108 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109109 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109110 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109111 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109112 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109113 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109114 + return false;
109115 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109116 + return false;
109117 +
109118 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109119 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109120 + return true;
109121 +}
109122 +
109123 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109124 +{
109125 + tree new_rhs1, new_rhs2;
109126 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109127 + gimple assign, stmt = get_def_stmt(lhs);
109128 + tree rhs1 = gimple_assign_rhs1(stmt);
109129 + tree rhs2 = gimple_assign_rhs2(stmt);
109130 +
109131 + if (!is_subtraction_special(stmt))
109132 + return NULL_TREE;
109133 +
109134 + new_rhs1 = expand(visited, rhs1);
109135 + new_rhs2 = expand(visited, rhs2);
109136 +
109137 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109138 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109139 +
109140 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109141 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109142 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109143 + }
109144 +
109145 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109146 + new_lhs = gimple_get_lhs(assign);
109147 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109148 +
109149 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109150 +}
109151 +
109152 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109153 +{
109154 + const_gimple def_stmt;
109155 +
109156 + if (TREE_CODE(rhs) != SSA_NAME)
109157 + return false;
109158 +
109159 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109160 + return false;
109161 +
109162 + def_stmt = get_def_stmt(rhs);
109163 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109164 + return false;
109165 +
109166 + return true;
109167 +}
109168 +
109169 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109170 +{
109171 + tree rhs1, rhs2, new_lhs;
109172 + gimple def_stmt = get_def_stmt(lhs);
109173 + tree new_rhs1 = NULL_TREE;
109174 + tree new_rhs2 = NULL_TREE;
109175 +
109176 + rhs1 = gimple_assign_rhs1(def_stmt);
109177 + rhs2 = gimple_assign_rhs2(def_stmt);
109178 +
109179 + /* no DImode/TImode division in the 32/64 bit kernel */
109180 + switch (gimple_assign_rhs_code(def_stmt)) {
109181 + case RDIV_EXPR:
109182 + case TRUNC_DIV_EXPR:
109183 + case CEIL_DIV_EXPR:
109184 + case FLOOR_DIV_EXPR:
109185 + case ROUND_DIV_EXPR:
109186 + case TRUNC_MOD_EXPR:
109187 + case CEIL_MOD_EXPR:
109188 + case FLOOR_MOD_EXPR:
109189 + case ROUND_MOD_EXPR:
109190 + case EXACT_DIV_EXPR:
109191 + case POINTER_PLUS_EXPR:
109192 + case BIT_AND_EXPR:
109193 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109194 + default:
109195 + break;
109196 + }
109197 +
109198 + new_lhs = handle_integer_truncation(visited, lhs);
109199 + if (new_lhs != NULL_TREE)
109200 + return new_lhs;
109201 +
109202 + if (TREE_CODE(rhs1) == SSA_NAME)
109203 + new_rhs1 = expand(visited, rhs1);
109204 + if (TREE_CODE(rhs2) == SSA_NAME)
109205 + new_rhs2 = expand(visited, rhs2);
109206 +
109207 + if (is_a_neg_overflow(def_stmt, rhs2))
109208 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109209 + if (is_a_neg_overflow(def_stmt, rhs1))
109210 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109211 +
109212 +
109213 + if (is_a_constant_overflow(def_stmt, rhs2))
109214 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109215 + if (is_a_constant_overflow(def_stmt, rhs1))
109216 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109217 +
109218 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109219 +}
109220 +
109221 +#if BUILDING_GCC_VERSION >= 4007
109222 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109223 +{
109224 + if (is_gimple_constant(rhs))
109225 + return cast_a_tree(size_overflow_type, rhs);
109226 + if (TREE_CODE(rhs) != SSA_NAME)
109227 + return NULL_TREE;
109228 + return expand(visited, rhs);
109229 +}
109230 +
109231 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109232 +{
109233 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109234 + gimple def_stmt = get_def_stmt(lhs);
109235 +
109236 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109237 +
109238 + rhs1 = gimple_assign_rhs1(def_stmt);
109239 + rhs2 = gimple_assign_rhs2(def_stmt);
109240 + rhs3 = gimple_assign_rhs3(def_stmt);
109241 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109242 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109243 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109244 +
109245 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109246 +}
109247 +#endif
109248 +
109249 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109250 +{
109251 + const_tree type;
109252 + tree new_type;
109253 +
109254 + gcc_assert(node != NULL_TREE);
109255 +
109256 + type = TREE_TYPE(node);
109257 +
109258 + if (gimple_plf(stmt, MY_STMT))
109259 + return TREE_TYPE(node);
109260 +
109261 + switch (TYPE_MODE(type)) {
109262 + case QImode:
109263 + new_type = intHI_type_node;
109264 + break;
109265 + case HImode:
109266 + new_type = intSI_type_node;
109267 + break;
109268 + case SImode:
109269 + new_type = intDI_type_node;
109270 + break;
109271 + case DImode:
109272 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109273 + new_type = intDI_type_node;
109274 + else
109275 + new_type = intTI_type_node;
109276 + break;
109277 + default:
109278 + debug_tree((tree)node);
109279 + error("%s: unsupported gcc configuration.", __func__);
109280 + gcc_unreachable();
109281 + }
109282 +
109283 + if (TYPE_QUALS(type) != 0)
109284 + return build_qualified_type(new_type, TYPE_QUALS(type));
109285 + return new_type;
109286 +}
109287 +
109288 +static tree expand_visited(gimple def_stmt)
109289 +{
109290 + const_gimple next_stmt;
109291 + gimple_stmt_iterator gsi;
109292 + enum gimple_code code = gimple_code(def_stmt);
109293 +
109294 + if (code == GIMPLE_ASM)
109295 + return NULL_TREE;
109296 +
109297 + gsi = gsi_for_stmt(def_stmt);
109298 + gsi_next(&gsi);
109299 +
109300 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109301 + return NULL_TREE;
109302 + gcc_assert(!gsi_end_p(gsi));
109303 + next_stmt = gsi_stmt(gsi);
109304 +
109305 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109306 + return NULL_TREE;
109307 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109308 +
109309 + return get_lhs(next_stmt);
109310 +}
109311 +
109312 +static tree expand(struct pointer_set_t *visited, tree lhs)
109313 +{
109314 + gimple def_stmt;
109315 +
109316 + if (skip_types(lhs))
109317 + return NULL_TREE;
109318 +
109319 + def_stmt = get_def_stmt(lhs);
109320 +
109321 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109322 + return NULL_TREE;
109323 +
109324 + if (gimple_plf(def_stmt, MY_STMT))
109325 + return lhs;
109326 +
109327 + if (pointer_set_contains(visited, def_stmt))
109328 + return expand_visited(def_stmt);
109329 +
109330 + switch (gimple_code(def_stmt)) {
109331 + case GIMPLE_PHI:
109332 + return handle_phi(visited, lhs);
109333 + case GIMPLE_CALL:
109334 + case GIMPLE_ASM:
109335 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109336 + case GIMPLE_ASSIGN:
109337 + switch (gimple_num_ops(def_stmt)) {
109338 + case 2:
109339 + return handle_unary_ops(visited, def_stmt);
109340 + case 3:
109341 + return handle_binary_ops(visited, lhs);
109342 +#if BUILDING_GCC_VERSION >= 4007
109343 + case 4:
109344 + return handle_ternary_ops(visited, lhs);
109345 +#endif
109346 + }
109347 + default:
109348 + debug_gimple_stmt(def_stmt);
109349 + error("%s: unknown gimple code", __func__);
109350 + gcc_unreachable();
109351 + }
109352 +}
109353 +
109354 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109355 +{
109356 + const_gimple assign;
109357 + tree orig_type = TREE_TYPE(orig_node);
109358 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109359 +
109360 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109361 + return gimple_get_lhs(assign);
109362 +}
109363 +
109364 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109365 +{
109366 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109367 + update_stmt(stmt);
109368 +}
109369 +
109370 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109371 +{
109372 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109373 + update_stmt(stmt);
109374 +}
109375 +
109376 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109377 +{
109378 + tree arg;
109379 + const_tree origarg;
109380 +
109381 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109382 + return true;
109383 +
109384 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109385 + while (origarg && *argnum) {
109386 + (*argnum)--;
109387 + origarg = TREE_CHAIN(origarg);
109388 + }
109389 +
109390 + gcc_assert(*argnum == 0);
109391 +
109392 + gcc_assert(origarg != NULL_TREE);
109393 + *argnum = 0;
109394 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109395 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109396 + return true;
109397 + return false;
109398 +}
109399 +
109400 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109401 +{
109402 + gimple phi = get_def_stmt(result);
109403 + unsigned int i, n = gimple_phi_num_args(phi);
109404 +
109405 + if (!phi)
109406 + return MARK_NO;
109407 +
109408 + pointer_set_insert(visited, phi);
109409 + for (i = 0; i < n; i++) {
109410 + enum mark marked;
109411 + const_tree arg = gimple_phi_arg_def(phi, i);
109412 + marked = pre_expand(visited, search_err_code, arg);
109413 + if (marked != MARK_NO)
109414 + return marked;
109415 + }
109416 + return MARK_NO;
109417 +}
109418 +
109419 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109420 +{
109421 + gimple def_stmt = get_def_stmt(lhs);
109422 + const_tree rhs;
109423 +
109424 + if (!def_stmt)
109425 + return MARK_NO;
109426 +
109427 + rhs = gimple_assign_rhs1(def_stmt);
109428 +
109429 + def_stmt = get_def_stmt(rhs);
109430 + if (is_gimple_constant(rhs))
109431 + search_err_code[FROM_CONST] = true;
109432 +
109433 + return pre_expand(visited, search_err_code, rhs);
109434 +}
109435 +
109436 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109437 +{
109438 + gimple def_stmt = get_def_stmt(lhs);
109439 + const_tree rhs1, rhs2;
109440 + enum mark marked;
109441 +
109442 + if (!def_stmt)
109443 + return MARK_NO;
109444 +
109445 + search_err_code[CAST_ONLY] = false;
109446 +
109447 + rhs1 = gimple_assign_rhs1(def_stmt);
109448 + rhs2 = gimple_assign_rhs2(def_stmt);
109449 + marked = pre_expand(visited, search_err_code, rhs1);
109450 + if (marked != MARK_NO)
109451 + return marked;
109452 + return pre_expand(visited, search_err_code, rhs2);
109453 +}
109454 +
109455 +static const_tree search_field_decl(const_tree comp_ref)
109456 +{
109457 + const_tree field = NULL_TREE;
109458 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109459 +
109460 + for (i = 0; i < len; i++) {
109461 + field = TREE_OPERAND(comp_ref, i);
109462 + if (TREE_CODE(field) == FIELD_DECL)
109463 + break;
109464 + }
109465 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109466 + return field;
109467 +}
109468 +
109469 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109470 +{
109471 + const_tree attr, p;
109472 +
109473 + // 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);
109474 + if (fndecl == NULL_TREE)
109475 + return MARK_NO;
109476 +
109477 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109478 + if (!attr || !TREE_VALUE(attr))
109479 + return MARK_NO;
109480 +
109481 + p = TREE_VALUE(attr);
109482 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109483 + return MARK_TURN_OFF;
109484 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109485 + return MARK_NOT_INTENTIONAL;
109486 + if (argnum == 0) {
109487 + gcc_assert(current_function_decl == fndecl);
109488 + return MARK_NO;
109489 + }
109490 +
109491 + do {
109492 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109493 + return MARK_YES;
109494 + p = TREE_CHAIN(p);
109495 + } while (p);
109496 +
109497 + return MARK_NO;
109498 +}
109499 +
109500 +static void print_missing_msg(tree func, unsigned int argnum)
109501 +{
109502 + unsigned int new_hash;
109503 + size_t len;
109504 + unsigned char tree_codes[CODES_LIMIT];
109505 + location_t loc;
109506 + const char *curfunc;
109507 +
109508 + func = get_original_function_decl(func);
109509 + loc = DECL_SOURCE_LOCATION(func);
109510 + curfunc = get_asm_name(func);
109511 +
109512 + len = get_function_decl(func, tree_codes);
109513 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109514 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109515 +}
109516 +
109517 +static unsigned int search_missing_attribute(const_tree arg)
109518 +{
109519 + unsigned int argnum;
109520 + const struct size_overflow_hash *hash;
109521 + const_tree type = TREE_TYPE(arg);
109522 + tree func = get_original_function_decl(current_function_decl);
109523 +
109524 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109525 +
109526 + if (TREE_CODE(type) == POINTER_TYPE)
109527 + return 0;
109528 +
109529 + argnum = find_arg_number(arg, func);
109530 + if (argnum == 0)
109531 + return 0;
109532 +
109533 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109534 + return argnum;
109535 +
109536 + hash = get_function_hash(func);
109537 + if (!hash || !(hash->param & (1U << argnum))) {
109538 + print_missing_msg(func, argnum);
109539 + return 0;
109540 + }
109541 + return argnum;
109542 +}
109543 +
109544 +static enum mark is_already_marked(const_tree lhs)
109545 +{
109546 + unsigned int argnum;
109547 + const_tree fndecl;
109548 +
109549 + argnum = search_missing_attribute(lhs);
109550 + fndecl = get_original_function_decl(current_function_decl);
109551 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109552 + return MARK_YES;
109553 + return MARK_NO;
109554 +}
109555 +
109556 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109557 +{
109558 + const_gimple def_stmt;
109559 +
109560 + if (skip_types(lhs))
109561 + return MARK_NO;
109562 +
109563 + if (TREE_CODE(lhs) == PARM_DECL)
109564 + return is_already_marked(lhs);
109565 +
109566 + if (TREE_CODE(lhs) == COMPONENT_REF) {
109567 + const_tree field, attr;
109568 +
109569 + field = search_field_decl(lhs);
109570 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
109571 + if (!attr || !TREE_VALUE(attr))
109572 + return MARK_NO;
109573 + return MARK_YES;
109574 + }
109575 +
109576 + def_stmt = get_def_stmt(lhs);
109577 +
109578 + if (!def_stmt)
109579 + return MARK_NO;
109580 +
109581 + if (pointer_set_contains(visited, def_stmt))
109582 + return MARK_NO;
109583 +
109584 + switch (gimple_code(def_stmt)) {
109585 + case GIMPLE_NOP:
109586 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
109587 + return is_already_marked(lhs);
109588 + return MARK_NO;
109589 + case GIMPLE_PHI:
109590 + return walk_phi(visited, search_err_code, lhs);
109591 + case GIMPLE_CALL:
109592 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
109593 + return MARK_TURN_OFF;
109594 + check_function_hash(def_stmt);
109595 + return MARK_NO;
109596 + case GIMPLE_ASM:
109597 + search_err_code[CAST_ONLY] = false;
109598 + return MARK_NO;
109599 + case GIMPLE_ASSIGN:
109600 + switch (gimple_num_ops(def_stmt)) {
109601 + case 2:
109602 + return walk_unary_ops(visited, search_err_code, lhs);
109603 + case 3:
109604 + return walk_binary_ops(visited, search_err_code, lhs);
109605 + }
109606 + default:
109607 + debug_gimple_stmt((gimple)def_stmt);
109608 + error("%s: unknown gimple code", __func__);
109609 + gcc_unreachable();
109610 + }
109611 +}
109612 +
109613 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
109614 +static bool skip_asm(const_tree arg)
109615 +{
109616 + gimple def_stmt = get_def_stmt(arg);
109617 +
109618 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109619 + return false;
109620 +
109621 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
109622 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
109623 +}
109624 +
109625 +/*
109626 +0</MARK_YES: no dup, search attributes (so, int)
109627 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
109628 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
109629 +*/
109630 +
109631 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
109632 +{
109633 + struct pointer_set_t *visited;
109634 + enum mark is_marked, is_found;
109635 + location_t loc;
109636 + bool search_err_code[2] = {true, false};
109637 +
109638 + is_marked = mark_status(current_function_decl, 0);
109639 + if (is_marked == MARK_TURN_OFF)
109640 + return true;
109641 +
109642 + is_marked = mark_status(fndecl, argnum + 1);
109643 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
109644 + return true;
109645 +
109646 + visited = pointer_set_create();
109647 + is_found = pre_expand(visited, search_err_code, arg);
109648 + pointer_set_destroy(visited);
109649 +
109650 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
109651 + return true;
109652 +
109653 + if (where == FROM_ARG && skip_asm(arg))
109654 + return true;
109655 +
109656 + if (is_found == MARK_TURN_OFF)
109657 + return true;
109658 +
109659 + if ((is_found == MARK_YES && is_marked == MARK_YES))
109660 + return true;
109661 +
109662 + if (is_found == MARK_YES) {
109663 + loc = DECL_SOURCE_LOCATION(fndecl);
109664 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
109665 + return true;
109666 + }
109667 + return false;
109668 +}
109669 +
109670 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
109671 +{
109672 + struct pointer_set_t *visited;
109673 + tree arg, new_arg;
109674 + bool match;
109675 +
109676 + if (argnum == 0)
109677 + return;
109678 +
109679 + argnum--;
109680 +
109681 + match = get_function_arg(&argnum, fndecl);
109682 + if (!match)
109683 + return;
109684 + gcc_assert(gimple_call_num_args(stmt) > argnum);
109685 + arg = gimple_call_arg(stmt, argnum);
109686 + if (arg == NULL_TREE)
109687 + return;
109688 +
109689 + if (skip_types(arg))
109690 + return;
109691 +
109692 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
109693 + return;
109694 +
109695 + visited = pointer_set_create();
109696 + new_arg = expand(visited, arg);
109697 + pointer_set_destroy(visited);
109698 +
109699 + if (new_arg == NULL_TREE)
109700 + return;
109701 +
109702 + change_function_arg(stmt, arg, argnum, new_arg);
109703 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
109704 +}
109705 +
109706 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
109707 +{
109708 + tree p = TREE_VALUE(attr);
109709 + do {
109710 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
109711 + p = TREE_CHAIN(p);
109712 + } while (p);
109713 +}
109714 +
109715 +static void handle_function_by_hash(gimple stmt, tree fndecl)
109716 +{
109717 + unsigned int num;
109718 + const struct size_overflow_hash *hash;
109719 +
109720 + hash = get_function_hash(fndecl);
109721 + if (!hash)
109722 + return;
109723 +
109724 + for (num = 0; num <= MAX_PARAM; num++)
109725 + if (hash->param & (1U << num))
109726 + handle_function_arg(stmt, fndecl, num);
109727 +}
109728 +
109729 +static bool check_return_value(void)
109730 +{
109731 + const struct size_overflow_hash *hash;
109732 +
109733 + hash = get_function_hash(current_function_decl);
109734 + if (!hash || !(hash->param & 1U << 0))
109735 + return false;
109736 +
109737 + return true;
109738 +}
109739 +
109740 +static void handle_return_value(gimple ret_stmt)
109741 +{
109742 + struct pointer_set_t *visited;
109743 + tree ret, new_ret;
109744 +
109745 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
109746 + return;
109747 +
109748 + ret = gimple_return_retval(ret_stmt);
109749 +
109750 + if (skip_types(ret))
109751 + return;
109752 +
109753 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
109754 + return;
109755 +
109756 + visited = pointer_set_create();
109757 + new_ret = expand(visited, ret);
109758 + pointer_set_destroy(visited);
109759 +
109760 + change_function_return(ret_stmt, ret, new_ret);
109761 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
109762 +}
109763 +
109764 +static void set_plf_false(void)
109765 +{
109766 + basic_block bb;
109767 +
109768 + FOR_ALL_BB(bb) {
109769 + gimple_stmt_iterator si;
109770 +
109771 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
109772 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109773 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
109774 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109775 + }
109776 +}
109777 +
109778 +static unsigned int handle_function(void)
109779 +{
109780 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
109781 + bool check_ret;
109782 +
109783 + set_plf_false();
109784 +
109785 + check_ret = check_return_value();
109786 +
109787 + do {
109788 + gimple_stmt_iterator gsi;
109789 + next = bb->next_bb;
109790 +
109791 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109792 + tree fndecl, attr;
109793 + gimple stmt = gsi_stmt(gsi);
109794 +
109795 + if (check_ret)
109796 + handle_return_value(stmt);
109797 +
109798 + if (!(is_gimple_call(stmt)))
109799 + continue;
109800 + fndecl = gimple_call_fndecl(stmt);
109801 + if (fndecl == NULL_TREE)
109802 + continue;
109803 + if (gimple_call_num_args(stmt) == 0)
109804 + continue;
109805 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
109806 + if (!attr || !TREE_VALUE(attr))
109807 + handle_function_by_hash(stmt, fndecl);
109808 + else
109809 + handle_function_by_attribute(stmt, attr, fndecl);
109810 + gsi = gsi_for_stmt(stmt);
109811 + next = gimple_bb(stmt)->next_bb;
109812 + }
109813 + bb = next;
109814 + } while (bb);
109815 + return 0;
109816 +}
109817 +
109818 +static struct gimple_opt_pass size_overflow_pass = {
109819 + .pass = {
109820 + .type = GIMPLE_PASS,
109821 + .name = "size_overflow",
109822 +#if BUILDING_GCC_VERSION >= 4008
109823 + .optinfo_flags = OPTGROUP_NONE,
109824 +#endif
109825 + .gate = NULL,
109826 + .execute = handle_function,
109827 + .sub = NULL,
109828 + .next = NULL,
109829 + .static_pass_number = 0,
109830 + .tv_id = TV_NONE,
109831 + .properties_required = PROP_cfg,
109832 + .properties_provided = 0,
109833 + .properties_destroyed = 0,
109834 + .todo_flags_start = 0,
109835 + .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
109836 + }
109837 +};
109838 +
109839 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
109840 +{
109841 + tree fntype;
109842 +
109843 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
109844 +
109845 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
109846 + fntype = build_function_type_list(void_type_node,
109847 + const_char_ptr_type_node,
109848 + unsigned_type_node,
109849 + const_char_ptr_type_node,
109850 + const_char_ptr_type_node,
109851 + NULL_TREE);
109852 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
109853 +
109854 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
109855 + TREE_PUBLIC(report_size_overflow_decl) = 1;
109856 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
109857 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
109858 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
109859 +}
109860 +
109861 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109862 +{
109863 + int i;
109864 + const char * const plugin_name = plugin_info->base_name;
109865 + const int argc = plugin_info->argc;
109866 + const struct plugin_argument * const argv = plugin_info->argv;
109867 + bool enable = true;
109868 +
109869 + struct register_pass_info size_overflow_pass_info = {
109870 + .pass = &size_overflow_pass.pass,
109871 + .reference_pass_name = "ssa",
109872 + .ref_pass_instance_number = 1,
109873 + .pos_op = PASS_POS_INSERT_AFTER
109874 + };
109875 +
109876 + if (!plugin_default_version_check(version, &gcc_version)) {
109877 + error(G_("incompatible gcc/plugin versions"));
109878 + return 1;
109879 + }
109880 +
109881 + for (i = 0; i < argc; ++i) {
109882 + if (!strcmp(argv[i].key, "no-size-overflow")) {
109883 + enable = false;
109884 + continue;
109885 + }
109886 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109887 + }
109888 +
109889 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
109890 + if (enable) {
109891 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
109892 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
109893 + }
109894 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109895 +
109896 + return 0;
109897 +}
109898 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
109899 new file mode 100644
109900 index 0000000..ac2901e
109901 --- /dev/null
109902 +++ b/tools/gcc/stackleak_plugin.c
109903 @@ -0,0 +1,327 @@
109904 +/*
109905 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
109906 + * Licensed under the GPL v2
109907 + *
109908 + * Note: the choice of the license means that the compilation process is
109909 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
109910 + * but for the kernel it doesn't matter since it doesn't link against
109911 + * any of the gcc libraries
109912 + *
109913 + * gcc plugin to help implement various PaX features
109914 + *
109915 + * - track lowest stack pointer
109916 + *
109917 + * TODO:
109918 + * - initialize all local variables
109919 + *
109920 + * BUGS:
109921 + * - none known
109922 + */
109923 +#include "gcc-plugin.h"
109924 +#include "config.h"
109925 +#include "system.h"
109926 +#include "coretypes.h"
109927 +#include "tree.h"
109928 +#include "tree-pass.h"
109929 +#include "flags.h"
109930 +#include "intl.h"
109931 +#include "toplev.h"
109932 +#include "plugin.h"
109933 +//#include "expr.h" where are you...
109934 +#include "diagnostic.h"
109935 +#include "plugin-version.h"
109936 +#include "tm.h"
109937 +#include "function.h"
109938 +#include "basic-block.h"
109939 +#include "gimple.h"
109940 +#include "rtl.h"
109941 +#include "emit-rtl.h"
109942 +
109943 +#if BUILDING_GCC_VERSION >= 4008
109944 +#define TODO_dump_func 0
109945 +#endif
109946 +
109947 +extern void print_gimple_stmt(FILE *, gimple, int, int);
109948 +
109949 +int plugin_is_GPL_compatible;
109950 +
109951 +static int track_frame_size = -1;
109952 +static const char track_function[] = "pax_track_stack";
109953 +static const char check_function[] = "pax_check_alloca";
109954 +static bool init_locals;
109955 +
109956 +static struct plugin_info stackleak_plugin_info = {
109957 + .version = "201302112000",
109958 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
109959 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
109960 +};
109961 +
109962 +static bool gate_stackleak_track_stack(void);
109963 +static unsigned int execute_stackleak_tree_instrument(void);
109964 +static unsigned int execute_stackleak_final(void);
109965 +
109966 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
109967 + .pass = {
109968 + .type = GIMPLE_PASS,
109969 + .name = "stackleak_tree_instrument",
109970 +#if BUILDING_GCC_VERSION >= 4008
109971 + .optinfo_flags = OPTGROUP_NONE,
109972 +#endif
109973 + .gate = gate_stackleak_track_stack,
109974 + .execute = execute_stackleak_tree_instrument,
109975 + .sub = NULL,
109976 + .next = NULL,
109977 + .static_pass_number = 0,
109978 + .tv_id = TV_NONE,
109979 + .properties_required = PROP_gimple_leh | PROP_cfg,
109980 + .properties_provided = 0,
109981 + .properties_destroyed = 0,
109982 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
109983 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
109984 + }
109985 +};
109986 +
109987 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
109988 + .pass = {
109989 + .type = RTL_PASS,
109990 + .name = "stackleak_final",
109991 +#if BUILDING_GCC_VERSION >= 4008
109992 + .optinfo_flags = OPTGROUP_NONE,
109993 +#endif
109994 + .gate = gate_stackleak_track_stack,
109995 + .execute = execute_stackleak_final,
109996 + .sub = NULL,
109997 + .next = NULL,
109998 + .static_pass_number = 0,
109999 + .tv_id = TV_NONE,
110000 + .properties_required = 0,
110001 + .properties_provided = 0,
110002 + .properties_destroyed = 0,
110003 + .todo_flags_start = 0,
110004 + .todo_flags_finish = TODO_dump_func
110005 + }
110006 +};
110007 +
110008 +static bool gate_stackleak_track_stack(void)
110009 +{
110010 + return track_frame_size >= 0;
110011 +}
110012 +
110013 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110014 +{
110015 + gimple check_alloca;
110016 + tree fntype, fndecl, alloca_size;
110017 +
110018 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110019 + fndecl = build_fn_decl(check_function, fntype);
110020 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110021 +
110022 + // insert call to void pax_check_alloca(unsigned long size)
110023 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110024 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110025 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110026 +}
110027 +
110028 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110029 +{
110030 + gimple track_stack;
110031 + tree fntype, fndecl;
110032 +
110033 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110034 + fndecl = build_fn_decl(track_function, fntype);
110035 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110036 +
110037 + // insert call to void pax_track_stack(void)
110038 + track_stack = gimple_build_call(fndecl, 0);
110039 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110040 +}
110041 +
110042 +#if BUILDING_GCC_VERSION == 4005
110043 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110044 +{
110045 + tree fndecl;
110046 +
110047 + if (!is_gimple_call(stmt))
110048 + return false;
110049 + fndecl = gimple_call_fndecl(stmt);
110050 + if (!fndecl)
110051 + return false;
110052 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110053 + return false;
110054 +// print_node(stderr, "pax", fndecl, 4);
110055 + return DECL_FUNCTION_CODE(fndecl) == code;
110056 +}
110057 +#endif
110058 +
110059 +static bool is_alloca(gimple stmt)
110060 +{
110061 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110062 + return true;
110063 +
110064 +#if BUILDING_GCC_VERSION >= 4007
110065 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110066 + return true;
110067 +#endif
110068 +
110069 + return false;
110070 +}
110071 +
110072 +static unsigned int execute_stackleak_tree_instrument(void)
110073 +{
110074 + basic_block bb, entry_bb;
110075 + bool prologue_instrumented = false, is_leaf = true;
110076 +
110077 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110078 +
110079 + // 1. loop through BBs and GIMPLE statements
110080 + FOR_EACH_BB(bb) {
110081 + gimple_stmt_iterator gsi;
110082 +
110083 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110084 + gimple stmt;
110085 +
110086 + stmt = gsi_stmt(gsi);
110087 +
110088 + if (is_gimple_call(stmt))
110089 + is_leaf = false;
110090 +
110091 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110092 + if (!is_alloca(stmt))
110093 + continue;
110094 +
110095 + // 2. insert stack overflow check before each __builtin_alloca call
110096 + stackleak_check_alloca(&gsi);
110097 +
110098 + // 3. insert track call after each __builtin_alloca call
110099 + stackleak_add_instrumentation(&gsi);
110100 + if (bb == entry_bb)
110101 + prologue_instrumented = true;
110102 + }
110103 + }
110104 +
110105 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110106 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110107 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110108 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110109 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110110 + return 0;
110111 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110112 + return 0;
110113 +
110114 + // 4. insert track call at the beginning
110115 + if (!prologue_instrumented) {
110116 + gimple_stmt_iterator gsi;
110117 +
110118 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110119 + if (dom_info_available_p(CDI_DOMINATORS))
110120 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110121 + gsi = gsi_start_bb(bb);
110122 + stackleak_add_instrumentation(&gsi);
110123 + }
110124 +
110125 + return 0;
110126 +}
110127 +
110128 +static unsigned int execute_stackleak_final(void)
110129 +{
110130 + rtx insn, next;
110131 +
110132 + if (cfun->calls_alloca)
110133 + return 0;
110134 +
110135 + // keep calls only if function frame is big enough
110136 + if (get_frame_size() >= track_frame_size)
110137 + return 0;
110138 +
110139 + // 1. find pax_track_stack calls
110140 + for (insn = get_insns(); insn; insn = next) {
110141 + // 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))
110142 + rtx body;
110143 +
110144 + next = NEXT_INSN(insn);
110145 + if (!CALL_P(insn))
110146 + continue;
110147 + body = PATTERN(insn);
110148 + if (GET_CODE(body) != CALL)
110149 + continue;
110150 + body = XEXP(body, 0);
110151 + if (GET_CODE(body) != MEM)
110152 + continue;
110153 + body = XEXP(body, 0);
110154 + if (GET_CODE(body) != SYMBOL_REF)
110155 + continue;
110156 + if (strcmp(XSTR(body, 0), track_function))
110157 + continue;
110158 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110159 + // 2. delete call
110160 + delete_insn_and_edges(insn);
110161 +#if BUILDING_GCC_VERSION >= 4007
110162 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110163 + insn = next;
110164 + next = NEXT_INSN(insn);
110165 + delete_insn_and_edges(insn);
110166 + }
110167 +#endif
110168 + }
110169 +
110170 +// print_simple_rtl(stderr, get_insns());
110171 +// print_rtl(stderr, get_insns());
110172 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110173 +
110174 + return 0;
110175 +}
110176 +
110177 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110178 +{
110179 + const char * const plugin_name = plugin_info->base_name;
110180 + const int argc = plugin_info->argc;
110181 + const struct plugin_argument * const argv = plugin_info->argv;
110182 + int i;
110183 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110184 + .pass = &stackleak_tree_instrument_pass.pass,
110185 +// .reference_pass_name = "tree_profile",
110186 + .reference_pass_name = "optimized",
110187 + .ref_pass_instance_number = 1,
110188 + .pos_op = PASS_POS_INSERT_BEFORE
110189 + };
110190 + struct register_pass_info stackleak_final_pass_info = {
110191 + .pass = &stackleak_final_rtl_opt_pass.pass,
110192 + .reference_pass_name = "final",
110193 + .ref_pass_instance_number = 1,
110194 + .pos_op = PASS_POS_INSERT_BEFORE
110195 + };
110196 +
110197 + if (!plugin_default_version_check(version, &gcc_version)) {
110198 + error(G_("incompatible gcc/plugin versions"));
110199 + return 1;
110200 + }
110201 +
110202 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110203 +
110204 + for (i = 0; i < argc; ++i) {
110205 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110206 + if (!argv[i].value) {
110207 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110208 + continue;
110209 + }
110210 + track_frame_size = atoi(argv[i].value);
110211 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110212 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110213 + continue;
110214 + }
110215 + if (!strcmp(argv[i].key, "initialize-locals")) {
110216 + if (argv[i].value) {
110217 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110218 + continue;
110219 + }
110220 + init_locals = true;
110221 + continue;
110222 + }
110223 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110224 + }
110225 +
110226 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110227 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110228 +
110229 + return 0;
110230 +}
110231 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110232 new file mode 100644
110233 index 0000000..4fae911
110234 --- /dev/null
110235 +++ b/tools/gcc/structleak_plugin.c
110236 @@ -0,0 +1,277 @@
110237 +/*
110238 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110239 + * Licensed under the GPL v2
110240 + *
110241 + * Note: the choice of the license means that the compilation process is
110242 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110243 + * but for the kernel it doesn't matter since it doesn't link against
110244 + * any of the gcc libraries
110245 + *
110246 + * gcc plugin to forcibly initialize certain local variables that could
110247 + * otherwise leak kernel stack to userland if they aren't properly initialized
110248 + * by later code
110249 + *
110250 + * Homepage: http://pax.grsecurity.net/
110251 + *
110252 + * Usage:
110253 + * $ # for 4.5/4.6/C based 4.7
110254 + * $ 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
110255 + * $ # for C++ based 4.7/4.8+
110256 + * $ 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
110257 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110258 + *
110259 + * TODO: eliminate redundant initializers
110260 + * increase type coverage
110261 + */
110262 +
110263 +#include "gcc-plugin.h"
110264 +#include "config.h"
110265 +#include "system.h"
110266 +#include "coretypes.h"
110267 +#include "tree.h"
110268 +#include "tree-pass.h"
110269 +#include "intl.h"
110270 +#include "plugin-version.h"
110271 +#include "tm.h"
110272 +#include "toplev.h"
110273 +#include "function.h"
110274 +#include "tree-flow.h"
110275 +#include "plugin.h"
110276 +#include "gimple.h"
110277 +#include "diagnostic.h"
110278 +#include "cfgloop.h"
110279 +#include "langhooks.h"
110280 +
110281 +#if BUILDING_GCC_VERSION >= 4008
110282 +#define TODO_dump_func 0
110283 +#endif
110284 +
110285 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110286 +
110287 +// unused type flag in all versions 4.5-4.8
110288 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110289 +
110290 +int plugin_is_GPL_compatible;
110291 +void debug_gimple_stmt(gimple gs);
110292 +
110293 +static struct plugin_info structleak_plugin_info = {
110294 + .version = "201304082245",
110295 + .help = "disable\tdo not activate plugin\n",
110296 +};
110297 +
110298 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110299 +{
110300 + *no_add_attrs = true;
110301 +
110302 + // check for types? for now accept everything linux has to offer
110303 + if (TREE_CODE(*node) != FIELD_DECL)
110304 + return NULL_TREE;
110305 +
110306 + *no_add_attrs = false;
110307 + return NULL_TREE;
110308 +}
110309 +
110310 +static struct attribute_spec user_attr = {
110311 + .name = "user",
110312 + .min_length = 0,
110313 + .max_length = 0,
110314 + .decl_required = false,
110315 + .type_required = false,
110316 + .function_type_required = false,
110317 + .handler = handle_user_attribute,
110318 +#if BUILDING_GCC_VERSION >= 4007
110319 + .affects_type_identity = true
110320 +#endif
110321 +};
110322 +
110323 +static void register_attributes(void *event_data, void *data)
110324 +{
110325 + register_attribute(&user_attr);
110326 +// register_attribute(&force_attr);
110327 +}
110328 +
110329 +static tree get_field_type(tree field)
110330 +{
110331 + return strip_array_types(TREE_TYPE(field));
110332 +}
110333 +
110334 +static bool is_userspace_type(tree type)
110335 +{
110336 + tree field;
110337 +
110338 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110339 + tree fieldtype = get_field_type(field);
110340 + enum tree_code code = TREE_CODE(fieldtype);
110341 +
110342 + if (code == RECORD_TYPE || code == UNION_TYPE)
110343 + if (is_userspace_type(fieldtype))
110344 + return true;
110345 +
110346 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110347 + return true;
110348 + }
110349 + return false;
110350 +}
110351 +
110352 +static void finish_type(void *event_data, void *data)
110353 +{
110354 + tree type = (tree)event_data;
110355 +
110356 + if (TYPE_USERSPACE(type))
110357 + return;
110358 +
110359 + if (is_userspace_type(type))
110360 + TYPE_USERSPACE(type) = 1;
110361 +}
110362 +
110363 +static void initialize(tree var)
110364 +{
110365 + basic_block bb;
110366 + gimple_stmt_iterator gsi;
110367 + tree initializer;
110368 + gimple init_stmt;
110369 +
110370 + // this is the original entry bb before the forced split
110371 + // TODO: check further BBs in case more splits occured before us
110372 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110373 +
110374 + // first check if the variable is already initialized, warn otherwise
110375 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110376 + gimple stmt = gsi_stmt(gsi);
110377 + tree rhs1;
110378 +
110379 + // we're looking for an assignment of a single rhs...
110380 + if (!gimple_assign_single_p(stmt))
110381 + continue;
110382 + rhs1 = gimple_assign_rhs1(stmt);
110383 +#if BUILDING_GCC_VERSION >= 4007
110384 + // ... of a non-clobbering expression...
110385 + if (TREE_CLOBBER_P(rhs1))
110386 + continue;
110387 +#endif
110388 + // ... to our variable...
110389 + if (gimple_get_lhs(stmt) != var)
110390 + continue;
110391 + // if it's an initializer then we're good
110392 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110393 + return;
110394 + }
110395 +
110396 + // these aren't the 0days you're looking for
110397 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110398 +
110399 + // build the initializer expression
110400 + initializer = build_constructor(TREE_TYPE(var), NULL);
110401 +
110402 + // build the initializer stmt
110403 + init_stmt = gimple_build_assign(var, initializer);
110404 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110405 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110406 + update_stmt(init_stmt);
110407 +}
110408 +
110409 +static unsigned int handle_function(void)
110410 +{
110411 + basic_block bb;
110412 + unsigned int ret = 0;
110413 + tree var;
110414 +
110415 +#if BUILDING_GCC_VERSION == 4005
110416 + tree vars;
110417 +#else
110418 + unsigned int i;
110419 +#endif
110420 +
110421 + // split the first bb where we can put the forced initializers
110422 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110423 + if (dom_info_available_p(CDI_DOMINATORS))
110424 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110425 +
110426 + // enumarate all local variables and forcibly initialize our targets
110427 +#if BUILDING_GCC_VERSION == 4005
110428 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110429 + var = TREE_VALUE(vars);
110430 +#else
110431 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110432 +#endif
110433 + tree type = TREE_TYPE(var);
110434 +
110435 + gcc_assert(DECL_P(var));
110436 + if (!auto_var_in_fn_p(var, current_function_decl))
110437 + continue;
110438 +
110439 + // only care about structure types
110440 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110441 + continue;
110442 +
110443 + // if the type is of interest, examine the variable
110444 + if (TYPE_USERSPACE(type))
110445 + initialize(var);
110446 + }
110447 +
110448 + return ret;
110449 +}
110450 +
110451 +static struct gimple_opt_pass structleak_pass = {
110452 + .pass = {
110453 + .type = GIMPLE_PASS,
110454 + .name = "structleak",
110455 +#if BUILDING_GCC_VERSION >= 4008
110456 + .optinfo_flags = OPTGROUP_NONE,
110457 +#endif
110458 + .gate = NULL,
110459 + .execute = handle_function,
110460 + .sub = NULL,
110461 + .next = NULL,
110462 + .static_pass_number = 0,
110463 + .tv_id = TV_NONE,
110464 + .properties_required = PROP_cfg,
110465 + .properties_provided = 0,
110466 + .properties_destroyed = 0,
110467 + .todo_flags_start = 0,
110468 + .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
110469 + }
110470 +};
110471 +
110472 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110473 +{
110474 + int i;
110475 + const char * const plugin_name = plugin_info->base_name;
110476 + const int argc = plugin_info->argc;
110477 + const struct plugin_argument * const argv = plugin_info->argv;
110478 + bool enable = true;
110479 +
110480 + struct register_pass_info structleak_pass_info = {
110481 + .pass = &structleak_pass.pass,
110482 + .reference_pass_name = "ssa",
110483 + .ref_pass_instance_number = 1,
110484 + .pos_op = PASS_POS_INSERT_AFTER
110485 + };
110486 +
110487 + if (!plugin_default_version_check(version, &gcc_version)) {
110488 + error(G_("incompatible gcc/plugin versions"));
110489 + return 1;
110490 + }
110491 +
110492 + if (strcmp(lang_hooks.name, "GNU C")) {
110493 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110494 + enable = false;
110495 + }
110496 +
110497 + for (i = 0; i < argc; ++i) {
110498 + if (!strcmp(argv[i].key, "disable")) {
110499 + enable = false;
110500 + continue;
110501 + }
110502 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110503 + }
110504 +
110505 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110506 + if (enable) {
110507 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110508 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110509 + }
110510 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110511 +
110512 + return 0;
110513 +}
110514 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110515 index 280dd82..077b427 100644
110516 --- a/tools/lib/lk/Makefile
110517 +++ b/tools/lib/lk/Makefile
110518 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110519
110520 LIBFILE = liblk.a
110521
110522 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110523 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110524 EXTLIBS = -lelf -lpthread -lrt -lm
110525 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110526 ALL_LDFLAGS = $(LDFLAGS)
110527 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110528 index 6789d78..4afd019e 100644
110529 --- a/tools/perf/util/include/asm/alternative-asm.h
110530 +++ b/tools/perf/util/include/asm/alternative-asm.h
110531 @@ -5,4 +5,7 @@
110532
110533 #define altinstruction_entry #
110534
110535 + .macro pax_force_retaddr rip=0, reload=0
110536 + .endm
110537 +
110538 #endif
110539 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110540 index 96b919d..c49bb74 100644
110541 --- a/tools/perf/util/include/linux/compiler.h
110542 +++ b/tools/perf/util/include/linux/compiler.h
110543 @@ -18,4 +18,12 @@
110544 #define __force
110545 #endif
110546
110547 +#ifndef __size_overflow
110548 +# define __size_overflow(...)
110549 +#endif
110550 +
110551 +#ifndef __intentional_overflow
110552 +# define __intentional_overflow(...)
110553 +#endif
110554 +
110555 #endif
110556 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110557 index 1580dd4..5627b5b 100644
110558 --- a/virt/kvm/kvm_main.c
110559 +++ b/virt/kvm/kvm_main.c
110560 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110561
110562 static cpumask_var_t cpus_hardware_enabled;
110563 static int kvm_usage_count = 0;
110564 -static atomic_t hardware_enable_failed;
110565 +static atomic_unchecked_t hardware_enable_failed;
110566
110567 struct kmem_cache *kvm_vcpu_cache;
110568 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
110569
110570 -static __read_mostly struct preempt_ops kvm_preempt_ops;
110571 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
110572 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
110573 +static struct preempt_ops kvm_preempt_ops = {
110574 + .sched_in = kvm_sched_in,
110575 + .sched_out = kvm_sched_out,
110576 +};
110577
110578 struct dentry *kvm_debugfs_dir;
110579
110580 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
110581 /* We can read the guest memory with __xxx_user() later on. */
110582 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
110583 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
110584 - !access_ok(VERIFY_WRITE,
110585 + !__access_ok(VERIFY_WRITE,
110586 (void __user *)(unsigned long)mem->userspace_addr,
110587 mem->memory_size)))
110588 goto out;
110589 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
110590 return 0;
110591 }
110592
110593 -static struct file_operations kvm_vcpu_fops = {
110594 +static file_operations_no_const kvm_vcpu_fops __read_only = {
110595 .release = kvm_vcpu_release,
110596 .unlocked_ioctl = kvm_vcpu_ioctl,
110597 #ifdef CONFIG_COMPAT
110598 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
110599 return 0;
110600 }
110601
110602 -static struct file_operations kvm_vm_fops = {
110603 +static file_operations_no_const kvm_vm_fops __read_only = {
110604 .release = kvm_vm_release,
110605 .unlocked_ioctl = kvm_vm_ioctl,
110606 #ifdef CONFIG_COMPAT
110607 @@ -2662,7 +2667,7 @@ out:
110608 return r;
110609 }
110610
110611 -static struct file_operations kvm_chardev_ops = {
110612 +static file_operations_no_const kvm_chardev_ops __read_only = {
110613 .unlocked_ioctl = kvm_dev_ioctl,
110614 .compat_ioctl = kvm_dev_ioctl,
110615 .llseek = noop_llseek,
110616 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
110617
110618 if (r) {
110619 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
110620 - atomic_inc(&hardware_enable_failed);
110621 + atomic_inc_unchecked(&hardware_enable_failed);
110622 printk(KERN_INFO "kvm: enabling virtualization on "
110623 "CPU%d failed\n", cpu);
110624 }
110625 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
110626
110627 kvm_usage_count++;
110628 if (kvm_usage_count == 1) {
110629 - atomic_set(&hardware_enable_failed, 0);
110630 + atomic_set_unchecked(&hardware_enable_failed, 0);
110631 on_each_cpu(hardware_enable_nolock, NULL, 1);
110632
110633 - if (atomic_read(&hardware_enable_failed)) {
110634 + if (atomic_read_unchecked(&hardware_enable_failed)) {
110635 hardware_disable_all_nolock();
110636 r = -EBUSY;
110637 }
110638 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
110639 kvm_arch_vcpu_put(vcpu);
110640 }
110641
110642 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110643 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110644 struct module *module)
110645 {
110646 int r;
110647 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110648 if (!vcpu_align)
110649 vcpu_align = __alignof__(struct kvm_vcpu);
110650 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
110651 - 0, NULL);
110652 + SLAB_USERCOPY, NULL);
110653 if (!kvm_vcpu_cache) {
110654 r = -ENOMEM;
110655 goto out_free_3;
110656 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110657 if (r)
110658 goto out_free;
110659
110660 + pax_open_kernel();
110661 kvm_chardev_ops.owner = module;
110662 kvm_vm_fops.owner = module;
110663 kvm_vcpu_fops.owner = module;
110664 + pax_close_kernel();
110665
110666 r = misc_register(&kvm_dev);
110667 if (r) {
110668 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110669
110670 register_syscore_ops(&kvm_syscore_ops);
110671
110672 - kvm_preempt_ops.sched_in = kvm_sched_in;
110673 - kvm_preempt_ops.sched_out = kvm_sched_out;
110674 -
110675 r = kvm_init_debug();
110676 if (r) {
110677 printk(KERN_ERR "kvm: create debugfs files failed\n");